gallium/tgsi: Add support for PRIMITIVEID as a system value.
authorEric Anholt <eric@anholt.net>
Tue, 14 Jan 2020 19:31:22 +0000 (11:31 -0800)
committerEric Anholt <eric@anholt.net>
Wed, 2 Sep 2020 16:58:44 +0000 (09:58 -0700)
NIR always represents this as a system value, so for NIR-to-TGSI we need
this support.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6567>

src/gallium/auxiliary/draw/draw_gs.c

index 2d11430b274af2b5c83f7e089a82a7dbe8e00968..9f9983d8350ac7694082636bb5430d2e54e41f2c 100644 (file)
@@ -132,6 +132,12 @@ static void tgsi_fetch_gs_input(struct draw_geometry_shader *shader,
    unsigned input_vertex_stride = shader->input_vertex_stride;
    const float (*input_ptr)[4];
 
+   int primid_sv = machine->SysSemanticToIndex[TGSI_SEMANTIC_PRIMID];
+   if (primid_sv != -1) {
+      for (unsigned j = 0; j < TGSI_QUAD_SIZE; j++)
+         machine->SystemValue[primid_sv].xyzw[0].i[j] = shader->in_prim_idx;
+   }
+
    input_ptr = shader->input;
 
    for (i = 0; i < num_vertices; ++i) {