From a59575d8fbe8b0ca053cc8366ce7a42bc660158a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 30 May 2009 20:07:18 -0600 Subject: softpipe: fix incorrect provoking vertex color for PIPE_PRIM_POLYGON This fixes the incorrect colors seen when rendering flat-shaded polygons. Note that clipped polygons were correct, but unclipped polygons were wrong. See the glean/clipFlat test for regression testing. --- src/gallium/drivers/softpipe/sp_prim_vbuf.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index eef6e5806c9..329c92b8da1 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -378,7 +378,6 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) break; case PIPE_PRIM_TRIANGLE_FAN: - case PIPE_PRIM_POLYGON: for (i = 2; i < nr; i += 1) { setup_tri( setup_ctx, get_vert(vertex_buffer, 0, stride), @@ -386,6 +385,7 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) get_vert(vertex_buffer, i-0, stride)); } break; + case PIPE_PRIM_QUADS: for (i = 3; i < nr; i += 4) { setup_tri( setup_ctx, @@ -412,6 +412,20 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) get_vert(vertex_buffer, i-0, stride)); } break; + + case PIPE_PRIM_POLYGON: + /* Almost same as tri fan but the _first_ vertex specifies the flat + * shading color. Note that the first polygon vertex is passed as + * the last triangle vertex here. + */ + for (i = 2; i < nr; i += 1) { + setup_tri( setup_ctx, + get_vert(vertex_buffer, i-0, stride), + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, 0, stride)); + } + break; + default: assert(0); } -- cgit v1.2.3