Fix vkCmdBeginRenderPass SYNC-HAZARD-WRITE-AFTER-READ error#1657
Fix vkCmdBeginRenderPass SYNC-HAZARD-WRITE-AFTER-READ error#1657TP-David wants to merge 1 commit intovsg-dev:masterfrom
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 |
|
I have merged the enabling of synchronization validation layer and get the validation error for the Copy but haven't see one yet for vkCmdBeginRenderPass one. I've been using: vsgviewer models/openstreetmap.vsgt --sync -dIs there another example that I should be using? |
|
vsgdraw --sync -d prints the error still on master: vsgtext --sync -d (after modifying windowTraits to take arguments on line 173) |
|
vsgdraw --sync -d doesn't produce any errors on my Kubuntu 24.04 + Geforce 2060 system, Vulkan 1.4.335.0. So... perhaps Windows drivers are doing something different. |
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