agx: fix metadata in layer lowering

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26976>
This commit is contained in:
Alyssa Rosenzweig
2024-01-08 22:48:43 -04:00
committed by Marge Bot
parent fe04e85be9
commit 01344819b0
2 changed files with 10 additions and 3 deletions

View File

@@ -3096,7 +3096,12 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
*/
if (nir->info.stage == MESA_SHADER_VERTEX) {
NIR_PASS_V(nir, nir_lower_io_to_scalar, nir_var_shader_out, NULL, NULL);
NIR_PASS_V(nir, agx_nir_lower_layer);
if (nir->info.outputs_written &
(VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT)) {
NIR_PASS_V(nir, agx_nir_lower_layer);
}
}
NIR_PASS_V(nir, nir_opt_constant_folding);

View File

@@ -11,8 +11,7 @@ void
agx_nir_lower_layer(nir_shader *s)
{
assert(s->info.stage == MESA_SHADER_VERTEX);
if (!(s->info.outputs_written & (VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT)))
return;
assert(s->info.outputs_written & (VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT));
/* Writes are in the last block, search */
nir_function_impl *impl = nir_shader_get_entrypoint(s);
@@ -64,4 +63,7 @@ agx_nir_lower_layer(nir_shader *s)
.io_semantics.location = VARYING_SLOT_LAYER,
.io_semantics.num_slots = 1,
.io_semantics.no_varying = true);
nir_metadata_preserve(impl,
nir_metadata_dominance | nir_metadata_block_index);
}