vulkan/runtime: Rename and document storage image Z range
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Fri, 3 Mar 2023 17:36:36 +0000 (11:36 -0600)
committerMarge Bot <emma+marge@anholt.net>
Sat, 4 Mar 2023 06:12:46 +0000 (06:12 +0000)
This makes it more clear that the fields specifically apply to the Z
range and aren't array slices.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21376>

src/gallium/frontends/lavapipe/lvp_image.c
src/vulkan/runtime/vk_image.c
src/vulkan/runtime/vk_image.h

index d87c5fd..edc4fb6 100644 (file)
@@ -250,8 +250,8 @@ lvp_create_imageview(const struct lvp_image_view *iv)
       view.format = lvp_vk_format_to_pipe_format(iv->vk.format);
 
    if (iv->vk.view_type == VK_IMAGE_VIEW_TYPE_3D) {
-      view.u.tex.first_layer = iv->vk.storage.slice_offset;
-      view.u.tex.last_layer = view.u.tex.first_layer + iv->vk.storage.slice_count - 1;
+      view.u.tex.first_layer = iv->vk.storage.z_slice_offset;
+      view.u.tex.last_layer = view.u.tex.first_layer + iv->vk.storage.z_slice_count - 1;
    } else {
       view.u.tex.first_layer = iv->vk.base_array_layer,
       view.u.tex.last_layer = iv->vk.base_array_layer + iv->vk.layer_count - 1;
index 1057340..0eb3405 100644 (file)
@@ -456,8 +456,8 @@ vk_image_view_init(struct vk_device *device,
    /* By default storage uses the same as the image properties, but it can be
     * overriden with VkImageViewSlicedCreateInfoEXT.
     */
-   image_view->storage.slice_offset = 0;
-   image_view->storage.slice_count = image_view->extent.depth;
+   image_view->storage.z_slice_offset = 0;
+   image_view->storage.z_slice_count = image_view->extent.depth;
 
    const VkImageViewSlicedCreateInfoEXT *sliced_info =
       vk_find_struct_const(pCreateInfo, IMAGE_VIEW_SLICED_CREATE_INFO_EXT);
@@ -474,14 +474,14 @@ vk_image_view_init(struct vk_device *device,
    case VK_IMAGE_TYPE_3D:
       if (sliced_info) {
          unsigned total = image_view->extent.depth;
-         image_view->storage.slice_offset = sliced_info->sliceOffset;
-         assert(image_view->storage.slice_offset < total);
+         image_view->storage.z_slice_offset = sliced_info->sliceOffset;
+         assert(image_view->storage.z_slice_offset < total);
          if (sliced_info->sliceCount == VK_REMAINING_3D_SLICES_EXT) {
-            image_view->storage.slice_count = total - image_view->storage.slice_offset;
+            image_view->storage.z_slice_count = total - image_view->storage.z_slice_offset;
          } else {
-            image_view->storage.slice_count = sliced_info->sliceCount;
+            image_view->storage.z_slice_count = sliced_info->sliceCount;
          }
-         assert(image_view->storage.slice_offset + image_view->storage.slice_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
index c2b0a3a..0716a2b 100644 (file)
@@ -279,9 +279,22 @@ struct vk_image_view {
    uint32_t base_array_layer;
    uint32_t layer_count;
 
+   /* VK_EXT_sliced_view_of_3d */
    struct {
-      uint32_t slice_offset;
-      uint32_t slice_count;
+      /* VkImageViewSlicedCreateInfoEXT::sliceOffset
+       *
+       * This field will be 0 for 1D and 2D 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.
+       */
+      uint32_t z_slice_count;
    } storage;
 
    /* VK_EXT_image_view_min_lod */