Reputation: 14466
When we provide attachment references when creating a subpass for a render pass we do something like the following:
VkAttachmentReference {.attachment = 1, .layout = VkImageLayout::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL};
The image layout constant tells Vulkan what layout to transition the image to after the sub-pass ends. So it goes something like this:
BEGIN_RENDER_PASS: (EXPECTS THE LAYOUT TO BE THAT SPECIFIED IN THE ATTACHMENT DESCRIPTION)
FIRST SUB-PASS ( EXPECTS THE INITIAL LAYOUT SPECIFIED IN THE ATTACHMENT DESCRIPTION)
FIRST SUB-PASS ENDS (TRANSITIONS THE IMAGE TO THAT SPECIFIED IN THE ATTACHMENT REFERENCE LAYOUT
SECOND SUB-PASS ( EXPECTS THE LAYOUT OF THE IMAGE AS THE ONE SPECIFIED IN THE LAST SUB-PASS ATTACHMENT REFERENCE, AND WHEN SUB-PASS IS FINISHED TRANSITIONS THE IMAGE LAYOUT TO THAT SPECIFIED IN LAYOUT OF ATTACHMENT REFERENCE)
END_RENDER_PASS (TRANSITIONS THE IMAGE TO THE FINAL LAYOUT. IT KNOWS WHAT LAYOUT IT'S ALREADY IN BASED ON THE THE ATTACHMENT REFERENCE LAYOUT OF THE LAST SUB-PASS)
Upvotes: 1
Views: 568
Reputation: 474536
The image layout constant tells Vulkan what layout to transition the image to after the sub-pass ends.
No. The attachment reference layout tells Vulkan what layout to transition the image to at the beginning of the subpass for which this reference is defined. Or more to the point, it is the layout which the image will be in for the duration of the subpass.
The first transition for an attached image of a render pass will be from the initialLayout
for the render pass to the reference layout for the first subpass that uses the image. The last transition for an attached image will be from reference layout of the final subpass that uses the attachment to the finalLayout
for the render pass.
Upvotes: 5