nir: Simplify assign_io_var_locations()

The size and stage parameters are left-overs from history.  Originally,
the function acted on a list and so it needed an explicit stage and size
output.  Now that it takes a NIR shader and a mode, we can just take the
stage from the shader and set num_(in|out)puts.

The one caller that actually used the explicit output parameter was
turnip.  However, given that the helper sorts and re-numbers all the I/O
variables, it's not like changing num_(in|out)puts instead of writing it
to some other location is that big of a deal.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38297>
This commit is contained in:
Faith Ekstrand
2025-11-06 21:42:00 -05:00
committed by Marge Bot
parent 51cfdf3a9d
commit 35cdddf632
10 changed files with 32 additions and 49 deletions
+6 -15
View File
@@ -933,11 +933,8 @@ lower_fs_io(nir_shader *nir)
NIR_PASS(_, nir, nir_lower_io_array_vars_to_elements_no_indirects, false);
NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_shader_out, NULL);
nir_assign_io_var_locations(nir, nir_var_shader_in, &nir->num_inputs,
MESA_SHADER_FRAGMENT);
nir_assign_io_var_locations(nir, nir_var_shader_out, &nir->num_outputs,
MESA_SHADER_FRAGMENT);
nir_assign_io_var_locations(nir, nir_var_shader_in);
nir_assign_io_var_locations(nir, nir_var_shader_out);
NIR_PASS(_, nir, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
type_size_vec4, 0);
@@ -948,11 +945,8 @@ lower_gs_io(struct nir_shader *nir)
{
NIR_PASS(_, nir, nir_lower_io_array_vars_to_elements_no_indirects, false);
nir_assign_io_var_locations(nir, nir_var_shader_in, &nir->num_inputs,
MESA_SHADER_GEOMETRY);
nir_assign_io_var_locations(nir, nir_var_shader_out, &nir->num_outputs,
MESA_SHADER_GEOMETRY);
nir_assign_io_var_locations(nir, nir_var_shader_in);
nir_assign_io_var_locations(nir, nir_var_shader_out);
}
static void
@@ -960,11 +954,8 @@ lower_vs_io(struct nir_shader *nir)
{
NIR_PASS(_, nir, nir_lower_io_array_vars_to_elements_no_indirects, false);
nir_assign_io_var_locations(nir, nir_var_shader_in, &nir->num_inputs,
MESA_SHADER_VERTEX);
nir_assign_io_var_locations(nir, nir_var_shader_out, &nir->num_outputs,
MESA_SHADER_VERTEX);
nir_assign_io_var_locations(nir, nir_var_shader_in);
nir_assign_io_var_locations(nir, nir_var_shader_out);
/* FIXME: if we call nir_lower_io, we get a crash later. Likely because it
* overlaps with v3d_nir_lower_io. Need further research though.