From 008bf6ca61081fbe9025a6bb1facf3f82b08106e Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 10 Dec 2020 17:51:39 +0100 Subject: [PATCH] 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 Part-of: --- 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; }