[Mesa-dev] [PATCH v2 5/7] nir: Offset vertex_id by first_vertex instead of base_vertex

Antia Puentes apuentes at igalia.com
Mon Dec 4 20:12:51 UTC 2017


From: Neil Roberts <nroberts at igalia.com>

base_vertex will be zero for non-indexed calls, but we need it to
include the ‘first’ parameter. This is true for both GL and Vulkan.

I think this patch will also affect freedreno and radeonsi. I believe
if they are relying on this lowering then they are currently already
broken because they will have the wrong values for gl_BaseVertex.
However this patch will also make them break for gl_VertexID and they
will need to be fixed to use firt_vertex instead.
---
 src/compiler/nir/nir_lower_system_values.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c
index 3594f4ae5ce..6f4fb8233ab 100644
--- a/src/compiler/nir/nir_lower_system_values.c
+++ b/src/compiler/nir/nir_lower_system_values.c
@@ -105,7 +105,7 @@ convert_block(nir_block *block, nir_builder *b)
          if (b->shader->options->vertex_id_zero_based) {
             sysval = nir_iadd(b,
                               nir_load_vertex_id_zero_base(b),
-                              nir_load_base_vertex(b));
+                              nir_load_first_vertex(b));
          } else {
             sysval = nir_load_vertex_id(b);
          }
-- 
2.14.1



More information about the mesa-dev mailing list