From afb60d7707f835e3a8ba2e3bf16518af01509b01 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 17 Nov 2023 17:20:17 -0400 Subject: [PATCH] asahi: fix index bias with GS/XFB noticed when bringing up mdi. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/lib/agx_nir_lower_gs.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/asahi/lib/agx_nir_lower_gs.c b/src/asahi/lib/agx_nir_lower_gs.c index 0b547ce4fa0..11a6ca132df 100644 --- a/src/asahi/lib/agx_nir_lower_gs.c +++ b/src/asahi/lib/agx_nir_lower_gs.c @@ -188,12 +188,7 @@ load_vs_vertex_id(nir_builder *b, struct agx_ia_key *key) load_primitive_id(b), nir_load_vertex_id_in_primitive_agx(b), nir_channel(b, nir_load_num_workgroups(b), 0)); - /* Add the "start", either an index bias or a base vertex */ - id = nir_iadd(b, id, nir_load_first_vertex(b)); - - /* If drawing with an index buffer, pull the vertex ID. Otherwise, the - * vertex ID is just the index as-is. - */ + /* If drawing with an index buffer, pull the vertex ID. */ if (key->index_size) { nir_def *index_buffer = load_geometry_param(b, input_index_buffer); nir_def *offset = nir_imul_imm(b, id, key->index_size); @@ -201,10 +196,13 @@ load_vs_vertex_id(nir_builder *b, struct agx_ia_key *key) nir_def *index = nir_load_global_constant(b, address, key->index_size, 1, key->index_size * 8); - return nir_u2uN(b, index, id->bit_size); - } else { - return id; + id = nir_u2uN(b, index, id->bit_size); } + + /* Add the "start", either an index bias or a base vertex. This must happen + * after indexing for proper index bias behaviour. + */ + return nir_iadd(b, id, nir_load_first_vertex(b)); } static bool