isl: Set Depth to array len for 3D storage images
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Tue, 28 Feb 2023 17:16:06 +0000 (11:16 -0600)
committerMarge Bot <emma+marge@anholt.net>
Sat, 4 Mar 2023 06:12:46 +0000 (06:12 +0000)
This is necessary for RESINFO to work properly.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21376>

src/intel/isl/isl_surface_state.c

index 455e2f3..4de6492 100644 (file)
@@ -329,12 +329,32 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
          s.RenderTargetViewExtent = s.Depth;
       break;
    case SURFTYPE_3D:
+      assert(info->view->base_array_layer + info->view->array_len <=
+             isl_minify(info->surf->logical_level0_px.depth,
+                        info->view->base_level));
+
       /* From the Broadwell PRM >> RENDER_SURFACE_STATE::Depth:
        *
        *    If the volume texture is MIP-mapped, this field specifies the
        *    depth of the base MIP level.
        */
-      s.Depth = info->surf->logical_level0_px.depth - 1;
+      if (GFX_VER >= 9 && info->view->usage & ISL_SURF_USAGE_STORAGE_BIT) {
+         /* From the Kaby Lake docs for the RESINFO message:
+          *
+          *    "Surface Type | ... | Blue
+          *    --------------+-----+----------------
+          *     SURFTYPE_3D  | ... | (Depth+1)»LOD"
+          *
+          * which isn't actually what the Vulkan or D3D specs want for storage
+          * images.  We want the requested array size.  The good news is that,
+          * thanks to Skylake and later using the same image layout for 3D
+          * images as 2D array images, we should be able to adjust the depth
+          * without affecting the layout.
+          */
+         s.Depth = (info->view->array_len << info->view->base_level) - 1;
+      } else {
+         s.Depth = info->surf->logical_level0_px.depth - 1;
+      }
 
       /* From the Broadwell PRM >> RENDER_SURFACE_STATE::RenderTargetViewExtent:
        *