Mesa (master): zink: ralloc spirv_shader

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Dec 16 10:42:32 UTC 2020


Module: Mesa
Branch: master
Commit: 008bf6ca61081fbe9025a6bb1facf3f82b08106e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=008bf6ca61081fbe9025a6bb1facf3f82b08106e

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Thu Dec 10 17:51:39 2020 +0100

zink: ralloc spirv_shader

This uses ralloc for spirv_shader and it's data-payload, which seems a
bit neater than having to remember to free twice. We can now also easily
piggy back on more sophisticated ralloc usage as well.

No need to use rzalloc here, as we'll write all memory in the struct,
and the struct isn't used as a hashmap key, so padding shouldn't matter.

Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8049>

---

 src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 4 ++--
 src/gallium/drivers/zink/zink_compiler.c             | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
index 765ea1cb074..f6ac01d60db 100644
--- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
+++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
@@ -2602,11 +2602,11 @@ nir_to_spirv(struct nir_shader *s, const struct zink_so_info *so_info,
 
    size_t num_words = spirv_builder_get_num_words(&ctx.builder);
 
-   ret = CALLOC_STRUCT(spirv_shader);
+   ret = ralloc(NULL, struct spirv_shader);
    if (!ret)
       goto fail;
 
-   ret->words = MALLOC(sizeof(uint32_t) * num_words);
+   ret->words = ralloc_size(ret, sizeof(uint32_t) * num_words);
    if (!ret->words)
       goto fail;
 
diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c
index 83973c5270f..98df9dfd3fd 100644
--- a/src/gallium/drivers/zink/zink_compiler.c
+++ b/src/gallium/drivers/zink/zink_compiler.c
@@ -269,8 +269,7 @@ zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, struct z
       ralloc_free(nir);
 
    /* TODO: determine if there's any reason to cache spirv output? */
-   free(spirv->words);
-   free(spirv);
+   ralloc_free(spirv);
    return mod;
 }
 



More information about the mesa-commit mailing list