Reputation: 68728
Under Appendix H of the Vulkan spec it says:
Aspect (Image):
An image may contain multiple kinds, or aspects, of data for each pixel, where each aspect is used in a particular way by the pipeline and may be stored differently or separately from other aspects. For example, the color components of an image format make up the color aspect of the image, and may be used as a framebuffer color attachment. Some operations, like depth testing, operate only on specific aspects of an image. Others operations, like image/buffer copies, only operate on one aspect at a time.
In addition there is the type VkImageAspectFlagBits
which (I think) lists the 7 possible aspects an image can have:
VK_IMAGE_ASPECT_COLOR_BIT
VK_IMAGE_ASPECT_DEPTH_BIT
VK_IMAGE_ASPECT_STENCIL_BIT
VK_IMAGE_ASPECT_METADATA_BIT
VK_IMAGE_ASPECT_PLANE_0_BIT
VK_IMAGE_ASPECT_PLANE_1_BIT
VK_IMAGE_ASPECT_PLANE_2_BIT
VkImageCreateInfo
does not have an aspects field.
If I understand correctly, a given VkImage
has a subset of these 7 aspects, right?
Is there a way to deduce which of the 7 aspects a VkImage has from its VkImageCreateInfo
?
ie how would you write a function that returns a bit mask of which aspects an image has?
VkImageAspectFlagsBits GetImageAspects(const VkImageCreateInfo& info) { ??? }
Upvotes: 1
Views: 503
Reputation: 6807
You can mostly derive which aspects an image has from its format:
VK_IMAGE_ASPECT_COLOR_BIT
refers to all R, G, B, and/or A components available in the format.VK_IMAGE_ASPECT_DEPTH_BIT
refers to D components.VK_IMAGE_ASPECT_STENCIL_BIT
refers to S components.VK_IMAGE_ASPECT_PLANE_n_BIT
refer to the planes of multi-planar formats, i.e. ones with 2PLANE
or 3PLANE
in their name. These aspects are mostly used in copy commands, but can also be used to create a VkImageView
of an individual plane rather than the whole image.VK_IMAGE_ASPECT_METADATA_BIT
is the odd one whose presence isn't based on format. Instead, images with sparse residency (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT
) have a metadata aspect.If an image doesn't have the components or flag corresponding to the aspect, then it doesn't have that aspect.
Upvotes: 1