Let’s say we have two subpasses, the first one contains an image as a color attachment and the second one uses this image as a texture.
renderPass1 = {
initialLayout = undefined,
finalLayout = shader read only optimal
};
We need to synchronise the color attachment output and fragment shader stage in subpass dependency.
It’s all clear here:
Subpass dependency in renderPass1
srcSubpass = lastSubpass,
dstSubpass = VK_SUBPASS_EXTERNAL,
srcStageMask = color attachment output,
srcAccessMask = color attachment write,
dstStageMask = fragment shader,
dstAccessMask = shader read
And here it is not clear:
Subpass dependency in renderPass2
srcSubpass = VK_SUBPASS_EXTERNAL,
dstSubpass = 0,
srcStageMask = color attachment output,
srcAccessMask = color attachment write,
dstStageMask = fragment shader,
dstAccessMask = shader read
I have a question: How does this synchronise the transition of the image layout from renderPass1 to finalLayout? How can the subpassDependency of one renderPass synchronise the layout transition of another renderPass?
My previous question was answered that layout transition happens between two synchronisation areas. Then the question arises: In this situation it only works with the transition to the finalLayout or with layout transitions at the beginning of the subpass too?