Merge commit 'origin/master' into gallium-0.2
[mesa.git] / src / gallium / auxiliary / draw / draw_pt_varray_tmp_linear.h
index 114ed371a06597d3776eab0ee4d6684993fa471f..55a8e6521dc4e3709a441a43b236c5f877dc0d8c 100644 (file)
@@ -11,11 +11,9 @@ static void FUNC(struct draw_pt_front_end *frontend,
    struct varray_frontend *varray = (struct varray_frontend *)frontend;
    unsigned start = (unsigned)elts;
 
-   unsigned i, j;
+   unsigned j;
    unsigned first, incr;
 
-   varray->fetch_start = start;
-
    draw_pt_split_prim(varray->input_prim, &first, &incr);
    
    /* Sanitize primitive length:
@@ -40,7 +38,7 @@ static void FUNC(struct draw_pt_front_end *frontend,
    case PIPE_PRIM_QUAD_STRIP:
       for (j = 0; j < count;) {
          unsigned remaining = count - j;
-         unsigned nr = trim( MIN2(FETCH_MAX, remaining), first, incr );
+         unsigned nr = trim( MIN2(varray->driver_fetch_max, remaining), first, incr );
          varray_flush_linear(varray, start + j, nr);
          j += nr;
          if (nr != remaining) 
@@ -49,33 +47,34 @@ static void FUNC(struct draw_pt_front_end *frontend,
       break;
 
    case PIPE_PRIM_LINE_LOOP:
-      if (count >= 2) {
-         for (j = 0; j + first <= count; j += i) {
-            unsigned end = MIN2(FETCH_MAX, count - j);
-            end -= (end % incr);
-            for (i = 1; i < end; i++) {
-               LINE(varray, i - 1, i);
-            }
-            LINE(varray, i - 1, 0);
-            i = end;
-            fetch_init(varray, end);
-            varray_flush(varray);
-         }
+      /* Always have to decompose as we've stated that this will be
+       * emitted as a line-strip.
+       */
+      for (j = 0; j < count;) {
+         unsigned remaining = count - j;
+         unsigned nr = trim( MIN2(varray->fetch_max-1, remaining), first, incr );
+         varray_line_loop_segment(varray, start, j, nr, nr == remaining);
+         j += nr;
+         if (nr != remaining) 
+            j -= (first - incr);
       }
       break;
 
 
    case PIPE_PRIM_POLYGON:
-   case PIPE_PRIM_TRIANGLE_FAN:
-      for (j = 0; j + first <= count; j += i) {
-         unsigned end = MIN2(FETCH_MAX, count - j);
-         end -= (end % incr);
-         for (i = 2; i < end; i++) {
-            TRIANGLE(varray, 0, i - 1, i);
+   case PIPE_PRIM_TRIANGLE_FAN: 
+      if (count < varray->driver_fetch_max) {
+         varray_flush_linear(varray, start, count);
+      }
+      else {
+         for ( j = 0; j < count;) {
+            unsigned remaining = count - j;
+            unsigned nr = trim( MIN2(varray->fetch_max-1, remaining), first, incr );
+            varray_fan_segment(varray, start, j, nr);
+            j += nr;
+            if (nr != remaining) 
+               j -= (first - incr);
          }
-         i = end;
-         fetch_init(varray, end);
-         varray_flush(varray);
       }
       break;
 
@@ -83,8 +82,6 @@ static void FUNC(struct draw_pt_front_end *frontend,
       assert(0);
       break;
    }
-
-   varray_flush(varray);
 }
 
 #undef TRIANGLE