nvpro_core
nvpro_core copied to clipboard
Possible memory hazard on depth buffer in AppBaseVk?
https://github.com/nvpro-samples/nvpro_core/blob/8096be945319118ab8ca8ce873d1ee46c387e8ac/nvvkhl/appbase_vk.cpp#L226
As shwon above line, only one depth buffer is shared by mutliple swap chain frame buffers in nvvkhl::AppBaseVk
class.
But it seems there is nothing that prevents more than on frame rendering processes simultaneoulsy writing the depth buffer.
A similar problem has been discussed in following stack overflow page. https://stackoverflow.com/questions/62371266/why-is-a-single-depth-buffer-sufficient-for-this-vulkan-swapchain-render-loop
Shouldn't there be mutliple depth buffers as well? Or change the subpass dependency as shwon in the answer of above stack overflow page?
https://github.com/nvpro-samples/nvpro_core/blob/8096be945319118ab8ca8ce873d1ee46c387e8ac/nvvkhl/appbase_vk.cpp#L279
I have done some research. and learned that this will not cause problem in most GPUs that has a single queue to execute rendering commands in the order.
But some hardware that may use multiple queue to execute the rendering commands may cause race condition on the depth buffer. Even in this case, there wouldn't be much performance gain by using multiple depth buffer, so I think the solution should be keep using one depth/stencil buffer but fix the stage masks in sub pass dependency.