Skip to content

Conversation

@TP-David
Copy link
Contributor

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

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
@robertosfield
Copy link
Collaborator

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 -d

I don't get any errors even without applying this PR or the other PR.

Which version of the VSG did you test against?

@TP-David
Copy link
Contributor Author

TP-David commented Jan 27, 2026

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).

@robertosfield
Copy link
Collaborator

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.

@TP-David
Copy link
Contributor Author

--sync -d and --sync prints nothing for me in vsgdraw and vsgtext on master. Seems the only way to trigger it is via Vulkan Configurator,

@robertosfield
Copy link
Collaborator

--sync -d and --sync prints nothing for me in vsgdraw and vsgtext on master. Seems the only way to trigger it is via Vulkan Configurator,

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:

  1. When the VSG enables the synchronization layer it's not doing it in the same way that the Vulkan Configurator is doing it so not triggering the same tests.
  2. When Vulkan Configurator runs it alters the environment that the application is running enough to affect application behavior/timings.

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.

@TP-David
Copy link
Contributor Author

I did some digging and after setting createInfo.pNext to a VkValidationFeaturesEXT struct in the Instance constructor I do get the errors with --sync -d. This is what the Vulkan Configurator does behind the scenes, it seems that just requesting the layer is not sufficient in this case.

    VkValidationFeatureEnableEXT validationFeature = VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT;
    VkValidationFeaturesEXT validationFeatures{};
    validationFeatures.sType = VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT;
    validationFeatures.enabledValidationFeatureCount = 1;
    validationFeatures.pEnabledValidationFeatures = &validationFeature;
    createInfo.pNext = &validationFeatures;

For an actual implementation this should probably be changed to only be enabled with the proper WindowTraits.

@robertosfield
Copy link
Collaborator

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.

@TP-David
Copy link
Contributor Author

Created PR: #1665

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants