Mesa (staging/22.1): iris: Don't leak surface states for compressed resources

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 28 17:16:53 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: c2760516821fe4761a7d9a98e8dbd4c5b1f3341e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c2760516821fe4761a7d9a98e8dbd4c5b1f3341e

Author: Nanley Chery <nanley.g.chery at intel.com>
Date:   Fri Jul 15 11:51:55 2022 -0400

iris: Don't leak surface states for compressed resources

Before this patch, we were leaking surface states in iris_create_surface.
Specifically, when we failed to create an uncompressed ISL surface and view for
a compressed resource, we didn't free surface states we allocated for it.

Fix this by attempting to create the uncompressed surface and view before we
allocate the surface states.

Cc: 22.1 <mesa-stable>
Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17598>
(cherry picked from commit bca601ffe92be0933bb706e4ad320676a0da8477)

---

 .pick_status.json                     |  2 +-
 src/gallium/drivers/iris/iris_state.c | 50 ++++++++++++++++++-----------------
 2 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index dda123585e8..5db006b6d41 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2038,7 +2038,7 @@
         "description": "iris: Don't leak surface states for compressed resources",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index 22001db446c..5c769ddfef6 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -2710,6 +2710,32 @@ iris_create_surface(struct pipe_context *ctx,
    }
 #endif
 
+   struct isl_surf isl_surf;
+   uint64_t offset_B = 0;
+   uint32_t tile_x_el = 0, tile_y_el = 0;
+   if (isl_format_is_compressed(res->surf.format)) {
+      /* The resource has a compressed format, which is not renderable, but we
+       * have a renderable view format.  We must be attempting to upload
+       * blocks of compressed data via an uncompressed view.
+       *
+       * In this case, we can assume there are no auxiliary buffers, a single
+       * miplevel, and that the resource is single-sampled.  Gallium may try
+       * and create an uncompressed view with multiple layers, however.
+       */
+      assert(res->aux.usage == ISL_AUX_USAGE_NONE);
+      assert(res->surf.samples == 1);
+      assert(view->levels == 1);
+
+      bool ok = isl_surf_get_uncompressed_surf(&screen->isl_dev,
+                                               &res->surf, view,
+                                               &isl_surf, view, &offset_B,
+                                               &tile_x_el, &tile_y_el);
+      if (!ok) {
+         free(surf);
+         return NULL;
+      }
+   }
+
    surf->clear_color = res->aux.clear_color;
 
    /* Bail early for depth/stencil - we don't want SURFACE_STATE for them. */
@@ -2750,30 +2776,6 @@ iris_create_surface(struct pipe_context *ctx,
       return psurf;
    }
 
-   /* The resource has a compressed format, which is not renderable, but we
-    * have a renderable view format.  We must be attempting to upload blocks
-    * of compressed data via an uncompressed view.
-    *
-    * In this case, we can assume there are no auxiliary buffers, a single
-    * miplevel, and that the resource is single-sampled.  Gallium may try
-    * and create an uncompressed view with multiple layers, however.
-    */
-   assert(!isl_format_is_compressed(fmt.fmt));
-   assert(res->aux.usage == ISL_AUX_USAGE_NONE);
-   assert(res->surf.samples == 1);
-   assert(view->levels == 1);
-
-   struct isl_surf isl_surf;
-   uint64_t offset_B = 0;
-   uint32_t tile_x_el = 0, tile_y_el = 0;
-   bool ok = isl_surf_get_uncompressed_surf(&screen->isl_dev, &res->surf,
-                                            view, &isl_surf, view,
-                                            &offset_B, &tile_x_el, &tile_y_el);
-   if (!ok) {
-      free(surf);
-      return NULL;
-   }
-
    psurf->width = isl_surf.logical_level0_px.width;
    psurf->height = isl_surf.logical_level0_px.height;
 



More information about the mesa-commit mailing list