nir/spirv: Use VERTEX_ID_ZERO_BASE for VertexId
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 1 Sep 2015 00:16:01 +0000 (17:16 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 1 Sep 2015 00:16:49 +0000 (17:16 -0700)
In Vulkan, VertexId and InstanceId will be zero-based and new intrinsics,
VertexIndex and InstanceIndex, will be added for non-zer-based.  See also,
Khronos bug #14255

src/glsl/nir/spirv_to_nir.c

index c3a16986fc1b55faf5f058580292784e9aeba765..27a864f59933cf16b61015ec9ddca3654141cbce 100644 (file)
@@ -644,7 +644,10 @@ vtn_get_builtin_location(SpvBuiltIn builtin, int *location,
       /* XXX figure this out */
       unreachable("unhandled builtin");
    case SpvBuiltInVertexId:
-      *location = SYSTEM_VALUE_VERTEX_ID;
+      /* Vulkan defines VertexID to be zero-based and reserves the new
+       * builtin keyword VertexIndex to indicate the non-zero-based value.
+       */
+      *location = SYSTEM_VALUE_VERTEX_ID_ZERO_BASE;
       *mode = nir_var_system_value;
       break;
    case SpvBuiltInInstanceId: