Reputation: 101
I am having some troubles understanding the Image and image view parameter compatibility requirements table in the VkImageViewCreateInfo
documentation and the VkImageViewCreateInfo::viewType
. The image VkImageViewCreateInfo
properties seams to be flexible enough to create, for example, a single 1D or 1D array image view of a 2D image. I tried to create 1D image view out of a 2D image with validation layers enabled and I got no warnings (I don't know exactly which row/column will be used if this is a valid usage).
Is it true to assume that there is one-to-one mapping between the VkImageCreateInfo::imageType
+ VkImageCreateInfo::arrayLayers
in the image and the VkImageViewCreateInfo::viewType
in the view, i.e. this VkImageViewType type is there to handle the special case of cube maps, otherwise viewType
could've been inferred from the image type? If not, how does the 1D view of 2D image work?
Upvotes: 0
Views: 259
Reputation: 6787
You can't create a 1D view of a 2D image, only the combinations listed in the table are valid.
It looks like the page you're looking at hasn't been regenerated recently, or doesn't include modifications made by the VK_KHR_maintenance1 extension.
Ignoring that extension and cubemaps for now, it's not quite true that there is a 1:1 correspondence between imageType+arrayLayers and viewType. A 2D image with multiple layers can be used with either 2D or 2D_ARRAY view types, and a 2D image with only one layer can still be used with a 2D_ARRAY view type. The view type corresponds to the SPIR-V resource types, and mostly determines how many coordinates are needed to identify a location in the view.
Then there is the cubemap complication, as you observed.
With VK_KHR_maintenance1, you can create 2D and 2D_ARRAY views of a subset of the slices in a 3D image. The extension adds two new rows to the table to describe that case.
Upvotes: 1