Mesa (main): zink: don't ralloc zink_resource structs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 19 02:56:40 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Mon Oct 18 10:52:44 2021 -0400

zink: don't ralloc zink_resource structs

the hash tables can just have their own contexts and be freed explicitly

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13431>

---

 src/gallium/drivers/zink/zink_resource.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 232a66a4deb..d98ecc2924c 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -110,16 +110,18 @@ zink_resource_destroy(struct pipe_screen *pscreen,
       util_idalloc_mt_free(&screen->buffer_ids, res->base.buffer_id_unique);
       assert(!_mesa_hash_table_num_entries(&res->bufferview_cache));
       simple_mtx_destroy(&res->bufferview_mtx);
+      ralloc_free(res->bufferview_cache.table);
    } else {
       assert(!_mesa_hash_table_num_entries(&res->surface_cache));
       simple_mtx_destroy(&res->surface_mtx);
+      ralloc_free(res->surface_cache.table);
    }
    /* no need to do anything for the caches, these objects own the resource lifetimes */
 
    zink_resource_object_reference(screen, &res->obj, NULL);
    zink_resource_object_reference(screen, &res->scanout_obj, NULL);
    threaded_resource_deinit(pres);
-   ralloc_free(res);
+   FREE(res);
 }
 
 static VkImageAspectFlags
@@ -733,14 +735,14 @@ resource_create(struct pipe_screen *pscreen,
                 const uint64_t *modifiers, int modifiers_count)
 {
    struct zink_screen *screen = zink_screen(pscreen);
-   struct zink_resource *res = rzalloc(NULL, struct zink_resource);
+   struct zink_resource *res = CALLOC_STRUCT(zink_resource);
 
    if (modifiers_count > 0) {
       /* for rebinds */
       res->modifiers_count = modifiers_count;
       res->modifiers = mem_dup(modifiers, modifiers_count * sizeof(uint64_t));
       if (!res->modifiers) {
-         ralloc_free(res);
+         FREE(res);
          return NULL;
       }
       /* TODO: remove this when multi-plane modifiers are supported */
@@ -770,7 +772,7 @@ resource_create(struct pipe_screen *pscreen,
    res->obj = resource_object_create(screen, &templ2, whandle, &optimal_tiling, NULL, 0);
    if (!res->obj) {
       free(res->modifiers);
-      ralloc_free(res);
+      FREE(res);
       return NULL;
    }
 
@@ -814,10 +816,10 @@ resource_create(struct pipe_screen *pscreen,
    }
    if (res->obj->is_buffer) {
       res->base.buffer_id_unique = util_idalloc_mt_alloc(&screen->buffer_ids);
-      _mesa_hash_table_init(&res->bufferview_cache, res, NULL, equals_bvci);
+      _mesa_hash_table_init(&res->bufferview_cache, NULL, NULL, equals_bvci);
       simple_mtx_init(&res->bufferview_mtx, mtx_plain);
    } else {
-      _mesa_hash_table_init(&res->surface_cache, res, NULL, equals_ivci);
+      _mesa_hash_table_init(&res->surface_cache, NULL, NULL, equals_ivci);
       simple_mtx_init(&res->surface_mtx, mtx_plain);
    }
    return &res->base.b;



More information about the mesa-commit mailing list