nvpro-samples / vk_raytracing_tutorial_KHR

Ray tracing examples and tutorials using VK_KHR_ray_tracing
Apache License 2.0
1.34k stars 142 forks source link

Incorrect srcStageMask in vkCmdPipelineBarrier in ray_tracing_ao #45

Closed lukelmy closed 1 year ago

lukelmy commented 1 year ago

In ray_tracing_ao, g-buffer is drawn in fragment shader and sampled in compute shader. Between both shaders there is a pipeline barrier. According to vulkan specs, the srcStageMask should be VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT instead of VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT which may cause corruption sometimes.

VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT specifies the stage of the pipeline after blending where the final color values are output from the pipeline. This stage also includes subpass load and store operations, multisample resolve operations for framebuffer attachments with a color or depth/stencil format, and vkCmdClearAttachments.

https://github.com/nvpro-samples/vk_raytracing_tutorial_KHR/blob/003bab42a58fd028a20f7c307ca991a1b5a6f48c/ray_tracing_ao/hello_vulkan.cpp#L810

lukelmy commented 1 year ago

Also "imgMemBarrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT" should be added before L829. https://github.com/nvpro-samples/vk_raytracing_tutorial_KHR/blob/003bab42a58fd028a20f7c307ca991a1b5a6f48c/ray_tracing_ao/hello_vulkan.cpp#L829-L830

mklefrancois commented 1 year ago

Thanks for spotting this @lukelmy , the change was committed in 525becc66ca5c27309560192ecc0db435959532d