nir/spirv: Fix gl_BaseVertex for non-indexed draws for OpenGL
authorAntia Puentes <apuentes@igalia.com>
Thu, 28 Feb 2019 18:07:36 +0000 (19:07 +0100)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Tue, 6 Aug 2019 16:11:27 +0000 (09:11 -0700)
Lowers BaseVertex to the correct system value for OpenGL.

v2: use options->environment rather than adding a new flag to
    spirv_to_nir_options

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
src/compiler/spirv/vtn_variables.c

index d4e3cac5db31c20dbbab7c4bcdd8e28296205f0b..843801cae5a1565c83558092beddfcb00906d58b 100644 (file)
@@ -1411,9 +1411,12 @@ vtn_get_builtin_location(struct vtn_builder *b,
       break;
    case SpvBuiltInBaseVertex:
       /* OpenGL gl_BaseVertex (SYSTEM_VALUE_BASE_VERTEX) is not the same
-       * semantic as SPIR-V BaseVertex (SYSTEM_VALUE_FIRST_VERTEX).
+       * semantic as Vulkan BaseVertex (SYSTEM_VALUE_FIRST_VERTEX).
        */
-      *location = SYSTEM_VALUE_FIRST_VERTEX;
+      if (b->options->environment == NIR_SPIRV_OPENGL)
+         *location = SYSTEM_VALUE_BASE_VERTEX;
+      else
+         *location = SYSTEM_VALUE_FIRST_VERTEX;
       set_mode_system_value(b, mode);
       break;
    case SpvBuiltInBaseInstance: