From 96ffc24e4ef7efc10734990023dc499c5bfe9b87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 1 Aug 2025 18:43:32 -0400 Subject: [PATCH] nir: add nir_variable_{set,append,steal}_name{f}() to modify nir_variable names Setting variable names currently always uses ralloc, but the new nir_variable_* helpers will mostly eliminate ralloc/malloc in a later commit. This just updates all places that touch nir_variable names to use the new helpers. Reviewed-by: Timothy Arceri Part-of: --- .../gl_nir_lower_blend_equation_advanced.c | 2 +- src/compiler/glsl/gl_nir_lower_discard_flow.c | 2 +- .../gl_nir_lower_named_interface_blocks.c | 2 +- .../glsl/gl_nir_lower_packed_varyings.c | 4 +- src/compiler/glsl/glsl_to_nir.cpp | 2 +- src/compiler/nir/nir.c | 42 ++++++++++++++++++- src/compiler/nir/nir.h | 5 +++ src/compiler/nir/nir_clone.c | 2 +- src/compiler/nir/nir_lower_clip.c | 2 +- .../nir_lower_clip_cull_distance_array_vars.c | 2 +- .../nir/nir_lower_const_arrays_to_uniforms.c | 4 +- src/compiler/nir/nir_lower_fragcolor.c | 3 +- .../nir/nir_lower_io_vars_to_temporaries.c | 4 +- src/compiler/nir/nir_passthrough_gs.c | 6 +-- src/compiler/nir/nir_serialize.c | 2 +- src/compiler/spirv/vtn_variables.c | 8 ++-- src/freedreno/ir3/ir3_nir_lower_tess.c | 4 +- src/gallium/auxiliary/nir/tgsi_to_nir.c | 6 +-- src/gallium/drivers/zink/zink_compiler.c | 12 +++--- src/intel/compiler/brw_compile_mesh.cpp | 3 +- src/microsoft/compiler/nir_to_dxil.c | 4 +- 21 files changed, 79 insertions(+), 42 deletions(-) diff --git a/src/compiler/glsl/gl_nir_lower_blend_equation_advanced.c b/src/compiler/glsl/gl_nir_lower_blend_equation_advanced.c index ecacc91b532..68d2e9341ec 100644 --- a/src/compiler/glsl/gl_nir_lower_blend_equation_advanced.c +++ b/src/compiler/glsl/gl_nir_lower_blend_equation_advanced.c @@ -218,7 +218,7 @@ add_temp_var(nir_builder *b, char *name, const struct glsl_type *type) { nir_variable *var = rzalloc(b->shader, nir_variable); var->type = type; - var->name = ralloc_strdup(var, name); + nir_variable_set_name(var, name); var->data.mode = nir_var_function_temp; nir_function_impl_add_variable(b->impl, var); diff --git a/src/compiler/glsl/gl_nir_lower_discard_flow.c b/src/compiler/glsl/gl_nir_lower_discard_flow.c index ef88c326946..2ec4a34ef05 100644 --- a/src/compiler/glsl/gl_nir_lower_discard_flow.c +++ b/src/compiler/glsl/gl_nir_lower_discard_flow.c @@ -136,7 +136,7 @@ gl_nir_lower_discard_flow(nir_shader *shader) nir_function_impl *main = nir_shader_get_entrypoint(shader); nir_variable *discarded = rzalloc(shader, nir_variable); - discarded->name = ralloc_strdup(discarded, "discarded"); + nir_variable_set_name(discarded, "discarded"); discarded->type = glsl_bool_type(); discarded->data.mode = nir_var_shader_temp; diff --git a/src/compiler/glsl/gl_nir_lower_named_interface_blocks.c b/src/compiler/glsl/gl_nir_lower_named_interface_blocks.c index 79c419a3978..e4b7178936e 100644 --- a/src/compiler/glsl/gl_nir_lower_named_interface_blocks.c +++ b/src/compiler/glsl/gl_nir_lower_named_interface_blocks.c @@ -270,7 +270,7 @@ lower_named_interface_blocks(struct gl_linked_shader *sh) glsl_get_struct_field_data(iface_t, i); nir_variable *new_var = rzalloc(sh->Program->nir, nir_variable); - new_var->name = ralloc_strdup(new_var, field_name); + nir_variable_set_name(new_var, field_name); if (!glsl_type_is_array(var->type)) { new_var->type = glsl_get_struct_field(iface_t, i); } else { diff --git a/src/compiler/glsl/gl_nir_lower_packed_varyings.c b/src/compiler/glsl/gl_nir_lower_packed_varyings.c index 928e92e10d1..c29bc815bc6 100644 --- a/src/compiler/glsl/gl_nir_lower_packed_varyings.c +++ b/src/compiler/glsl/gl_nir_lower_packed_varyings.c @@ -271,7 +271,7 @@ create_or_update_packed_varying(struct lower_packed_varyings_state *state, assert(name); nir_variable *packed_var = rzalloc(state->shader, nir_variable); - packed_var->name = ralloc_asprintf(packed_var, "packed:%s", name); + nir_variable_set_namef(packed_var, "packed:%s", name); packed_var->data.mode = state->mode; bool is_interpolation_flat = @@ -316,7 +316,7 @@ create_or_update_packed_varying(struct lower_packed_varyings_state *state, */ if (state->gs_input_vertices == 0 || vertex_index == 0) { assert(name); - ralloc_asprintf_append((char **) &var->name, ",%s", name); + nir_variable_append_namef(var, ",%s", name); } } } diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index cd2b51109fa..560544fc105 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -447,7 +447,7 @@ nir_visitor::visit(ir_variable *ir) nir_variable *var = rzalloc(shader, nir_variable); var->type = ir->type; - var->name = ralloc_strdup(var, ir->name); + nir_variable_set_name(var, ir->name); var->data.assigned = ir->data.assigned; var->data.read_only = ir->data.read_only; diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 9c71d8c5473..ebf56534364 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -267,12 +267,50 @@ nir_shader_add_variable(nir_shader *shader, nir_variable *var) exec_list_push_tail(&shader->variables, &var->node); } +void +nir_variable_set_name(nir_variable *var, const char *name) +{ + if (var->name) + ralloc_free(var->name); + + var->name = ralloc_strdup(var, name); +} + +void +nir_variable_set_namef(nir_variable *var, const char *fmt, ...) +{ + if (var->name) + ralloc_free(var->name); + + va_list args; + va_start(args, fmt); + var->name = ralloc_vasprintf(var, fmt, args); + va_end(args); +} + +void +nir_variable_append_namef(nir_variable *var, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + ralloc_vasprintf_append(&var->name, fmt, args); + va_end(args); +} + +void +nir_variable_steal_name(nir_variable *dst, nir_variable *src) +{ + ralloc_steal(dst, src->name); + dst->name = src->name; + src->name = NULL; +} + nir_variable * nir_variable_create(nir_shader *shader, nir_variable_mode mode, const struct glsl_type *type, const char *name) { nir_variable *var = rzalloc(shader, nir_variable); - var->name = ralloc_strdup(var, name); + nir_variable_set_name(var, name); var->type = type; var->data.mode = mode; var->data.how_declared = nir_var_declared_normally; @@ -297,7 +335,7 @@ nir_local_variable_create(nir_function_impl *impl, const struct glsl_type *type, const char *name) { nir_variable *var = rzalloc(impl->function->shader, nir_variable); - var->name = ralloc_strdup(var, name); + nir_variable_set_name(var, name); var->type = type; var->data.mode = nir_var_function_temp; diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 53dc11fc424..04265d6610f 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3942,6 +3942,11 @@ nir_function_impl_add_variable(nir_function_impl *impl, nir_variable *var) exec_list_push_tail(&impl->locals, &var->node); } +void nir_variable_set_name(nir_variable *var, const char *name); +void nir_variable_set_namef(nir_variable *var, const char *fmt, ...) PRINTFLIKE(2, 3); +void nir_variable_append_namef(nir_variable *var, const char *fmt, ...) PRINTFLIKE(2, 3); +void nir_variable_steal_name(nir_variable *dst, nir_variable *src); + /** creates a variable, sets a few defaults, and adds it to the list */ nir_variable *nir_variable_create(nir_shader *shader, nir_variable_mode mode, diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c index 6cf2d041754..39206b3b6f5 100644 --- a/src/compiler/nir/nir_clone.c +++ b/src/compiler/nir/nir_clone.c @@ -154,7 +154,7 @@ nir_variable_clone(const nir_variable *var, nir_shader *shader) nir_variable *nvar = rzalloc(shader, nir_variable); nvar->type = var->type; - nvar->name = ralloc_strdup(nvar, var->name); + nir_variable_set_name(nvar, var->name); nvar->data = var->data; nvar->num_state_slots = var->num_state_slots; if (var->num_state_slots) { diff --git a/src/compiler/nir/nir_lower_clip.c b/src/compiler/nir/nir_lower_clip.c index 4d67ed52bb6..263283b2d9e 100644 --- a/src/compiler/nir/nir_lower_clip.c +++ b/src/compiler/nir/nir_lower_clip.c @@ -54,7 +54,7 @@ create_clipdist_var(nir_shader *shader, var->data.mode = nir_var_shader_in; shader->num_inputs += MAX2(1, DIV_ROUND_UP(array_size, 4)); } - var->name = ralloc_asprintf(var, "clipdist_%d", slot - VARYING_SLOT_CLIP_DIST0); + nir_variable_set_namef(var, "clipdist_%d", slot - VARYING_SLOT_CLIP_DIST0); var->data.index = 0; var->data.location = slot; diff --git a/src/compiler/nir/nir_lower_clip_cull_distance_array_vars.c b/src/compiler/nir/nir_lower_clip_cull_distance_array_vars.c index 80d0b2bb491..b12298cfcc0 100644 --- a/src/compiler/nir/nir_lower_clip_cull_distance_array_vars.c +++ b/src/compiler/nir/nir_lower_clip_cull_distance_array_vars.c @@ -147,7 +147,7 @@ replace_var_declaration(struct lower_distance_state *state, nir_shader *sh, unsigned new_size = (state->total_size + 3) / 4; *new_var = rzalloc(sh, nir_variable); - (*new_var)->name = ralloc_strdup(*new_var, GLSL_CLIP_VAR_NAME); + nir_variable_set_name(*new_var, GLSL_CLIP_VAR_NAME); (*new_var)->data.mode = var->data.mode; (*new_var)->data.location = VARYING_SLOT_CLIP_DIST0; (*new_var)->data.assigned = true; diff --git a/src/compiler/nir/nir_lower_const_arrays_to_uniforms.c b/src/compiler/nir/nir_lower_const_arrays_to_uniforms.c index 455c0892d65..b0cb2db483f 100644 --- a/src/compiler/nir/nir_lower_const_arrays_to_uniforms.c +++ b/src/compiler/nir/nir_lower_const_arrays_to_uniforms.c @@ -207,8 +207,8 @@ lower_const_array_to_uniform(nir_shader *shader, struct var_info *info, uni->data.read_only = true; uni->data.mode = nir_var_uniform; uni->type = info->var->type; - uni->name = ralloc_asprintf(uni, "constarray_%x_%u", - *const_count, shader->info.stage); + nir_variable_set_namef(uni,"constarray_%x_%u", + *const_count, shader->info.stage); nir_shader_add_variable(shader, uni); diff --git a/src/compiler/nir/nir_lower_fragcolor.c b/src/compiler/nir/nir_lower_fragcolor.c index 37fcae65a12..682efe05525 100644 --- a/src/compiler/nir/nir_lower_fragcolor.c +++ b/src/compiler/nir/nir_lower_fragcolor.c @@ -62,12 +62,11 @@ lower_fragcolor_intrin(nir_builder *b, nir_intrinsic_instr *instr, void *data) b->cursor = nir_after_instr(&instr->instr); nir_def *frag_color = instr->src[1].ssa; - ralloc_free(out->name); const char *name = out->data.index == 0 ? "gl_FragData[0]" : "gl_SecondaryFragDataEXT[0]"; const char *name_tmpl = out->data.index == 0 ? "gl_FragData[%u]" : "gl_SecondaryFragDataEXT[%u]"; - out->name = ralloc_strdup(out, name); + nir_variable_set_name(out, name); /* translate gl_FragColor -> gl_FragData since this is already handled */ out->data.location = FRAG_RESULT_DATA0; diff --git a/src/compiler/nir/nir_lower_io_vars_to_temporaries.c b/src/compiler/nir/nir_lower_io_vars_to_temporaries.c index 9e5bcd3cf2c..87e419f2f9e 100644 --- a/src/compiler/nir/nir_lower_io_vars_to_temporaries.c +++ b/src/compiler/nir/nir_lower_io_vars_to_temporaries.c @@ -305,13 +305,13 @@ create_shadow_temp(struct lower_io_state *state, nir_variable *var) nir_variable *temp = var; /* Reparent the name to the new variable */ - ralloc_steal(nvar, nvar->name); + nir_variable_steal_name(nvar, var); assert(nvar->constant_initializer == NULL && nvar->pointer_initializer == NULL); /* Give the original a new name with @-temp appended */ const char *mode = (temp->data.mode == nir_var_shader_in) ? "in" : "out"; - temp->name = ralloc_asprintf(var, "%s@%s-temp", mode, nvar->name); + nir_variable_set_namef(temp, "%s@%s-temp", mode, nvar->name); temp->data.mode = nir_var_shader_temp; temp->data.read_only = false; temp->data.fb_fetch_output = false; diff --git a/src/compiler/nir/nir_passthrough_gs.c b/src/compiler/nir/nir_passthrough_gs.c index 94c32759cc3..e38d176a195 100644 --- a/src/compiler/nir/nir_passthrough_gs.c +++ b/src/compiler/nir/nir_passthrough_gs.c @@ -174,8 +174,7 @@ nir_create_passthrough_gs(const nir_shader_compiler_options *options, snprintf(name, sizeof(name), "in_%d", var->data.driver_location); nir_variable *in = nir_variable_clone(var, nir); - ralloc_free(in->name); - in->name = ralloc_strdup(in, name); + nir_variable_set_name(in, name); in->type = glsl_array_type(var->type, 6, false); in->data.mode = nir_var_shader_in; nir_shader_add_variable(nir, in); @@ -195,8 +194,7 @@ nir_create_passthrough_gs(const nir_shader_compiler_options *options, snprintf(name, sizeof(name), "out_%d", var->data.driver_location); nir_variable *out = nir_variable_clone(var, nir); - ralloc_free(out->name); - out->name = ralloc_strdup(out, name); + nir_variable_set_name(out, name); out->data.mode = nir_var_shader_out; nir_shader_add_variable(nir, out); diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c index a9f2946e38f..4aefa97bab4 100644 --- a/src/compiler/nir/nir_serialize.c +++ b/src/compiler/nir/nir_serialize.c @@ -366,7 +366,7 @@ read_variable(read_ctx *ctx) if (flags.u.has_name) { const char *name = blob_read_string(ctx->blob); - var->name = ralloc_strdup(var, name); + nir_variable_set_name(var, name); } else { var->name = NULL; } diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index f09dc0b8c92..9b613f24391 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -2183,7 +2183,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, case vtn_variable_mode_node_payload: /* For these, we create the variable normally */ var->var = rzalloc(b->shader, nir_variable); - var->var->name = ralloc_strdup(var->var, val->name); + nir_variable_set_name(var->var, val->name); var->var->type = vtn_type_get_nir_type(b, var->type, var->mode); /* This is a total hack but we need some way to flag variables which are @@ -2205,7 +2205,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, case vtn_variable_mode_accel_struct: case vtn_variable_mode_shader_record: var->var = rzalloc(b->shader, nir_variable); - var->var->name = ralloc_strdup(var->var, val->name); + nir_variable_set_name(var->var, val->name); var->var->type = vtn_type_get_nir_type(b, var->type, var->mode); var->var->interface_type = var->var->type; @@ -2221,7 +2221,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, case vtn_variable_mode_task_payload: /* Create the variable normally */ var->var = rzalloc(b->shader, nir_variable); - var->var->name = ralloc_strdup(var->var, val->name); + nir_variable_set_name(var->var, val->name); var->var->type = vtn_type_get_nir_type(b, var->type, var->mode); var->var->data.mode = nir_mode; if (var->mode == vtn_variable_mode_workgroup && @@ -2232,7 +2232,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, case vtn_variable_mode_input: case vtn_variable_mode_output: { var->var = rzalloc(b->shader, nir_variable); - var->var->name = ralloc_strdup(var->var, val->name); + nir_variable_set_name(var->var, val->name); var->var->type = vtn_type_get_nir_type(b, var->type, var->mode); var->var->data.mode = nir_mode; diff --git a/src/freedreno/ir3/ir3_nir_lower_tess.c b/src/freedreno/ir3/ir3_nir_lower_tess.c index 63ca5fa3793..ab7765017d4 100644 --- a/src/freedreno/ir3/ir3_nir_lower_tess.c +++ b/src/freedreno/ir3/ir3_nir_lower_tess.c @@ -1030,14 +1030,14 @@ ir3_nir_lower_gs(nir_shader *shader) exec_list_push_tail(&state.new_outputs, &output->node); /* Rewrite the original output to be a shadow variable. */ - var->name = ralloc_asprintf(var, "%s@gs-temp", output->name); + nir_variable_set_namef(var, "%s@gs-temp", output->name); var->data.mode = nir_var_shader_temp; /* Clone the shadow variable to create the emit shadow variable that * we'll assign in the emit conditionals. */ nir_variable *emit_output = nir_variable_clone(var, shader); - emit_output->name = ralloc_asprintf(var, "%s@emit-temp", output->name); + nir_variable_set_namef(emit_output, "%s@emit-temp", output->name); exec_list_push_tail(&state.emit_outputs, &emit_output->node); } diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c index ef05b784e7b..08cc06e336e 100644 --- a/src/gallium/auxiliary/nir/tgsi_to_nir.c +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c @@ -301,7 +301,7 @@ ttn_emit_declaration(struct ttn_compile *c) case TGSI_FILE_INPUT: var->data.read_only = true; var->data.mode = nir_var_shader_in; - var->name = ralloc_asprintf(var, "in_%d", idx); + nir_variable_set_namef(var, "in_%d", idx); if (c->scan->processor == PIPE_SHADER_FRAGMENT) { if (decl->Semantic.Name == TGSI_SEMANTIC_FACE) { @@ -359,7 +359,7 @@ ttn_emit_declaration(struct ttn_compile *c) is_array ? array_size : 0); var->data.mode = nir_var_shader_out; - var->name = ralloc_asprintf(var, "out_%d", idx); + nir_variable_set_namef(var, "out_%d", idx); var->data.index = 0; var->data.interpolation = ttn_translate_interp_mode(decl->Interp.Interpolate); @@ -446,7 +446,7 @@ ttn_emit_declaration(struct ttn_compile *c) break; case TGSI_FILE_CONSTANT: var->data.mode = nir_var_uniform; - var->name = ralloc_asprintf(var, "uniform_%d", idx); + nir_variable_set_namef(var, "uniform_%d", idx); var->data.location = idx; break; default: diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index cd9b2a2d58e..5e8c8e371ce 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -1111,8 +1111,7 @@ zink_create_quads_emulation_gs(const nir_shader_compiler_options *options, snprintf(name, sizeof(name), "in_%d", var->data.driver_location); nir_variable *in = nir_variable_clone(var, nir); - ralloc_free(in->name); - in->name = ralloc_strdup(in, name); + nir_variable_set_name(in, name); in->type = glsl_array_type(var->type, 4, false); in->data.mode = nir_var_shader_in; nir_shader_add_variable(nir, in); @@ -1123,8 +1122,7 @@ zink_create_quads_emulation_gs(const nir_shader_compiler_options *options, snprintf(name, sizeof(name), "out_%d", var->data.driver_location); nir_variable *out = nir_variable_clone(var, nir); - ralloc_free(out->name); - out->name = ralloc_strdup(out, name); + nir_variable_set_name(out, name); out->data.mode = nir_var_shader_out; nir_shader_add_variable(nir, out); @@ -2063,7 +2061,7 @@ decompose_attribs(nir_shader *nir, uint32_t decomposed_attrs, uint32_t decompose state.needs_w = (decomposed_attrs_without_w & BITFIELD_BIT(location)) != 0 && num_components == 4; for (unsigned i = 0; i < (state.needs_w ? num_components - 1 : num_components); i++) { split[i+1] = nir_variable_clone(var, nir); - split[i+1]->name = ralloc_asprintf(nir, "%s_split%u", var->name, i); + nir_variable_set_namef(split[i+1], "%s_split%u", var->name, i); if (decomposed_attrs_without_w & BITFIELD_BIT(location)) split[i+1]->type = !i && num_components == 4 ? var->type : new_type; else @@ -2222,9 +2220,9 @@ get_bo_var(nir_shader *shader, struct bo_vars *bo, bool ssbo, nir_src *src, unsi } var = nir_variable_clone(var, shader); if (ssbo) - var->name = ralloc_asprintf(shader, "%s@%u", "ssbos", bit_size); + nir_variable_set_namef(var, "%s@%u", "ssbos", bit_size); else - var->name = ralloc_asprintf(shader, "%s@%u", idx ? "ubos" : "uniform_0", bit_size); + nir_variable_set_namef(var, "%s@%u", idx ? "ubos" : "uniform_0", bit_size); *ptr = var; nir_shader_add_variable(shader, var); diff --git a/src/intel/compiler/brw_compile_mesh.cpp b/src/intel/compiler/brw_compile_mesh.cpp index 4ea3a44ffc7..babaf270a4d 100644 --- a/src/intel/compiler/brw_compile_mesh.cpp +++ b/src/intel/compiler/brw_compile_mesh.cpp @@ -269,8 +269,7 @@ brw_nir_lower_mesh_primitive_count(nir_shader *nir) nir_create_variable_with_location(nir, nir_var_shader_out, VARYING_SLOT_PRIMITIVE_COUNT, glsl_uint_type()); - final_primitive_count->name = ralloc_strdup(final_primitive_count, - "gl_PrimitiveCountNV"); + nir_variable_set_name(final_primitive_count, "gl_PrimitiveCountNV"); final_primitive_count->data.interpolation = INTERP_MODE_NONE; nir_store_var(b, final_primitive_count, diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c index 801744cd483..5cd5d30b832 100644 --- a/src/microsoft/compiler/nir_to_dxil.c +++ b/src/microsoft/compiler/nir_to_dxil.c @@ -1494,7 +1494,7 @@ emit_global_consts(struct ntd_context *ctx) nir_foreach_variable_with_modes(var, ctx->shader, nir_var_mem_constant) { if (!var->name) - var->name = ralloc_asprintf(var, "const_%d", var->data.driver_location); + nir_variable_set_namef(var, "const_%d", var->data.driver_location); const struct dxil_value *agg_vals = get_value_for_const_aggregate(&ctx->mod, var->constant_initializer, var->type); @@ -1525,7 +1525,7 @@ emit_shared_vars(struct ntd_context *ctx) nir_foreach_variable_with_modes(var, ctx->shader, nir_var_mem_shared) { if (!var->name) - var->name = ralloc_asprintf(var, "shared_%d", var->data.driver_location); + nir_variable_set_namef(var, "shared_%d", var->data.driver_location); const struct dxil_value *gvar = dxil_add_global_ptr_var(&ctx->mod, var->name, get_type_for_glsl_type(&ctx->mod, var->type), DXIL_AS_GROUPSHARED, 16,