gallium: a lot more complete implementation of stream output
[mesa.git] / src / gallium / auxiliary / draw / draw_pt_decompose.h
index 8e1d60e9ce350da6fba5be55bf1149104a2ed667..52f9593d46ed535f199cecab6f7b7641a918aa5f 100644 (file)
@@ -47,33 +47,26 @@ static void FUNC( ARGS,
 
    case PIPE_PRIM_TRIANGLES:
       for (i = 0; i+2 < count; i += 3) {
-         if (draw->rasterizer->flatshade_first) {
-            /* put provoking vertex in last pos for clipper */
-            TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
-                      (i + 1),
-                      (i + 2),
-                      (i + 0 ));
-         }
-         else {
-            TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
-                      (i + 0),
-                      (i + 1),
-                      (i + 2 ));
-         }
+         TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+                   (i + 0),
+                   (i + 1),
+                   (i + 2 ));
       }
       break;
 
    case PIPE_PRIM_TRIANGLE_STRIP:
       if (flatfirst) {
          for (i = 0; i+2 < count; i++) {
+            /* Emit first triangle vertex as first triangle vertex */
             TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+                      (i + 0),
                       (i + 1 + (i&1)),
-                      (i + 2 - (i&1)),
-                      (i + 0) );
+                      (i + 2 - (i&1)) );
          }
       }
       else {
          for (i = 0; i+2 < count; i++) {
+            /* Emit last triangle vertex as last triangle vertex */
             TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
                       (i + 0 + (i&1)),
                       (i + 1 - (i&1)),
@@ -87,9 +80,9 @@ static void FUNC( ARGS,
          if (flatfirst) {
             for (i = 0; i+2 < count; i++) {
                TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+                         (i + 1),
                          (i + 2),
-                         0,
-                         (i + 1) );
+                         0 );
             }
          }
          else {
@@ -105,44 +98,52 @@ static void FUNC( ARGS,
 
 
    case PIPE_PRIM_QUADS:
+      /* GL quads don't follow provoking vertex convention */
       if (flatfirst) {
          for (i = 0; i+3 < count; i += 4) {
-            QUAD( (i + 1),
-                  (i + 2),
-                  (i + 3),
-                  (i + 0) );
+            /* emit last quad vertex as first triangle vertex */
+            QUAD_FIRST_PV( (i + 3),
+                           (i + 0),
+                           (i + 1),
+                           (i + 2) );
          }
       }
       else {
          for (i = 0; i+3 < count; i += 4) {
-            QUAD( (i + 0),
-                  (i + 1),
-                  (i + 2),
-                  (i + 3));
+            /* emit last quad vertex as last triangle vertex */
+            QUAD_LAST_PV( (i + 0),
+                          (i + 1),
+                          (i + 2),
+                          (i + 3) );
          }
       }
       break;
 
    case PIPE_PRIM_QUAD_STRIP:
+      /* GL quad strips don't follow provoking vertex convention */
       if (flatfirst) {
          for (i = 0; i+3 < count; i += 2) {
-            QUAD( (i + 1),
-                  (i + 3),
-                  (i + 2),
-                  (i + 0) );
+            /* emit last quad vertex as first triangle vertex */
+            QUAD_FIRST_PV( (i + 3),
+                           (i + 2),
+                           (i + 0),
+                           (i + 1) );
+
          }
       }
       else {
          for (i = 0; i+3 < count; i += 2) {
-            QUAD( (i + 2),
-                  (i + 0),
-                  (i + 1),
-                  (i + 3));
+            /* emit last quad vertex as last triangle vertex */
+            QUAD_LAST_PV( (i + 2),
+                          (i + 0),
+                          (i + 1),
+                          (i + 3) );
          }
       }
       break;
 
    case PIPE_PRIM_POLYGON:
+      /* GL polygons don't follow provoking vertex convention */
       {
          /* These bitflags look a little odd because we submit the
           * vertices as (1,2,0) to satisfy flatshade requirements.
@@ -158,10 +159,20 @@ static void FUNC( ARGS,
             if (i + 3 == count)
                flags |= edge_last;
 
-           TRIANGLE( flags,
-                      (i + 1),
-                      (i + 2),
-                      (0));
+            if (flatfirst) {
+               /* emit first polygon vertex as first triangle vertex */
+               TRIANGLE( flags,
+                         (0),
+                         (i + 1),
+                         (i + 2) );
+            }
+            else {
+               /* emit first polygon vertex as last triangle vertex */
+               TRIANGLE( flags,
+                         (i + 1),
+                         (i + 2),
+                         (0));
+            }
         }
       }
       break;
@@ -176,7 +187,8 @@ static void FUNC( ARGS,
 
 
 #undef TRIANGLE
-#undef QUAD
+#undef QUAD_FIRST_PV
+#undef QUAD_LAST_PV
 #undef POINT
 #undef LINE
 #undef FUNC