pco: use nir_unlower_io_to_vars
Some checks failed
macOS-CI / macOS-CI (dri) (push) Has been cancelled
macOS-CI / macOS-CI (xlib) (push) Has been cancelled

Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37540>
This commit is contained in:
Simon Perretta 2025-09-23 14:52:06 +01:00
parent cd9d55201f
commit 86557cace1
2 changed files with 4 additions and 66 deletions

View file

@ -825,16 +825,6 @@ void pco_lower_nir(pco_ctx *ctx, nir_shader *nir, pco_data *data)
NIR_PASS(_, nir, nir_opt_constant_folding);
if (nir->info.stage == MESA_SHADER_VERTEX) {
/* TODO: false? */
NIR_PASS(_, nir, nir_lower_io_array_vars_to_elements_no_indirects, true);
NIR_PASS(_, nir, nir_split_struct_vars, nir_var_shader_out);
NIR_PASS(_, nir, nir_split_struct_vars, nir_var_shader_in);
} else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
NIR_PASS(_, nir, nir_lower_io_array_vars_to_elements_no_indirects, false);
NIR_PASS(_, nir, nir_split_struct_vars, nir_var_shader_in);
}
NIR_PASS(_,
nir,
nir_lower_io,
@ -859,11 +849,13 @@ void pco_lower_nir(pco_ctx *ctx, nir_shader *nir, pco_data *data)
nir_io_add_const_offset_to_base,
nir_var_shader_in | nir_var_shader_out);
/* Internal shaders will be using invalid32 types at this stage. */
if (!nir->info.internal)
NIR_PASS(_, nir, nir_unlower_io_to_vars, true);
if (nir->info.stage == MESA_SHADER_VERTEX)
NIR_PASS(_, nir, pco_nir_lower_clip_cull_vars);
NIR_PASS(_, nir, pco_nir_lower_variables, true, true);
NIR_PASS(_, nir, pco_nir_lower_images, data);
NIR_PASS(_,
nir,

View file

@ -103,57 +103,3 @@ bool pco_nir_lower_io(nir_shader *shader)
return progress;
}
bool pco_nir_lower_variables(nir_shader *shader, bool inputs, bool outputs)
{
bool progress = false;
nir_variable_mode modes = 0;
assert(inputs || outputs);
if (inputs)
modes |= nir_var_shader_in;
if (outputs)
modes |= nir_var_shader_out;
nir_foreach_variable_with_modes (var, shader, modes) {
unsigned slots = glsl_count_vec4_slots(var->type, false, false);
if (slots == 1)
continue;
assert(!var->data.location_frac);
unsigned dwords = glsl_count_dword_slots(var->type, false);
assert(!(dwords % slots));
unsigned slot_size = dwords / slots;
unsigned location = var->data.location;
var->type = glsl_vector_type(
glsl_get_base_type(glsl_without_array_or_matrix(var->type)),
slot_size);
dwords -= slot_size;
for (unsigned u = 1; u < slots; ++u) {
assert(!nir_find_variable_with_location(shader,
var->data.mode,
location + u));
unsigned comps = dwords < slot_size ? dwords : slot_size;
const glsl_type *type =
glsl_vector_type(glsl_get_base_type(var->type), comps);
dwords -= comps;
nir_create_variable_with_location(shader,
var->data.mode,
location + u,
type);
}
progress = true;
}
return nir_progress(progress,
nir_shader_get_entrypoint(shader),
nir_metadata_none);
}