diff --git a/src/asahi/lib/agx_nir_lower_tilebuffer.c b/src/asahi/lib/agx_nir_lower_tilebuffer.c index 81d32275d51..4bb6b057773 100644 --- a/src/asahi/lib/agx_nir_lower_tilebuffer.c +++ b/src/asahi/lib/agx_nir_lower_tilebuffer.c @@ -205,6 +205,15 @@ load_memory(nir_builder *b, unsigned bindless_base, unsigned nr_samples, } } +nir_def * +agx_internal_layer_id(nir_builder *b) +{ + /* In the background and end-of-tile programs, the layer ID is available as + * sr2, the Z component of the workgroup index. + */ + return nir_channel(b, nir_load_workgroup_id(b), 2); +} + static nir_def * tib_impl(nir_builder *b, nir_instr *instr, void *data) { diff --git a/src/asahi/lib/agx_tilebuffer.h b/src/asahi/lib/agx_tilebuffer.h index 13b317d2a37..6f9a4849a28 100644 --- a/src/asahi/lib/agx_tilebuffer.h +++ b/src/asahi/lib/agx_tilebuffer.h @@ -22,6 +22,8 @@ extern "C" { /* Forward declarations to keep the header lean */ struct nir_shader; +struct nir_def; +struct nir_builder; struct agx_usc_builder; struct agx_tile_size { @@ -88,6 +90,8 @@ bool agx_nir_lower_tilebuffer(struct nir_shader *shader, uint8_t *colormasks, unsigned *bindless_base, bool *translucent); +struct nir_def *agx_internal_layer_id(struct nir_builder *b); + struct agx_msaa_state { uint8_t nr_samples;