Mesa (master): r300g: Fix provoking vertex for non-quads.

Corbin Simpson csimpson at kemper.freedesktop.org
Sat Dec 19 05:54:31 UTC 2009


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

Author: Corbin Simpson <MostAwesomeDude at gmail.com>
Date:   Fri Dec 18 21:50:45 2009 -0800

r300g: Fix provoking vertex for non-quads.

Read the comments. In short, we can't possibly pass piglit's
glean/clipFlat without some help from Gallium and an API/spec change.

---

 src/gallium/drivers/r300/r300_render.c |   31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 11c7ce8..2d70ec2 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -83,15 +83,34 @@ static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300,
     /* By default (see r300_state.c:r300_create_rs_state) color_control is
      * initialized to provoking the first vertex.
      *
-     * If we are provoking the first vertex, then there's a quirk in the
-     * specification for ARB_provoking_vertex that essentially makes the
-     * second vertex the correct one to provoke for triangle fans.
+     * Triangle fans must be reduced to the second vertex, not the first, in
+     * Gallium flatshade-first mode, as per the GL spec.
      * (http://www.opengl.org/registry/specs/ARB/provoking_vertex.txt)
-     * Otherwise, force the last vertex, as GL standard. */
+     *
+     * Quads never provoke correctly in flatshade-first mode. The first
+     * vertex is never considered as provoking, so only the second, third,
+     * and fourth vertices can be selected, and both "third" and "last" modes
+     * select the fourth vertex. This is probably due to D3D lacking quads.
+     *
+     * Similarly, polygons reduce to the first, not the last, vertex, when in
+     * "last" mode, and all other modes start from the second vertex.
+     *
+     * ~ C.
+     */
 
     if (r300->rs_state->rs.flatshade_first) {
-        if (mode == PIPE_PRIM_TRIANGLE_FAN) {
-            color_control |= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_SECOND;
+        switch (mode) {
+            case PIPE_PRIM_TRIANGLE_FAN:
+                color_control |= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_SECOND;
+                break;
+            case PIPE_PRIM_QUADS:
+            case PIPE_PRIM_QUAD_STRIP:
+            case PIPE_PRIM_POLYGON:
+                color_control |= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST;
+                break;
+            default:
+                color_control |= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_FIRST;
+                break;
         }
     } else {
         color_control |= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST;




More information about the mesa-commit mailing list