-
Notifications
You must be signed in to change notification settings - Fork 263
Fix vkCmdBeginRenderPass SYNC-HAZARD-WRITE-AFTER-READ error #1657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix vkCmdBeginRenderPass SYNC-HAZARD-WRITE-AFTER-READ error #1657
Conversation
Add VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT to colorDependency.srcAccessMask and depthDependency.dstAccessMask Add VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT to depthDependency.srcStageMask and depthDependency.dstStageMask Fix vkCmdBeginRenderPass SYNC-HAZARD-WRITE-AFTER-WRITE error for multi-sampled window Add VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT to dependency.dstStageMask and dependency2.srcStageMask Add VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT to dependency.dstAccessMask and dependency2.srcAccessMask
|
I have tried reproducing the synchronization layer error on my desktop Windows 11 + Geforce 1650 with latest NVidia driver and latestest Vulkan SDK but don't get any errors with VSG and vsgExamples master. vsgdraw.exe --sync -d
vsgtext.exe --sync -dI don't get any errors even without applying this PR or the other PR. Which version of the VSG did you test against? |
|
I'm using the Jan 26 master branch of both VSG and vsgExamples. "Synchronization" validation must be enabled via the Vulkan Configurator that ships with the SDK (1.4.328.1). I also found that the -d flag is not neccessary to trigger it. Also we have done performance tests in our application and haven't found any drops after applying this fix (and the vkCmdCopyBuffer one). |
|
What happens if you use the command line to enable the synchronization layer via --sync rather than the Vulkan Configurator? I updated to the latest NVidia drivers and VulkanSDK today, but I'm not on my Windows 11 machine right now so can't double check the version. I think the NVidia Vulkan driver version was 1.4.330. |
|
|
Interesting finding. Don't know yet what to make of it so we'll need to try out a few more combinations to tease out what might be going on. First thoughts:
My priority is making sure the VSG runs standalone correctly, including enabling the layers like synchronization correctly. Quietening reports when running the VSG in a non standard configuration/environment is potentially dangerous as you could be fixing false positives may inadvertently cause their own problems, problems that might be subtle and not seen until much later. I raise this as I saw exactly this problem in the OSG project with chasing compiler warning fixes that ended up introducing bugs. For now I think it makes sense to figure out if 1. is the case. Does Vulkan Configurator enable options in the synchronization layer? FYI, I don't very rarely use Windows am not familiar the Vulkan Configurator so can't provide answers just off the top of my head. |
|
I did some digging and after setting For an actual implementation this should probably be changed to only be enabled with the proper WindowTraits. |
|
Thanks for looking into it. Could you create a PR with these changes? If not I can look into it tomorrow. First step is to get validation side generating the errors with standalone VSG then to use this to QA these PRs. |
|
Created PR: #1665 |
These errors appear when enabling "Synchronization" Layer Configuration in Vulkan Configurator and running vsgdraw and vsgtext:
Validation Error: [ SYNC-HAZARD-WRITE-AFTER-READ ] | MessageID = 0x376bc9df vkQueueSubmit(): WRITE_AFTER_READ hazard detected. vkCmdBeginRenderPass: ...Fix in vsg::createRenderPass:
Add VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT to colorDependency.srcAccessMask and depthDependency.dstAccessMask
Add VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT to depthDependency.srcStageMask and depthDependency.dstStageMask
Fix in vsg::createMultisampledRenderPass (for multi-sampled windows):
Add VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT to dependency.dstStageMask and dependency2.srcStageMask
Add VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT to dependency.dstAccessMask and dependency2.srcAccessMask
OS Windows 11
GPU NVIDIA RTX 2000 Ada Generation Laptop GPU
Driver date 10/12/2025
Vulkan 1.4.328.1