pan/bi: Add helpers to get vertex/instance ID

These are preloaded in different places across Bifrost and Valhall. Abstract
that away so code using the builder isn't littered with "is Valhall?" checks.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15461>
This commit is contained in:
Alyssa Rosenzweig
2022-03-13 18:53:32 -04:00
committed by Marge Bot
parent 76a09b8cd3
commit 1e37113ede

View File

@@ -1277,6 +1277,23 @@ bi_word_node(bi_index idx)
return (idx.value << 2) | idx.offset;
}
/*
* Vertex ID and Instance ID are preloaded registers. Where they are preloaded
* changed from Bifrost to Valhall. Provide helpers that smooth over the
* architectural difference.
*/
static inline bi_index
bi_vertex_id(bi_builder *b)
{
return bi_register((b->shader->arch >= 9) ? 60 : 61);
}
static inline bi_index
bi_instance_id(bi_builder *b)
{
return bi_register((b->shader->arch >= 9) ? 61 : 62);
}
/* NIR passes */
bool bi_lower_divergent_indirects(nir_shader *shader, unsigned lanes);