Render passes synchronization

I want to apply post-processing to an image in render pass, using the color attachment of the past render pass as a

So far I’m using:

finalLayout = Shader read only optimal

Subpass dependency:

srcStageMask = Color Attachment Output
srcAccessMask = Color Attachment Write
dstStageMask = Fragment Shader
dstAccessMask = Shader Read

But I’m not sure if this will work, since the layout transition to finalLayout happens after the render pass finishes, and here only the Color Attachment Output stage is expected to finish. How can I make it so that the image is used as a texture after the end of the previous render pass?

I’m not knowledgeable enough to give a direct answer; have you looked at the Vulkan Synchronization Examples? In particular this one seems to apply to your situation.

These do assume you can make use of the VK_KHR_synchronization2 extension (or Vulkan 1.3), but there’s also a page for legacy APIs.

Isn’t there a transition to finalLayout after transitioning the layout using the barrier? At what point does the transition to finalLayout even occur?

Isn’t that the stage that writes to the image? Is that not the source of the writes that you want to make available to the layout transition and the destination?

I don’t see your concern.

Does the layout transition to finalLayout also happen at the color attachment output stage? I couldn’t find information about this in the specification.

You have found that information before. You simply haven’t internalized it:

When a layout transition is specified in a memory dependency, it happens-after the availability operations in the memory dependency, and happens-before the visibility operations.

That’s what you need to know. Layout transitions do not happen “at a stage”; they happen between two halves of a synchronization operation.

1 Like
srcStageMask = Vertex shader
srcAccessMask = 0
dstStageMask = Fragment Shader
dstAccessMask = Shader Read

In this example, the layout transition to finalLayout will occur between the Vertex shader and color attachment output stages, because VK_SUBPASS_EXTERNAL includes the last subpass of the first render pass, right? If so, then this synchronization could cause the layout transition to occur before the color attachment output first render pass, and therefore the data could be corrupted?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.