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

Author: Lionel Landwerlin <[email protected]>
Date:   Thu Jan 26 11:54:42 2023 +0200

vulkan/runtime: store parameters of VK_EXT_sliced_view_of_3d

Signed-off-by: Lionel Landwerlin <[email protected]>
Reviewed-by: Mike Blumenkrantz <[email protected]>
Reviewed-by: Faith Ekstrand <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21514>

---

 src/vulkan/runtime/vk_image.c | 20 ++++++++++++++++++++
 src/vulkan/runtime/vk_image.h |  5 +++++
 2 files changed, 25 insertions(+)

diff --git a/src/vulkan/runtime/vk_image.c b/src/vulkan/runtime/vk_image.c
index d1cee3730e0..10573406c54 100644
--- a/src/vulkan/runtime/vk_image.c
+++ b/src/vulkan/runtime/vk_image.c
@@ -453,6 +453,14 @@ vk_image_view_init(struct vk_device *device,
    image_view->extent =
       vk_image_mip_level_extent(image, image_view->base_mip_level);
 
+   /* 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;
+
+   const VkImageViewSlicedCreateInfoEXT *sliced_info =
+      vk_find_struct_const(pCreateInfo, IMAGE_VIEW_SLICED_CREATE_INFO_EXT);
    assert(image_view->base_mip_level + image_view->level_count
           <= image->mip_levels);
    switch (image->image_type) {
@@ -464,6 +472,18 @@ vk_image_view_init(struct vk_device *device,
              <= image->array_layers);
       break;
    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);
+         if (sliced_info->sliceCount == VK_REMAINING_3D_SLICES_EXT) {
+            image_view->storage.slice_count = total - 
image_view->storage.slice_offset;
+         } else {
+            image_view->storage.slice_count = sliced_info->sliceCount;
+         }
+         assert(image_view->storage.slice_offset + 
image_view->storage.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 6557a45b337..c2b0a3aa062 100644
--- a/src/vulkan/runtime/vk_image.h
+++ b/src/vulkan/runtime/vk_image.h
@@ -279,6 +279,11 @@ struct vk_image_view {
    uint32_t base_array_layer;
    uint32_t layer_count;
 
+   struct {
+      uint32_t slice_offset;
+      uint32_t slice_count;
+   } storage;
+
    /* VK_EXT_image_view_min_lod */
    float min_lod;
 

Reply via email to