mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 02:40:11 +01:00
microsoft/compiler: Use mem_constant instead of shader_temp for consts
We still use shader_temp as a temporary variable mode to differentiate which variables have simple deref patterns vs ones that need to be lowered to ssbo, but then we put it back to mem_constant when we're done to restore sanity. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23173>
This commit is contained in:
parent
f9b0382faf
commit
95bfee6a85
2 changed files with 12 additions and 8 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue