draw/vs: partly fix basevertex/vertex id
authorDave Airlie <airlied@redhat.com>
Mon, 25 Mar 2019 05:38:18 +0000 (15:38 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 26 Mar 2019 21:52:28 +0000 (07:52 +1000)
This gets the basevertex from the draw depending on whether
it's an indexed or non-indexed draw.

We still fail a transform feedback test for vertex id, as
the vertex id actually an index id, and isn't getting translated
properly to a vertex id, suggestions on how/where to fix that welcome.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/draw/draw_vs_exec.c

index 4f11ac7506cdd9cccb1e3ab7438ce02148a4e231..dbd7aa551ebc2d07647d693e1277e3b6d67e5530 100644 (file)
@@ -128,18 +128,17 @@ vs_exec_run_linear(struct draw_vertex_shader *shader,
                          input[slot][3]);
          }
 #endif
+        int basevertex = shader->draw->pt.user.eltSize ? shader->draw->pt.user.eltBias : shader->draw->start_index;
 
          if (shader->info.uses_vertexid) {
             unsigned vid = machine->SysSemanticToIndex[TGSI_SEMANTIC_VERTEXID];
             assert(vid < ARRAY_SIZE(machine->SystemValue));
-            machine->SystemValue[vid].xyzw[0].i[j] = i + j;
-            /* XXX this should include base vertex. Where to get it??? */
+            machine->SystemValue[vid].xyzw[0].i[j] = i + j + basevertex;
          }
          if (shader->info.uses_basevertex) {
             unsigned vid = machine->SysSemanticToIndex[TGSI_SEMANTIC_BASEVERTEX];
             assert(vid < ARRAY_SIZE(machine->SystemValue));
-            machine->SystemValue[vid].xyzw[0].i[j] = 0;
-            /* XXX Where to get it??? */
+            machine->SystemValue[vid].xyzw[0].i[j] = basevertex;
          }
          if (shader->info.uses_vertexid_nobase) {
             unsigned vid = machine->SysSemanticToIndex[TGSI_SEMANTIC_VERTEXID_NOBASE];