From 4e797ac530b02a1d35a86061fe704524d6bab5a5 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Fri, 1 Jul 2022 12:33:08 +1000 Subject: [PATCH] st/glsl: fix broken vertex attrib mapping Here we move the nir_get_single_slot_attribs_mask() call that sets the inputs_read mask after NIR optimisations have finished and after st_nir_assign_vs_in_locations() has been called. Besides fixing a bug where the mappings would be missaligned if further NIR optimisations resulted in less inputs being read, it also allows us to drop an additional nir gather info call. Fixes: 0909a57b631f ("radeonsi/nir: Set vs_inputs_dual_locations and let NIR do the remap") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6240 Reviewed-by: Mike Blumenkrantz Part-of: --- src/mesa/state_tracker/st_glsl_to_nir.cpp | 39 +++++++++---------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 27ff0e34..179a646 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -85,19 +85,6 @@ st_nir_fixup_varying_slots(struct st_context *st, nir_shader *shader, } } -static void -st_shader_gather_info(nir_shader *nir, struct gl_program *prog) -{ - nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir)); - - /* Copy the info we just generated back into the gl_program */ - const char *prog_name = prog->info.name; - const char *prog_label = prog->info.label; - prog->info = nir->info; - prog->info.name = prog_name; - prog->info.label = prog_label; -} - /* input location assignment for VS inputs must be handled specially, so * that it is aligned w/ st's vbo state. * (This isn't the case with, for ex, FS inputs, which only need to agree @@ -797,17 +784,6 @@ st_link_nir(struct gl_context *ctx, if (!st->screen->get_param(st->screen, PIPE_CAP_CULL_DISTANCE_NOCOMBINE)) NIR_PASS_V(nir, nir_lower_clip_cull_distance_arrays); - st_shader_gather_info(nir, shader->Program); - if (shader->Stage == MESA_SHADER_VERTEX) { - /* NIR expands dual-slot inputs out to two locations. We need to - * compact things back down GL-style single-slot inputs to avoid - * confusing the state tracker. - */ - shader->Program->info.inputs_read = - nir_get_single_slot_attribs_mask(nir->info.inputs_read, - shader->Program->DualSlotInputs); - } - if (i >= 1) { struct gl_program *prev_shader = linked_shader[i - 1]->Program; @@ -881,12 +857,19 @@ st_link_nir(struct gl_context *ctx, prog->info.num_ssbos = old_info.num_ssbos; prog->info.num_ubos = old_info.num_ubos; prog->info.num_abos = old_info.num_abos; - if (prog->info.stage == MESA_SHADER_VERTEX) - prog->info.inputs_read = old_info.inputs_read; - /* Initialize st_vertex_program members. */ - if (shader->Stage == MESA_SHADER_VERTEX) + if (prog->info.stage == MESA_SHADER_VERTEX) { + /* NIR expands dual-slot inputs out to two locations. We need to + * compact things back down GL-style single-slot inputs to avoid + * confusing the state tracker. + */ + prog->info.inputs_read = + nir_get_single_slot_attribs_mask(prog->nir->info.inputs_read, + prog->DualSlotInputs); + + /* Initialize st_vertex_program members. */ st_prepare_vertex_program(prog); + } /* Get pipe_stream_output_info. */ if (shader->Stage == MESA_SHADER_VERTEX || -- 2.7.4