aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2020-07-17 18:52:13 +0200
committerMarge Bot <[email protected]>2020-07-17 17:33:34 +0000
commit12b324b30c572729e158b70a1cbe0d53f4563829 (patch)
tree00ef4a92cefbf0e006fc5eeb918fa8f3e63675d4 /src/gallium
parent56d9bcdded8f3eb7bd45262ce013ef1809d8edb1 (diff)
zink: use ralloc in nir-to-spirv
Reviewed-By: Mike Blumenkrantz <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5954>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c16
1 files changed, 8 insertions, 8 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 6c4c91b0927..44eade4e25a 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
@@ -90,6 +90,8 @@ static unsigned slot_pack_map[] = {
#define NTV_MIN_RESERVED_SLOTS 11
struct ntv_context {
+ void *mem_ctx;
+
struct spirv_builder builder;
SpvId GLSL_std_450;
@@ -2168,6 +2170,7 @@ nir_to_spirv(struct nir_shader *s, const struct pipe_stream_output_info *so_info
struct spirv_shader *ret = NULL;
struct ntv_context ctx = {};
+ ctx.mem_ctx = ralloc_context(NULL);
switch (s->info.stage) {
case MESA_SHADER_VERTEX:
@@ -2233,10 +2236,10 @@ nir_to_spirv(struct nir_shader *s, const struct pipe_stream_output_info *so_info
SpvId entry_point = spirv_builder_new_id(&ctx.builder);
spirv_builder_emit_name(&ctx.builder, entry_point, "main");
- ctx.vars = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
+ ctx.vars = _mesa_hash_table_create(ctx.mem_ctx, _mesa_hash_pointer,
_mesa_key_pointer_equal);
- ctx.so_outputs = _mesa_hash_table_create(NULL, _mesa_hash_u32,
+ ctx.so_outputs = _mesa_hash_table_create(ctx.mem_ctx, _mesa_hash_u32,
_mesa_key_u32_equal);
nir_foreach_variable(var, &s->inputs)
@@ -2332,19 +2335,16 @@ nir_to_spirv(struct nir_shader *s, const struct pipe_stream_output_info *so_info
ret->num_words = spirv_builder_get_words(&ctx.builder, ret->words, num_words);
assert(ret->num_words == num_words);
+ ralloc_free(ctx.mem_ctx);
+
return ret;
fail:
+ ralloc_free(ctx.mem_ctx);
if (ret)
spirv_shader_delete(ret);
- if (ctx.vars)
- _mesa_hash_table_destroy(ctx.vars, NULL);
-
- if (ctx.so_outputs)
- _mesa_hash_table_destroy(ctx.so_outputs, NULL);
-
return NULL;
}