nir/lower_io: don't renumber VS inputs when not called from a linker

This fixes a Nine regression. The comment explains it.

The new varying linking code will set true here.

Fixes: d29dd333 - nir: assign IO bases in nir_lower_io_passes
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8935

Reviewed-by: Timothy Arceri <tarceri@yahoo.com.au>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22859>
This commit is contained in:
Marek Olšák 2023-05-04 15:45:49 -04:00 committed by Marge Bot
parent 275cf62e20
commit 177af45577
4 changed files with 14 additions and 5 deletions

View file

@ -4904,7 +4904,7 @@ bool nir_lower_io(nir_shader *shader,
bool nir_io_add_const_offset_to_base(nir_shader *nir, nir_variable_mode modes);
bool nir_lower_color_inputs(nir_shader *nir);
void nir_lower_io_passes(nir_shader *nir);
void nir_lower_io_passes(nir_shader *nir, bool renumber_vs_inputs);
bool nir_io_add_intrinsic_xfb_info(nir_shader *nir);
bool

View file

@ -3045,9 +3045,16 @@ type_size_vec4(const struct glsl_type *type, bool bindless)
/**
* This runs all compiler passes needed to lower IO, lower indirect IO access,
* set transform feedback info in IO intrinsics, and clean up the IR.
*
* \param renumber_vs_inputs
* Set to true if holes between VS inputs should be removed, which is safe
* to do in any shader linker that can handle that. Set to false if you want
* to keep holes between VS inputs, which is recommended to do in gallium
* drivers so as not to break the mapping of vertex elements to VS inputs
* expected by gallium frontends.
*/
void
nir_lower_io_passes(nir_shader *nir)
nir_lower_io_passes(nir_shader *nir, bool renumber_vs_inputs)
{
if (!nir->options->lower_io_variables ||
nir->info.stage == MESA_SHADER_COMPUTE)
@ -3089,7 +3096,9 @@ nir_lower_io_passes(nir_shader *nir)
* This kind of canonicalizes all bases.
*/
NIR_PASS_V(nir, nir_recompute_io_bases,
nir_var_shader_in | nir_var_shader_out);
(nir->info.stage != MESA_SHADER_VERTEX ||
renumber_vs_inputs ? nir_var_shader_in : 0) |
nir_var_shader_out);
/* nir_io_add_const_offset_to_base needs actual constants. */
NIR_PASS_V(nir, nir_opt_constant_folding);

View file

@ -437,7 +437,7 @@ char *si_finalize_nir(struct pipe_screen *screen, void *nirptr)
struct si_screen *sscreen = (struct si_screen *)screen;
struct nir_shader *nir = (struct nir_shader *)nirptr;
nir_lower_io_passes(nir);
nir_lower_io_passes(nir, false);
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_in | nir_var_shader_out, NULL);
if (nir->info.stage == MESA_SHADER_FRAGMENT)

View file

@ -1081,7 +1081,7 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
* This depends on st_nir_assign_varying_locations.
*/
if (nir->options->lower_io_variables) {
nir_lower_io_passes(nir);
nir_lower_io_passes(nir, false);
NIR_PASS_V(nir, nir_remove_dead_variables,
nir_var_shader_in | nir_var_shader_out, NULL);
}