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

Author: Lionel Landwerlin <[email protected]>
Date:   Fri Feb 17 10:03:38 2023 +0200

anv: VK_EXT_image_sliced_view_of_3d

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

---

 src/intel/vulkan/anv_device.c  |  8 ++++++++
 src/intel/vulkan/anv_image.c   | 11 +++++++++--
 src/intel/vulkan/anv_private.h |  6 ++++++
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index f1b6b7de95f..74b46aae4e3 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -307,6 +307,7 @@ get_device_extensions(const struct anv_physical_device 
*device,
       .EXT_image_2d_view_of_3d               = true,
       .EXT_image_robustness                  = true,
       .EXT_image_drm_format_modifier         = true,
+      .EXT_image_sliced_view_of_3d           = true,
       .EXT_image_view_min_lod                = true,
       .EXT_index_type_uint8                  = true,
       .EXT_inline_uniform_block              = true,
@@ -1410,6 +1411,13 @@ void anv_GetPhysicalDeviceFeatures2(
          break;
       }
 
+      case 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_SLICED_VIEW_OF_3D_FEATURES_EXT: {
+         VkPhysicalDeviceImageSlicedViewOf3DFeaturesEXT *features =
+            (VkPhysicalDeviceImageSlicedViewOf3DFeaturesEXT *)ext;
+         features->imageSlicedViewOf3D = true;
+         break;
+      }
+
       case 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_NV: {
          VkPhysicalDeviceComputeShaderDerivativesFeaturesNV *features =
             (VkPhysicalDeviceComputeShaderDerivativesFeaturesNV *)ext;
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index f84e53f558b..6ea5088b084 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -2663,14 +2663,21 @@ anv_CreateImageView(VkDevice _device,
 
       /* NOTE: This one needs to go last since it may stomp isl_view.format */
       if (iview->vk.usage & VK_IMAGE_USAGE_STORAGE_BIT) {
+         struct isl_view storage_view = iview->planes[vplane].isl;
+         if (iview->vk.view_type == VK_IMAGE_VIEW_TYPE_3D) {
+            storage_view.base_array_layer = iview->vk.storage.z_slice_offset;
+            storage_view.array_len = iview->vk.storage.z_slice_count;
+         }
+
          enum isl_aux_usage general_aux_usage =
             anv_layout_to_aux_usage(device->info, image, 1UL << iaspect_bit,
                                     VK_IMAGE_USAGE_STORAGE_BIT,
                                     VK_IMAGE_LAYOUT_GENERAL);
          iview->planes[vplane].storage_surface_state.state =
             alloc_bindless_surface_state(device);
+
          anv_image_fill_surface_state(device, image, 1ULL << iaspect_bit,
-                                      &iview->planes[vplane].isl,
+                                      &storage_view,
                                       ISL_SURF_USAGE_STORAGE_BIT,
                                       general_aux_usage, NULL,
                                       0,
@@ -2680,7 +2687,7 @@ anv_CreateImageView(VkDevice _device,
             alloc_bindless_surface_state(device);
          if (isl_is_storage_image_format(format.isl_format)) {
             anv_image_fill_surface_state(device, image, 1ULL << iaspect_bit,
-                                         &iview->planes[vplane].isl,
+                                         &storage_view,
                                          ISL_SURF_USAGE_STORAGE_BIT,
                                          general_aux_usage, NULL,
                                          ANV_IMAGE_VIEW_STATE_STORAGE_LOWERED,
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index a22a376ebd5..970dfbd05ca 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -3922,6 +3922,12 @@ struct anv_image_view {
 
       struct isl_view isl;
 
+      /**
+       * A version of the image view for storage usage (can apply 3D image
+       * slicing).
+       */
+      struct isl_view isl_storage;
+
       /**
        * RENDER_SURFACE_STATE when using image as a sampler surface with an
        * image layout of SHADER_READ_ONLY_OPTIMAL or

Reply via email to