anv: Ignore unused dimensions in vkCreateImage
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Wed, 17 Feb 2016 20:21:46 +0000 (12:21 -0800)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Wed, 17 Feb 2016 20:21:51 +0000 (12:21 -0800)
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.

src/vulkan/anv_image.c

index 4ce997589c500283b4e82c9746d4f04c57494dcf..dfacced92ef8b8f9e965388b9d2efcabfb9281c3 100644 (file)
@@ -124,13 +124,28 @@ make_surface(const struct anv_device *dev,
 
    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,