[Mesa-dev] [PATCH 25/34] gallium/draw: Pass primitive ID as integer to the shader.

Paul Berry stereotype441 at gmail.com
Sun Jul 28 23:03:51 PDT 2013


From: Fabian Bieler <fabianbieler at fastmail.fm>

The shader interprets the value as an integer.
---
 src/gallium/auxiliary/draw/draw_gs.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index 78727c6..917f028 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -143,14 +143,16 @@ static void tgsi_fetch_gs_input(struct draw_geometry_shader *shader,
       for (slot = 0, vs_slot = 0; slot < shader->info.num_inputs; ++slot) {
          unsigned idx = i * TGSI_EXEC_MAX_INPUT_ATTRIBS + slot;
          if (shader->info.input_semantic_name[slot] == TGSI_SEMANTIC_PRIMID) {
-            machine->Inputs[idx].xyzw[0].f[prim_idx] =
-               (float)shader->in_prim_idx;
-            machine->Inputs[idx].xyzw[1].f[prim_idx] =
-               (float)shader->in_prim_idx;
-            machine->Inputs[idx].xyzw[2].f[prim_idx] =
-               (float)shader->in_prim_idx;
-            machine->Inputs[idx].xyzw[3].f[prim_idx] =
-               (float)shader->in_prim_idx;
+            machine->Inputs[idx].xyzw[0].i[prim_idx] =
+            machine->Inputs[idx].xyzw[1].i[prim_idx] =
+            machine->Inputs[idx].xyzw[2].i[prim_idx] =
+            machine->Inputs[idx].xyzw[3].i[prim_idx] =
+               shader->in_prim_idx;
+#if DEBUG_INPUTS
+            debug_printf("\tSlot = %d, primitive id, idx = %d:\n",
+                         slot, idx);
+            debug_printf("\t\t%d\n", shader->in_prim_idx);
+#endif
          } else {
             vs_slot = draw_gs_get_input_index(
                shader->info.input_semantic_name[slot],
-- 
1.8.3.4



More information about the mesa-dev mailing list