Overv / VulkanTutorial

Tutorial for the Vulkan graphics and compute API
https://vulkan-tutorial.com
Creative Commons Attribution Share Alike 4.0 International
3.06k stars 511 forks source link

Synchronization Validation Error in 30_multisampling.cpp #349

Closed krfantasy closed 11 months ago

krfantasy commented 11 months ago

When enabling Synchronization Validation in 30_multisampling.cpp, a validation error is reported:

SYNC-HAZARD-WRITE-AFTER-WRITE(ERROR / SPEC): msgNum: 1544472022 - Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0x55d5c6124420, type = VK_OBJECT_TYPE_QUEUE; | MessageID = 0x5c0ec5d6 | vkQueueSubmit: Hazard WRITE_AFTER_WRITE for entry 0, VkCommandBuffer 0x55d5c6578420[], Recorded access info (recorded_usage: SYNC_IMAGE_LAYOUT_TRANSITION, command: vkCmdBeginRenderPass, seq_no: 1,renderpass: VkRenderPass 0xe88693000000000c[], reset_no: 2). Access info (prior_usage: SYNC_COLOR_ATTACHMENT_OUTPUT_COLOR_ATTACHMENT_WRITE, write_barriers: 0, queue: VkQueue 0x55d5c6124420[], submit: 5, batch: 0, batch_tag: 42, command: vkCmdEndRenderPass, seq_no: 3, command_buffer: VkCommandBuffer 0x55d5c64bf8d0[],renderpass: VkRenderPass 0xe88693000000000c[], reset_no: 2). Objects: 1 [0] 0x55d5c6124420, type: 4, name: NULL

This issue is similar to the one discussed in https://github.com/Overv/VulkanTutorial/issues/308. The additional multisampled color attachment also needs proper synchronization to prevent write-after-write hazards.

To ensure that the color attachment write operations from previous commands are completed before any subsequent color attachment write operations, add VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT in the srcAccessMask:

 dependency.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;