diff options
author | José Fonseca <jfonseca@vmware.com> | 2010-05-05 00:40:56 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2010-05-05 00:46:13 +0100 |
commit | ddb0e18f6c5582d4d2cc59ffd16ad9c4639ed059 (patch) | |
tree | 883babf9defff6f298b488cc0f9bca743ea47072 /src/gallium/auxiliary/draw/draw_pipe_clip.c | |
parent | dc1c33b448c830c5775e4f3fb6510830694a4177 (diff) |
draw: Preserve the provoking vertex both when decomposing and clipping.
Based on John Lawless' feedback.
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_pipe_clip.c')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_pipe_clip.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c index 51a6115ebf..428ef4ef67 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_clip.c +++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c @@ -175,9 +175,17 @@ static void emit_poly( struct draw_stage *stage, header.pad = 0; for (i = 2; i < n; i++, header.flags = edge_middle) { - header.v[0] = inlist[i-1]; - header.v[1] = inlist[i]; - header.v[2] = inlist[0]; /* keep in v[2] for flatshading */ + /* keep in provoking vertex for flatshading */ + if (stage->draw->rasterizer->flatshade_first) { + header.v[0] = inlist[0]; + header.v[1] = inlist[i-1]; + header.v[2] = inlist[i]; + } + else { + header.v[0] = inlist[i-1]; + header.v[1] = inlist[i]; + header.v[2] = inlist[0]; + } if (i == n-1) header.flags |= edge_last; @@ -293,12 +301,21 @@ do_clip_tri( struct draw_stage *stage, /* If flat-shading, copy color to new provoking vertex. */ - if (clipper->flat && inlist[0] != header->v[2]) { - inlist[0] = dup_vert(stage, inlist[0], tmpnr++); + if (stage->draw->rasterizer->flatshade_first) { + if (clipper->flat && inlist[0] != header->v[0]) { + inlist[0] = dup_vert(stage, inlist[0], tmpnr++); + + copy_colors(stage, inlist[0], header->v[0]); + } + } else { + if (clipper->flat && inlist[0] != header->v[2]) { + inlist[0] = dup_vert(stage, inlist[0], tmpnr++); - copy_colors(stage, inlist[0], header->v[2]); + copy_colors(stage, inlist[0], header->v[2]); + } } + /* Emit the polygon as triangles to the setup stage: */ if (n >= 3) |