anv: Ignore unused dimensions in vkCreateImage
We would assert on unused dimensions (eg extent.depth for
VK_IMAGE_TYPE_2D) not being 1, but the specification doesn't put any
constraints on those. For example, for VK_IMAGE_TYPE_1D:
"If imageType is VK_IMAGE_TYPE_1D, the value of extent.width must be
less than or equal to the value of
VkPhysicalDeviceLimits::maxImageDimension1D, or the value of
VkImageFormatProperties::maxExtent.width (as returned by
vkGetPhysicalDeviceImageFormatProperties with values of format,
type, tiling, usage and flags equal to those in this structure) -
whichever is higher"
We'll fix up the arguments to isl to keep isl strict in what it expects.
diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c
index 4ce9975..dfacced 100644
--- a/src/vulkan/anv_image.c
+++ b/src/vulkan/anv_image.c
@@ -124,13 +124,28 @@
struct anv_surface *anv_surf = get_surface(image, aspect);
+ VkExtent3D extent;
+ switch (vk_info->imageType) {
+ case VK_IMAGE_TYPE_1D:
+ extent = (VkExtent3D) { vk_info->extent.width, 1, 1 };
+ break;
+ case VK_IMAGE_TYPE_2D:
+ extent = (VkExtent3D) { vk_info->extent.width, vk_info->extent.height, 1 };
+ break;
+ case VK_IMAGE_TYPE_3D:
+ extent = vk_info->extent;
+ break;
+ default:
+ unreachable("invalid image type");
+ }
+
ok = isl_surf_init(&dev->isl_dev, &anv_surf->isl,
.dim = vk_to_isl_surf_dim[vk_info->imageType],
.format = anv_get_isl_format(vk_info->format, aspect,
vk_info->tiling, NULL),
- .width = vk_info->extent.width,
- .height = vk_info->extent.height,
- .depth = vk_info->extent.depth,
+ .width = extent.width,
+ .height = extent.height,
+ .depth = extent.depth,
.levels = vk_info->mipLevels,
.array_len = vk_info->arrayLayers,
.samples = vk_info->samples,