From 1e37113edeff141f6bf4f2deda59e5f05aea96be Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 13 Mar 2022 18:53:32 -0400 Subject: [PATCH] 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 Part-of: --- src/panfrost/bifrost/compiler.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 2d7ea5f707c..50a057805ae 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -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);