Module: Mesa
Branch: main
Commit: 4ee1908ab60058c958d376d9da3167829cbf5b12
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ee1908ab60058c958d376d9da3167829cbf5b12

Author: Lionel Landwerlin <[email protected]>
Date:   Fri Mar  3 12:50:45 2023 +0200

vulkan/runtime: only consider slice info with 3D image views

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 <[email protected]>
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 |  9 ++++++---
 src/vulkan/runtime/vk_image.h | 11 ++++++-----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/vulkan/runtime/vk_image.c b/src/vulkan/runtime/vk_image.c
index 0eb34050f7e..e4bd997a215 100644
--- a/src/vulkan/runtime/vk_image.c
+++ b/src/vulkan/runtime/vk_image.c
@@ -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;
diff --git a/src/vulkan/runtime/vk_image.h b/src/vulkan/runtime/vk_image.h
index 0716a2bb4ed..bd120da646a 100644
--- a/src/vulkan/runtime/vk_image.h
+++ b/src/vulkan/runtime/vk_image.h
@@ -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;

Reply via email to