Vulkan icon indicating copy to clipboard operation
Vulkan copied to clipboard

In the example Inputattachments,subpass dependencies didn't take care of the layout transition of depth image.

Open CretaceousConstructor opened this issue 3 years ago • 6 comments

I ran this example with Vulkan configurator's Synchronization utility on,and got errors:

SYNC-HAZARD-WRITE_AFTER_WRITE(ERROR / SPEC): msgNum: -33950239 - Validation Error: [ SYNC-HAZARD-WRITE_AFTER_WRITE ] Object 0: handle = 0x2bb0785d7b0, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0xfdf9f5e1 | vkCmdBeginRenderPass: Hazard WRITE_AFTER_WRITE vs. layout transition in subpass 0 for attachment 2 aspect depth during load with loadOp VK_ATTACHMENT_LOAD_OP_CLEAR.

    Objects: 1

        [0] 0x2bb0785d7b0, type: 18, name: NULL

(more errors in the attached file) inputattachmentsWithExplicit.txt

the layout transiton of depth image from VK_IMAGE_LAYOUT_UNDEFINED(VK_SUBPASS_EXTERNAL) to VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL (supass 0) has to happen before the depth image is used as output-depth values recipient(or more concisely,as render target ).my solution is here:

dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL;
dependencies[0].dstSubpass = 0;
dependencies[0].srcStageMask =VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
dependencies[0].dstStageMask = 
   VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | 
   VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
dependencies[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
dependencies[0].dstAccessMask   =   
    VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | 
    VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | 
    VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
dependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;

This make sure that the layout transition will happen before VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT stage when depth values need to be writen to depth image.But I'm not sure if this is the optimal method.

CretaceousConstructor avatar Apr 07 '21 15:04 CretaceousConstructor

This has been a problem with many examples (even triangle).

I applied @CretaceousConstructor 's solution to void VulkanExampleBase::setupRenderPass() and the validation error went away.

kyamant avatar May 16 '21 10:05 kyamant

I'm aware of the synchronization issues. I'm in the process of completely reworking synchronization in my samples and will tackle issues as this in that process.

SaschaWillems avatar May 16 '21 10:05 SaschaWillems

Seems like this went away with 1.2.182.0

kyamant avatar Sep 11 '21 20:09 kyamant

Seems like this went away with 1.2.182.0

Is that because some new implicit transitions have been added ?

CretaceousConstructor avatar Sep 12 '21 05:09 CretaceousConstructor

Seems like this went away with 1.2.182.0

Is that because some new implicit transitions have been added ?

Not sure about the underlying mechanics; just an observation.

kyamant avatar Sep 12 '21 12:09 kyamant

Curiously enough, the validation messages came back with 1.2.189.2 ?

kyamant avatar Oct 04 '21 14:10 kyamant