Corrupted depth buffer with no reason

Hello, here is a short video (set 1080p res) bug for khronos - YouTube

In the first case girl’s mesh is rendered in depth buffer during depth prepass. First frame is fine but another frame has suddenly corrupted depth buffer when vkCmdEndRenderPass() is called. Both frames captured during same session after application starts, so there is some flickering.

In the second case trees are rendered. In first frame every next draw call adds more data to depth buffer. In the second frame every next draw call clears depth buffer completely and then adds own data. Also during pixel debugging you can see that it reports update failing by discard operation but in shader discard command wasn’t called.

I may add that this problem occurs randomly. When application starts there might be the problem and then it reveals itself under specific angles of camera but never disappears completely or there might not be the problem and no action is able to reproduce it except restart. Also it happens only when meshes are rendered to depth buffer without other render targets (shadows or depth prepass) and secondary command buffers with flag VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT are used (even if they are recorded in the same thread without multithreading)

I have latests driver for Radeon RX 480 and 1.3.216 vulkan version (same problem for 1.2.189). Any ideas what happens?

This is typical for missing synchronization. So how do you sync your writes and reads?

I have barriers placed automatically, here is depth buffer usage scheme (or what kind of synchronization do you mean?)