Initial layout in VkAttachmentDescription

There is InitialLayout in VkAttachmentDescription structure, it is not clear from specification what it is for. As I understand it, in this field we specify the image layout, with which the render pass will work. But it could also mean the layout which will be set with layout transition at the beginning of renderPass. Which version is true?

initialLayout is parameter telling Vulkan in which layout will the image already be in when you hand it to the render pass. Subpass layout parameter is the layout it will be converted to (should it differ from initalLayout) for the duration of the given subpass. finalLayout is the layout the image will be converted to from the layout of the last subpass that used it (if they differ).

Thanks, in the case where the layout of the image differs from the initial layout, a layout transition occurs. In that case, if we get an image from a swap chain, for example, do we need to synchronize the layout transition with the image from the swap chain? If so, how?

Um, no. You misunderstand.

Vulkan requires you to tell it what layout the image is in. At all times. Everything that uses an image requires that you tell Vulkan what layout it is in. Not just render passes, but everything else that touches images needs to know what layout it will be in at that point in executing the command buffer.

The initial layout is the layout that the attached image will be in when the render pass starts. And if it is not in that layout, undefined behavior will result.

Note that the initial layout is different from the layout of an attachment during a subpass. This is the layout that Vulkan is required to transition the image into for the duration of that subpass.

1 Like

Okay, we initialize the initial layout with undefined, does that mean that we don’t care which layout the image is in, because it will end up being colorAttachmentOptimal at the beginning of the subpass, for example?

Yes; that’s what the undefined “layout” means. It’s still a layout transition.

1 Like

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