st/mesa: use vertex id lowering according to pipe cap bit.
authorRoland Scheidegger <sroland@vmware.com>
Fri, 12 Dec 2014 03:14:02 +0000 (04:14 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 16 Dec 2014 03:23:00 +0000 (04:23 +0100)
Tested with llvmpipe by setting the cap bit temporarily, seems to work,
though no driver requests it for now.

src/mesa/state_tracker/st_extensions.c
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 20a6845e3b263b687528e27adb66ab2e325f2db4..e472b84a83346971c4510471bb3f4b165a9fea4b 100644 (file)
@@ -674,6 +674,10 @@ void st_init_extensions(struct pipe_screen *screen,
       consts->NativeIntegers = GL_TRUE;
       consts->MaxClipPlanes = 8;
 
+      if (screen->get_param(screen, PIPE_CAP_VERTEXID_NOBASE)) {
+         consts->VertexID_is_zero_based = GL_TRUE;
+      }
+
       /* Extensions that either depend on GLSL 1.30 or are a subset thereof. */
       extensions->ARB_conservative_depth = GL_TRUE;
       extensions->ARB_shading_language_packing = GL_TRUE;
index 80dd1028a523f602c51cbb3242f067442bff58f5..5bc70a4925bcab6f92bb8aa20dc9eedc0f797211 100644 (file)
@@ -4195,8 +4195,8 @@ const unsigned _mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = {
     */
    TGSI_SEMANTIC_VERTEXID,
    TGSI_SEMANTIC_INSTANCEID,
-   0,
-   0,
+   TGSI_SEMANTIC_VERTEXID_NOBASE,
+   TGSI_SEMANTIC_BASEVERTEX,
 
    /* Geometry shader
     */
@@ -4907,6 +4907,10 @@ st_translate_program(
           TGSI_SEMANTIC_SAMPLEMASK);
    assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_INVOCATION_ID] ==
           TGSI_SEMANTIC_INVOCATIONID);
+   assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_VERTEX_ID_ZERO_BASE] ==
+          TGSI_SEMANTIC_VERTEXID_NOBASE);
+   assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_BASE_VERTEX] ==
+          TGSI_SEMANTIC_BASEVERTEX);
 
    t = CALLOC_STRUCT(st_translate);
    if (!t) {