Setting an image memory barrier
Images are created for various purposes--they are used as textures, by binding them to a pipeline via descriptor sets, as render targets, or as presentable images in swapchains. We can copy data to or from images--these are also separate usages defined during image creation.
Before we start using an image for any purpose, and every time we want to change the current usage of a given image, we need to inform a driver about this operation. We do this by using image memory barriers which are set during command buffer recording.
Getting ready
For the purpose of this recipe, a custom structure type ImageTransition
is introduced. It has the following definition:
struct ImageTransition { VkImage Image; VkAccessFlags CurrentAccess; VkAccessFlags NewAccess; VkImageLayout CurrentLayout; VkImageLayout NewLayout; uint32_t CurrentQueueFamily; uint32_t NewQueueFamily; VkImageAspectFlags Aspect...