}
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;
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;
}
}
}
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);
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,
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);
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;