Mesa (7.9): draw: don't apply flatshading to clipped tris with <3 verts

Keith Whitwell keithw at kemper.freedesktop.org
Thu Sep 23 15:28:42 UTC 2010


Module: Mesa
Branch: 7.9
Commit: 6f310f379b31be4776e43447bf38416de56e5abb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f310f379b31be4776e43447bf38416de56e5abb

Author: Keith Whitwell <keithw at vmware.com>
Date:   Thu Sep 23 16:11:17 2010 +0100

draw: don't apply flatshading to clipped tris with <3 verts

If a triangle was completely culled by clipping, we would still try to
fix up its provoking vertex.

---

 src/gallium/auxiliary/draw/draw_pipe_clip.c |   35 ++++++++++++++-------------
 1 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c
index 8a3d499..50acc6c 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_clip.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c
@@ -321,27 +321,28 @@ do_clip_tri( struct draw_stage *stage,
 
    /* If flat-shading, copy provoking vertex color to polygon vertex[0]
     */
-   if (clipper->flat) {
-      if (stage->draw->rasterizer->flatshade_first) {
-         if (inlist[0] != header->v[0]) {
-            assert(tmpnr < MAX_CLIPPED_VERTICES + 1);
-            inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
-            copy_colors(stage, inlist[0], header->v[0]);
+   if (n >= 3) {
+      if (clipper->flat) {
+         if (stage->draw->rasterizer->flatshade_first) {
+            if (inlist[0] != header->v[0]) {
+               assert(tmpnr < MAX_CLIPPED_VERTICES + 1);
+               inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
+               copy_colors(stage, inlist[0], header->v[0]);
+            }
          }
-      }
-      else {
-         if (inlist[0] != header->v[2]) {
-            assert(tmpnr < MAX_CLIPPED_VERTICES + 1);
-            inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
-            copy_colors(stage, inlist[0], header->v[2]);
+         else {
+            if (inlist[0] != header->v[2]) {
+               assert(tmpnr < MAX_CLIPPED_VERTICES + 1);
+               inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
+               copy_colors(stage, inlist[0], header->v[2]);
+            }
          }
       }
-   }
-
-   /* Emit the polygon as triangles to the setup stage:
-    */
-   if (n >= 3)
+      
+      /* Emit the polygon as triangles to the setup stage:
+       */
       emit_poly( stage, inlist, n, header );
+   }
 }
 
 




More information about the mesa-commit mailing list