vulkan/runtime: only consider slice info with 3D image views
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 3 Mar 2023 10:50:45 +0000 (12:50 +0200)
committerMarge Bot <emma+marge@anholt.net>
Sat, 4 Mar 2023 06:12:46 +0000 (06:12 +0000)
Because we can have 2D views of 3D images, we want to consider the
slice info only with 3D *image views*.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 66e3ccbcac ("vulkan/runtime: store parameters of VK_EXT_sliced_view_of_3d")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21376>

src/vulkan/runtime/vk_image.c
src/vulkan/runtime/vk_image.h

index 0eb3405..e4bd997 100644 (file)
@@ -472,7 +472,7 @@ vk_image_view_init(struct vk_device *device,
              <= image->array_layers);
       break;
    case VK_IMAGE_TYPE_3D:
-      if (sliced_info) {
+      if (sliced_info && image_view->view_type == VK_IMAGE_VIEW_TYPE_3D) {
          unsigned total = image_view->extent.depth;
          image_view->storage.z_slice_offset = sliced_info->sliceOffset;
          assert(image_view->storage.z_slice_offset < total);
@@ -481,9 +481,12 @@ vk_image_view_init(struct vk_device *device,
          } else {
             image_view->storage.z_slice_count = sliced_info->sliceCount;
          }
-         assert(image_view->storage.z_slice_offset + image_view->storage.z_slice_count
-                <= image->extent.depth);
+      } else if (image_view->view_type != VK_IMAGE_VIEW_TYPE_3D) {
+         image_view->storage.z_slice_offset = image_view->base_array_layer;
+         image_view->storage.z_slice_count = image_view->layer_count;
       }
+      assert(image_view->storage.z_slice_offset + image_view->storage.z_slice_count
+             <= image->extent.depth);
       assert(image_view->base_array_layer + image_view->layer_count
              <= image_view->extent.depth);
       break;
index 0716a2b..bd120da 100644 (file)
@@ -283,16 +283,17 @@ struct vk_image_view {
    struct {
       /* VkImageViewSlicedCreateInfoEXT::sliceOffset
        *
-       * This field will be 0 for 1D and 2D images or when no
-       * VkImageViewSlicedCreateInfoEXT is provided.
+       * This field will be 0 for 1D and 2D images, 2D views of 3D images, or
+       * when no VkImageViewSlicedCreateInfoEXT is provided.
        */
       uint32_t z_slice_offset;
 
       /* VkImageViewSlicedCreateInfoEXT::sliceCount
        *
-       * This field will be 1 for 1D and 2D images and the image view depth
-       * (see vk_image_view::extent) when no VkImageViewSlicedCreateInfoEXT is
-       * provided.
+       * This field will be 1 for 1D and 2D images or 2D views of 3D images.
+       * For 3D views, it will be VkImageViewSlicedCreateInfoEXT::sliceCount
+       * or image view depth (see vk_image_view::extent) when no
+       * VkImageViewSlicedCreateInfoEXT is provided.
        */
       uint32_t z_slice_count;
    } storage;