Mesa (master): draw/gs: Correctly iterate the emitted primitives

Zack Rusin zack at kemper.freedesktop.org
Mon Mar 11 16:38:09 UTC 2013


Module: Mesa
Branch: master
Commit: 7295fad2043e2cb09fd1c0b98357464062478912
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7295fad2043e2cb09fd1c0b98357464062478912

Author: Zack Rusin <zackr at vmware.com>
Date:   Thu Mar  7 19:15:03 2013 -0800

draw/gs: Correctly iterate the emitted primitives

We were assuming that each emitted primitive had the same
number of vertices. That is incorrect. Emitted primitives
can have arbirtrary number of vertices. Simply increment
index on iteration to fix it.

Signed-off-by: Zack Rusin <zackr at vmware.com>
Reviewed-by: José Fonseca <jfonseca at vmware.com>

---

 src/gallium/auxiliary/draw/draw_gs.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index 99335af..e605965 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -172,6 +172,7 @@ draw_geometry_fetch_outputs(struct draw_geometry_shader *shader,
 {
    struct tgsi_exec_machine *machine = shader->machine;
    unsigned prim_idx, j, slot;
+   unsigned current_idx = 0;
    float (*output)[4];
 
    output = *p_output;
@@ -184,9 +185,8 @@ draw_geometry_fetch_outputs(struct draw_geometry_shader *shader,
       shader->primitive_lengths[prim_idx +   shader->emitted_primitives] =
          machine->Primitives[prim_idx];
       shader->emitted_vertices += num_verts_per_prim;
-      for (j = 0; j < num_verts_per_prim; j++) {
-         int idx = (prim_idx * num_verts_per_prim + j) *
-                   shader->info.num_outputs;
+      for (j = 0; j < num_verts_per_prim; j++, current_idx++) {
+         int idx = current_idx * shader->info.num_outputs;
 #ifdef DEBUG_OUTPUTS
          debug_printf("%d) Output vert:\n", idx / shader->info.num_outputs);
 #endif
@@ -208,7 +208,7 @@ draw_geometry_fetch_outputs(struct draw_geometry_shader *shader,
       }
    }
    *p_output = output;
-         shader->emitted_primitives += num_primitives;
+   shader->emitted_primitives += num_primitives;
 }
 
 /*#define DEBUG_INPUTS 1*/




More information about the mesa-commit mailing list