radv: fix lowering the view index to an input varying for FS

When multiview is used and the FS is compiled separately with GPL, the
view index still needs to be lowered, otherwise it's crashing later.

The lowering doesn't need to know the previous stage because ViewIndex
is a global thing (ie. it's neither a per-vertex or a per-primitive
varying).

This fixes recent
dEQP-VK.pipeline.pipeline_library.graphics_library.misc.other.view_index_from_device_index_*_pre_rasterization

Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31192>
This commit is contained in:
Samuel Pitoiset 2024-09-16 17:51:09 +02:00 committed by Marge Bot
parent fb3b563d1f
commit 656d7e887a
3 changed files with 5 additions and 8 deletions

View file

@ -51,7 +51,7 @@ bool radv_nir_lower_fs_barycentric(nir_shader *shader, const struct radv_graphic
bool radv_nir_lower_intrinsics_early(nir_shader *nir, bool lower_view_index_to_zero);
bool radv_nir_lower_view_index(nir_shader *nir, bool per_primitive);
bool radv_nir_lower_view_index(nir_shader *nir);
bool radv_nir_lower_viewport_to_zero(nir_shader *nir);

View file

@ -33,7 +33,7 @@ find_layer_in_var(nir_shader *nir)
* driver_location.
*/
bool
radv_nir_lower_view_index(nir_shader *nir, bool per_primitive)
radv_nir_lower_view_index(nir_shader *nir)
{
bool progress = false;
nir_function_impl *entry = nir_shader_get_entrypoint(nir);
@ -52,15 +52,12 @@ radv_nir_lower_view_index(nir_shader *nir, bool per_primitive)
if (!layer)
layer = find_layer_in_var(nir);
layer->data.per_primitive = per_primitive;
b.cursor = nir_before_instr(instr);
nir_def *def = nir_load_var(&b, layer);
nir_def_rewrite_uses(&load->def, def);
/* Update inputs_read to reflect that the pass added a new input. */
nir->info.inputs_read |= VARYING_BIT_LAYER;
if (per_primitive)
nir->info.per_primitive_inputs |= VARYING_BIT_LAYER;
nir_instr_remove(instr);
progress = true;

View file

@ -1184,9 +1184,6 @@ radv_link_shaders(const struct radv_device *device, struct radv_shader_stage *pr
!(producer->info.outputs_written & VARYING_BIT_VIEWPORT)) {
NIR_PASS(_, consumer, radv_nir_lower_viewport_to_zero);
}
/* Lower the view index to map on the layer. */
NIR_PASS(_, consumer, radv_nir_lower_view_index, producer->info.stage == MESA_SHADER_MESH);
}
if (producer_stage->key.optimisations_disabled || consumer_stage->key.optimisations_disabled)
@ -1383,6 +1380,9 @@ radv_link_fs(struct radv_shader_stage *fs_stage, const struct radv_graphics_stat
{
assert(fs_stage->nir->info.stage == MESA_SHADER_FRAGMENT);
/* Lower the view index to map on the layer. */
NIR_PASS(_, fs_stage->nir, radv_nir_lower_view_index);
radv_remove_color_exports(gfx_state, fs_stage->nir);
}