Skip to content

Vulkan: Fix texture synchronization #8772

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

Closed
wants to merge 2 commits into from

Conversation

Majora320
Copy link
Contributor

This fixes two bugs around synchronization when uploading textures to the GPU:

  • The pipeline barrier only waits on the copy with VK_PIPELINE_STAGE_HOST_BIT, but it must also wait for any ongoing reads to be complete with VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT.
  • The specification for vkFlushMappedMemoryRanges states that it does not guarantee for writes to be available to the device unless a memory dependency is specified on VK_ACCESS_HOST_WRITE_BIT.

The first bug is currently caught by the synchronization profile of the validation layers with this message:

Validation Error: [ SYNC-HAZARD-WRITE-AFTER-READ ] | MessageID = 0x376bc9df
vkQueueSubmit(): WRITE_AFTER_READ hazard detected. vkCmdPipelineBarrier (from VkCommandBuffer 0x55da2be07fb0 submitted on the current VkQueue 0x55da2bcf0cb0) writes to VkImage 0x250000000025, which was previously read by vkCmdDrawIndexed (from VkCommandBuffer 0x55da2bd5a610 submitted on VkQueue 0x55da2bcf0cb0). 
No sufficient synchronization is present to ensure that a layout transition does not conflict with a prior read (VK_ACCESS_2_SHADER_SAMPLED_READ_BIT) at VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT.
Vulkan insight: an execution dependency is sufficient to prevent this hazard.
Objects: 2
    [0] VkQueue 0x55da2bcf0cb0
    [1] VkCommandBuffer 0x55da2be07fb0

@ocornut
Copy link
Owner

ocornut commented Jul 7, 2025

Thank you Moses. Merged as c2d9b07, 032e139, c0d02e5. I had forgotten to update the Changelog so done that in a third commit.

@ocornut ocornut closed this Jul 7, 2025
@ocornut ocornut added the bug label Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants