From e1783fc083b830fa804a81206fea41e75a811353 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 29 Jan 2024 16:17:45 -0400 Subject: [PATCH] libagx: generalize vertex_id_for_topology so we can use it in separable GS Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/lib/agx_nir_lower_gs.h | 4 ++++ src/asahi/lib/agx_nir_lower_ia.c | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/asahi/lib/agx_nir_lower_gs.h b/src/asahi/lib/agx_nir_lower_gs.h index 126602d657a..3f6bd3b62a0 100644 --- a/src/asahi/lib/agx_nir_lower_gs.h +++ b/src/asahi/lib/agx_nir_lower_gs.h @@ -26,6 +26,10 @@ struct agx_lower_output_to_var_state { bool agx_lower_output_to_var(struct nir_builder *b, struct nir_instr *instr, void *data); +struct nir_def *agx_vertex_id_for_topology(struct nir_builder *b, + struct nir_def *vert, + struct agx_ia_key *key); + bool agx_nir_lower_ia(struct nir_shader *s, struct agx_ia_key *ia); bool agx_nir_lower_gs(struct nir_shader *gs, struct nir_shader *vs, diff --git a/src/asahi/lib/agx_nir_lower_ia.c b/src/asahi/lib/agx_nir_lower_ia.c index d0f6d179160..032c216dd10 100644 --- a/src/asahi/lib/agx_nir_lower_ia.c +++ b/src/asahi/lib/agx_nir_lower_ia.c @@ -24,11 +24,11 @@ * Sync with geometry.cl, this is preferred to avoid NIR needing to chew through * the massive switch statement (bad for compile time). */ -static nir_def * -vertex_id_for_topology(nir_builder *b, struct agx_ia_key *key) +nir_def * +agx_vertex_id_for_topology(nir_builder *b, nir_def *vert, + struct agx_ia_key *key) { nir_def *prim = nir_load_primitive_id(b); - nir_def *vert = nir_load_vertex_id_in_primitive_agx(b); nir_def *flatshade_first = nir_imm_bool(b, key->flatshade_first); switch (key->mode) { @@ -73,7 +73,8 @@ vertex_id_for_topology(nir_builder *b, struct agx_ia_key *key) static nir_def * load_vertex_id(nir_builder *b, struct agx_ia_key *key) { - nir_def *id = vertex_id_for_topology(b, key); + nir_def *vert = nir_load_vertex_id_in_primitive_agx(b); + nir_def *id = agx_vertex_id_for_topology(b, vert, key); /* If drawing with an index buffer, pull the vertex ID. Otherwise, the * vertex ID is just the index as-is.