Skip to content
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

Vulkan Pipeline Barrier Synchronization Issue: Invalid Source Stage in vkCmdPipelineBarrier. #8176

Open
Mordentary opened this issue Nov 22, 2024 · 0 comments

Comments

@Mordentary
Copy link

Version/Branch of Dear ImGui:

docking branch (1.91.5)

Back-ends:

imgui_impl_vulkan.cpp, sdl

Compiler, OS:

Windows 11 + msvc

Full config/build information:

No response

Details:

My Issue/Question:

Hi, so I found this trying to fix validation error.
The issue
When dragging an ImGui window outside of the main application window, a synchronization hazard occurs due to incorrect pipeline barrier stage flags. The Vulkan backend uses VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT as the source stage in vkCmdPipelineBarrier, which causes a read-write hazard during external window operations.

Validation Error Details shCopy[ERROR] Validation Error: [ SYNC-HAZARD-WRITE-AFTER-READ ] Object 0: handle = 0x291d2876fa0, type = VK_OBJECT_TYPE_QUEUE; MessageID = 0x376bc9df vkQueueSubmit(): Hazard WRITE_AFTER_READ for entry 0, VkCommandBuffer 0x291efc487a0[] Submitted access info (submitted_usage: SYNC_IMAGE_LAYOUT_TRANSITION, command: vkCmdPipelineBarrier, seq_no: 1, reset_no: 112) Access info (prior_usage: SYNC_PRESENT_ENGINE_SYNCVAL_PRESENT_ACQUIRE_READ_SYNCVAL, read_barriers: VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT|VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT, batch_tag: 3367, vkAcquireNextImageKHR aquire_tag:3367: VkSwapchainKHR 0x1d4e2e0000000062[], image_index: 2image: VkImage 0x5dbcf90000000065[])

Expected behavior
The pipeline barrier should properly synchronize the image layout transition when dragging windows outside the main window, without triggering any validation errors. This should be achieved by using the correct source stage flag (VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT).

Reproduction Steps:

  • Use ImGui docking branch with Vulkan backend
  • Enable synchronization validation
  • Create a window in the application
  • Drag the window outside the main application window
  • Observe validation error in debug output

Related discussion:
SYNC-HAZARD-WRITE-AFTER-READ error with swapchain acquisition and command buffer submission

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

// In imgui_impl_vulkan.cpp
vkCmdPipelineBarrier(fd->CommandBuffer,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, // srcStageMask (incorrect)
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, // dstStageMask
0,
0, nullptr,
0, nullptr,
1, &barrier);

Proposed Fix:
cppCopyvkCmdPipelineBarrier(fd->CommandBuffer,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, // srcStageMask (correct)
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, // dstStageMask
0,
0, nullptr,
0, nullptr,
1, &barrier);

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

No branches or pull requests

1 participant