nv50: clear buffer status on all vertex bufs, not just the first one
[mesa.git] / src / gallium / auxiliary / indices / u_unfilled_indices.c
index 26c5d4d4c72cad1fc664658973dab87a7f2a4563..121877a60fbb2bff2f20e1b8b5a4a0a9a63d41b9 100644 (file)
 
 
 static void translate_ubyte_ushort( const void *in,
-                                    unsigned nr,
+                                    unsigned start,
+                                    unsigned in_nr,
+                                    unsigned out_nr,
+                                    unsigned restart_index,
                                     void *out )
 {
    const ubyte *in_ub = (const ubyte *)in;
    ushort *out_us = (ushort *)out;
    unsigned i;
-   for (i = 0; i < nr; i++)
-      out_us[i] = (ushort) in_ub[i];
+   for (i = 0; i < out_nr; i++)
+      out_us[i] = (ushort) in_ub[i+start];
 }
 
 static void translate_memcpy_ushort( const void *in,
-                                     unsigned nr,
+                                     unsigned start,
+                                     unsigned in_nr,
+                                     unsigned out_nr,
+                                     unsigned restart_index,
                                      void *out )
 {
-   memcpy(out, in, nr*sizeof(short));
+   memcpy(out, &((short *)in)[start], out_nr*sizeof(short));
 }
                               
 static void translate_memcpy_uint( const void *in,
-                                   unsigned nr,
+                                   unsigned start,
+                                   unsigned in_nr,
+                                   unsigned out_nr,
+                                   unsigned restart_index,
                                    void *out )
 {
-   memcpy(out, in, nr*sizeof(int));
+   memcpy(out, &((int *)in)[start], out_nr*sizeof(int));
 }
 
 
-static void generate_linear_ushort( unsigned nr,
+static void generate_linear_ushort( unsigned start,
+                                    unsigned nr,
                                     void *out )
 {
    ushort *out_us = (ushort *)out;
    unsigned i;
    for (i = 0; i < nr; i++)
-      out_us[i] = (ushort) i;
+      out_us[i] = (ushort)(i + start);
 }
                               
-static void generate_linear_uint( unsigned nr,
+static void generate_linear_uint( unsigned start,
+                                  unsigned nr,
                                   void *out )
 {
    unsigned *out_ui = (unsigned *)out;
    unsigned i;
    for (i = 0; i < nr; i++)
-      out_ui[i] = i;
+      out_ui[i] = i + start;
 }
 
 
+/**
+ * Given a primitive type and number of vertices, return the number of vertices
+ * needed to draw the primitive with fill mode = PIPE_POLYGON_MODE_LINE using
+ * separate lines (PIPE_PRIM_LINES).
+ */
 static unsigned nr_lines( unsigned prim,
                           unsigned nr )
 {
@@ -86,7 +102,7 @@ static unsigned nr_lines( unsigned prim,
    case PIPE_PRIM_QUAD_STRIP:
       return (nr - 2) / 2 * 8;
    case PIPE_PRIM_POLYGON:
-      return (nr - 2) * 6;
+      return 2 * nr; /* a line (two verts) for each polygon edge */
    default:
       assert(0);
       return 0;
@@ -146,7 +162,14 @@ int u_unfilled_translator( unsigned prim,
 }
 
 
-
+/**
+ * Utility for converting unfilled polygons into points, lines, triangles.
+ * Few drivers have direct support for OpenGL's glPolygonMode.
+ * This function helps with converting triangles into points or lines
+ * when the front and back fill modes are the same.  When there's
+ * different front/back fill modes, that can be handled with the
+ * 'draw' module.
+ */
 int u_unfilled_generator( unsigned prim,
                           unsigned start,
                           unsigned nr,