asahi: Add helper to get layer id in internal program

For background/EOT only.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
This commit is contained in:
Alyssa Rosenzweig 2023-09-15 16:20:15 -04:00
parent 7d94f2ee49
commit 88fd76d378
2 changed files with 13 additions and 0 deletions

View file

@ -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)
{

View file

@ -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;