diff --git a/src/microsoft/clc/clc_compiler.c b/src/microsoft/clc/clc_compiler.c index 165bf15907b..f29f6cdbc54 100644 --- a/src/microsoft/clc/clc_compiler.c +++ b/src/microsoft/clc/clc_compiler.c @@ -478,8 +478,11 @@ clc_lower_constant_to_ssbo(nir_shader *nir, } static void -clc_lower_global_to_ssbo(nir_shader *nir) +clc_change_variable_mode(nir_shader *nir, nir_variable_mode from, nir_variable_mode to) { + nir_foreach_variable_with_modes(var, nir, from) + var->data.mode = to; + nir_foreach_function(func, nir) { if (!func->is_entrypoint) continue; @@ -493,10 +496,10 @@ clc_lower_global_to_ssbo(nir_shader *nir) nir_deref_instr *deref = nir_instr_as_deref(instr); - if (deref->modes != nir_var_mem_global) + if (deref->modes != from) continue; - deref->modes = nir_var_mem_ssbo; + deref->modes = to; } } } @@ -897,7 +900,8 @@ clc_spirv_to_dxil(struct clc_libclc *lib, nir->info.cs.ptr_size = 64; NIR_PASS_V(nir, clc_lower_constant_to_ssbo, out_dxil->kernel, &uav_id); - NIR_PASS_V(nir, clc_lower_global_to_ssbo); + NIR_PASS_V(nir, clc_change_variable_mode, nir_var_shader_temp, nir_var_mem_constant); + NIR_PASS_V(nir, clc_change_variable_mode, nir_var_mem_global, nir_var_mem_ssbo); bool has_printf = false; NIR_PASS(has_printf, nir, clc_lower_printf_base, uav_id); @@ -905,7 +909,7 @@ clc_spirv_to_dxil(struct clc_libclc *lib, NIR_PASS_V(nir, dxil_nir_lower_deref_ssbo); - NIR_PASS_V(nir, dxil_nir_split_unaligned_loads_stores, nir_var_all & ~nir_var_shader_temp); + NIR_PASS_V(nir, dxil_nir_split_unaligned_loads_stores, nir_var_all & ~nir_var_mem_constant); assert(nir->info.cs.ptr_size == 64); NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_ssbo, diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c index c9ae8bbcc53..ea92c6fa4c0 100644 --- a/src/microsoft/compiler/nir_to_dxil.c +++ b/src/microsoft/compiler/nir_to_dxil.c @@ -1500,14 +1500,14 @@ static bool emit_global_consts(struct ntd_context *ctx) { uint32_t index = 0; - nir_foreach_variable_with_modes(var, ctx->shader, nir_var_shader_temp) { + nir_foreach_variable_with_modes(var, ctx->shader, nir_var_mem_constant) { assert(var->constant_initializer); var->data.driver_location = index++; } ctx->consts = ralloc_array(ctx->ralloc_ctx, const struct dxil_value *, index); - nir_foreach_variable_with_modes(var, ctx->shader, nir_var_shader_temp) { + 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); @@ -6751,7 +6751,7 @@ nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts, optimize_nir(s, opts); NIR_PASS_V(s, nir_remove_dead_variables, - nir_var_function_temp | nir_var_shader_temp, NULL); + nir_var_function_temp | nir_var_mem_constant, NULL); if (!allocate_sysvalues(ctx)) return false;