At what point does the image layout change in subpass?

Hello.
I am interested in the moment when the layout is changed to the one specified in VkAttachmentReference.layout? Is it tied to some stage of the pipeline?
As far as I understand, when the vkCmdDraw() command starts executing, the subpass execution begins and before it starts, the image layout(if it is used by the subpass) changes to the specified in VkAttachmentReference.layout, but when does this happen? Is this related to the pipeline stages?

The layout change happens between the two synchronization scopes as provided by the VkSubpassDependencys.

That is, the layout changes before the start of the subpass?
What if VkSubpassDependency is not described?

The layout of attachments change between subpasses. Beyond that, when the change happens is irrelevant. It “happens before” anything in the subpass, and “happens after” anything in the previous subpass.

1 Like

Then in the case of two subpasses, it is missynchronized if the attachment is used in both. And in the case of external subpasses it is unbounded on one side (as prescribed by the implicit dependency in the specification), and happens in STAGE_NONE, which should count as BOTTOM or TOP contextually, and could be synchronized against later.

1 Like

That’s technically not true. It is bounded to the provided Dependencies. With the exception of read-read accesses, in which case a Dependency is not required and driver will deal with the clashing layout changes itself.

Though it is irrelevant to the extent that if the code is correctly synchronized in the first place, then it already does the layout changes correctly.

The relevant sections of the specification are here: Vulkan® 1.0.223 - A Specification

2 Likes