draw_pt_varray_tmp_linear.h

Go to the documentation of this file.
00001 static unsigned trim( unsigned count, unsigned first, unsigned incr )
00002 {
00003    return count - (count - first) % incr; 
00004 }
00005 
00006 static void FUNC(struct draw_pt_front_end *frontend,
00007                  pt_elt_func get_elt,
00008                  const void *elts,
00009                  unsigned count)
00010 {
00011    struct varray_frontend *varray = (struct varray_frontend *)frontend;
00012    unsigned start = (unsigned) ((char *) elts - (char *) NULL);
00013 
00014    unsigned j;
00015    unsigned first, incr;
00016 
00017    draw_pt_split_prim(varray->input_prim, &first, &incr);
00018    
00019    /* Sanitize primitive length:
00020     */
00021    count = trim(count, first, incr); 
00022    if (count < first)
00023       return;
00024 
00025 #if 0
00026    debug_printf("%s (%d) %d/%d\n", __FUNCTION__,
00027                 varray->input_prim,
00028                 start, count);
00029 #endif
00030 
00031    switch (varray->input_prim) {
00032    case PIPE_PRIM_POINTS:
00033    case PIPE_PRIM_LINES:
00034    case PIPE_PRIM_TRIANGLES:
00035    case PIPE_PRIM_LINE_STRIP:
00036    case PIPE_PRIM_TRIANGLE_STRIP:
00037    case PIPE_PRIM_QUADS:
00038    case PIPE_PRIM_QUAD_STRIP:
00039       for (j = 0; j < count;) {
00040          unsigned remaining = count - j;
00041          unsigned nr = trim( MIN2(varray->driver_fetch_max, remaining), first, incr );
00042          varray_flush_linear(varray, start + j, nr);
00043          j += nr;
00044          if (nr != remaining) 
00045             j -= (first - incr);
00046       }
00047       break;
00048 
00049    case PIPE_PRIM_LINE_LOOP:
00050       /* Always have to decompose as we've stated that this will be
00051        * emitted as a line-strip.
00052        */
00053       for (j = 0; j < count;) {
00054          unsigned remaining = count - j;
00055          unsigned nr = trim( MIN2(varray->fetch_max-1, remaining), first, incr );
00056          varray_line_loop_segment(varray, start, j, nr, nr == remaining);
00057          j += nr;
00058          if (nr != remaining) 
00059             j -= (first - incr);
00060       }
00061       break;
00062 
00063 
00064    case PIPE_PRIM_POLYGON:
00065    case PIPE_PRIM_TRIANGLE_FAN: 
00066       if (count < varray->driver_fetch_max) {
00067          varray_flush_linear(varray, start, count);
00068       }
00069       else {
00070          for ( j = 0; j < count;) {
00071             unsigned remaining = count - j;
00072             unsigned nr = trim( MIN2(varray->fetch_max-1, remaining), first, incr );
00073             varray_fan_segment(varray, start, j, nr);
00074             j += nr;
00075             if (nr != remaining) 
00076                j -= (first - incr);
00077          }
00078       }
00079       break;
00080 
00081    default:
00082       assert(0);
00083       break;
00084    }
00085 }
00086 
00087 #undef TRIANGLE
00088 #undef QUAD
00089 #undef POINT
00090 #undef LINE
00091 #undef FUNC

Generated on Tue Sep 29 06:25:14 2009 for Gallium3D by  doxygen 1.5.4