u_primconvert: add primitive restart support
authorDave Airlie <airlied@gmail.com>
Wed, 18 Mar 2015 01:46:45 +0000 (11:46 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 19 Mar 2015 23:46:30 +0000 (09:46 +1000)
This add primitive restart support to the prim conversion.

This involves changing the API for the translate functions
as we need to pass the prim restart index and the original
number of indices into the translate functions.

primitive restart is support for quads, quad strips
and polygons.

This deal with the case where the actual number of output
primitives is less than the initially calculated number,
by filling the rest of the output primitives with the restart
index, the other option is to reduce the output prim number,
but that will make the generator code a bit messier.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/auxiliary/indices/u_indices.c
src/gallium/auxiliary/indices/u_indices.h
src/gallium/auxiliary/indices/u_indices_gen.py
src/gallium/auxiliary/indices/u_primconvert.c
src/gallium/auxiliary/indices/u_unfilled_gen.py
src/gallium/auxiliary/indices/u_unfilled_indices.c
src/gallium/drivers/svga/svga_draw_elements.c

index 1b33f413fc4f05b6ff26e0b1c8a19de1f28105b5..c25594b4b7a0f77dcf2a9acf0e291e0d4da3c2d4 100644 (file)
 
 static void translate_memcpy_ushort( const void *in,
                                      unsigned start,
-                                     unsigned nr,
+                                     unsigned in_nr,
+                                     unsigned out_nr,
+                                     unsigned restart_index,
                                      void *out )
 {
-   memcpy(out, &((short *)in)[start], nr*sizeof(short));
+   memcpy(out, &((short *)in)[start], out_nr*sizeof(short));
 }
                               
 static void translate_memcpy_uint( const void *in,
                                    unsigned start,
-                                   unsigned nr,
+                                   unsigned in_nr,
+                                   unsigned out_nr,
+                                   unsigned restart_index,
                                    void *out )
 {
-   memcpy(out, &((int *)in)[start], nr*sizeof(int));
+   memcpy(out, &((int *)in)[start], out_nr*sizeof(int));
 }
                               
 
@@ -58,6 +62,7 @@ static void translate_memcpy_uint( const void *in,
  * \param nr  number of incoming vertices
  * \param in_pv  incoming provoking vertex convention (PV_FIRST or PV_LAST)
  * \param out_pv  desired provoking vertex convention (PV_FIRST or PV_LAST)
+ * \param prim_restart  whether primitive restart is disable or enabled
  * \param out_prim  returns new PIPE_PRIM_x we'll translate to
  * \param out_index_size  returns bytes per new index value (2 or 4)
  * \param out_nr  returns number of new vertices
@@ -69,6 +74,7 @@ int u_index_translator( unsigned hw_mask,
                         unsigned nr,
                         unsigned in_pv,
                         unsigned out_pv,
+                        unsigned prim_restart,
                         unsigned *out_prim,
                         unsigned *out_index_size,
                         unsigned *out_nr,
@@ -106,68 +112,68 @@ int u_index_translator( unsigned hw_mask,
    else {
       switch (prim) {
       case PIPE_PRIM_POINTS:
-         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
+         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
          *out_prim = PIPE_PRIM_POINTS;
          *out_nr = nr;
          break;
 
       case PIPE_PRIM_LINES:
-         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
+         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
          *out_prim = PIPE_PRIM_LINES;
          *out_nr = nr;
          break;
 
       case PIPE_PRIM_LINE_STRIP:
-         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
+         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
          *out_prim = PIPE_PRIM_LINES;
          *out_nr = (nr - 1) * 2;
          break;
 
       case PIPE_PRIM_LINE_LOOP:
-         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
+         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
          *out_prim = PIPE_PRIM_LINES;
          *out_nr = nr * 2;
          break;
 
       case PIPE_PRIM_TRIANGLES:
-         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
+         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
          *out_prim = PIPE_PRIM_TRIANGLES;
          *out_nr = nr;
          break;
 
       case PIPE_PRIM_TRIANGLE_STRIP:
-         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
+         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
          *out_prim = PIPE_PRIM_TRIANGLES;
          *out_nr = (nr - 2) * 3;
          break;
 
       case PIPE_PRIM_TRIANGLE_FAN:
-         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
+         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
          *out_prim = PIPE_PRIM_TRIANGLES;
          *out_nr = (nr - 2) * 3;
          break;
 
       case PIPE_PRIM_QUADS:
-         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
+         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
          *out_prim = PIPE_PRIM_TRIANGLES;
          *out_nr = (nr / 4) * 6;
          break;
 
       case PIPE_PRIM_QUAD_STRIP:
-         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
+         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
          *out_prim = PIPE_PRIM_TRIANGLES;
          *out_nr = (nr - 2) * 3;
          break;
 
       case PIPE_PRIM_POLYGON:
-         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
+         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
          *out_prim = PIPE_PRIM_TRIANGLES;
          *out_nr = (nr - 2) * 3;
          break;
 
       default:
          assert(0);
-         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
+         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim_restart][prim];
          *out_prim = PIPE_PRIM_POINTS;
          *out_nr = nr;
          return U_TRANSLATE_ERROR;
index 54cd9441abce4e066652eef36f1bf98841e44dd8..e01201e4b04460456773c901a6dbafa855d8bcb0 100644 (file)
 #define PV_LAST       1
 #define PV_COUNT      2
 
+/* primitive restart disable/enable flags */
+#define PR_DISABLE 0
+#define PR_ENABLE 1
+#define PR_COUNT 2
 /**
  * Index translator function (for glDrawElements() case)
  *
@@ -42,7 +46,9 @@
  */
 typedef void (*u_translate_func)( const void *in,
                                   unsigned start,
-                                  unsigned nr,
+                                  unsigned in_nr,
+                                  unsigned out_nr,
+                                  unsigned restart_index,
                                   void *out );
 
 /**
@@ -77,6 +83,7 @@ int u_index_translator( unsigned hw_mask,
                         unsigned nr,
                         unsigned in_pv,   /* API */
                         unsigned out_pv,  /* hardware */
+                        unsigned prim_restart,
                         unsigned *out_prim,
                         unsigned *out_index_size,
                         unsigned *out_nr,
index f05b70a67e30978d69b43753c6321b88cb7844ef..687a717db9a43a8add8c5f31934bcb6b668df5b4 100644 (file)
@@ -27,10 +27,12 @@ copyright = '''
 
 GENERATE, UBYTE, USHORT, UINT = 'generate', 'ubyte', 'ushort', 'uint'
 FIRST, LAST = 'first', 'last'
+PRDISABLE, PRENABLE = 'prdisable', 'prenable'
 
 INTYPES = (GENERATE, UBYTE, USHORT, UINT)
 OUTTYPES = (USHORT, UINT)
 PVS=(FIRST, LAST)
+PRS=(PRDISABLE, PRENABLE)
 PRIMS=('points', 
        'lines', 
        'linestrip', 
@@ -57,7 +59,7 @@ longprim = dict(zip(PRIMS, LONGPRIMS))
 intype_idx = dict(ubyte='IN_UBYTE', ushort='IN_USHORT', uint='IN_UINT')
 outtype_idx = dict(ushort='OUT_USHORT', uint='OUT_UINT')
 pv_idx = dict(first='PV_FIRST', last='PV_LAST')
-
+pr_idx = dict(prdisable='PR_DISABLE', prenable='PR_ENABLE')
 
 def prolog():
     print '''/* File automatically generated by indices.py */'''
@@ -97,7 +99,7 @@ static unsigned in_size_idx( unsigned index_size )
 }
 
 
-static u_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];
+static u_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PR_COUNT][PRIM_COUNT];
 static u_generate_func  generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];
 
 
@@ -143,18 +145,22 @@ def do_quad( intype, outtype, ptr, v0, v1, v2, v3, inpv, outpv ):
     do_tri( intype, outtype, ptr+'+0',  v0, v1, v3, inpv, outpv );
     do_tri( intype, outtype, ptr+'+3',  v1, v2, v3, inpv, outpv );
 
-def name(intype, outtype, inpv, outpv, prim):
+def name(intype, outtype, inpv, outpv, pr, prim):
     if intype == GENERATE:
         return 'generate_' + prim + '_' + outtype + '_' + inpv + '2' + outpv
     else:
-        return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv
+        return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv + '_' + pr
 
-def preamble(intype, outtype, inpv, outpv, prim):
-    print 'static void ' + name( intype, outtype, inpv, outpv, prim ) + '('
+def preamble(intype, outtype, inpv, outpv, pr, prim):
+    print 'static void ' + name( intype, outtype, inpv, outpv, pr, prim ) + '('
     if intype != GENERATE:
         print '    const void * _in,'
     print '    unsigned start,'
-    print '    unsigned nr,'
+    if intype != GENERATE:
+        print '    unsigned in_nr,'
+    print '    unsigned out_nr,'
+    if intype != GENERATE:
+        print '    unsigned restart_index,'
     print '    void *_out )'
     print '{'
     if intype != GENERATE:
@@ -167,46 +173,46 @@ def postamble():
     print '}'
 
 
-def points(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='points')
-    print '  for (i = start; i < (nr+start); i++) { '
+def points(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='points')
+    print '  for (i = start; i < (out_nr+start); i++) { '
     do_point( intype, outtype, 'out+i',  'i' );
     print '   }'
     postamble()
 
-def lines(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='lines')
-    print '  for (i = start; i < (nr+start); i+=2) { '
+def lines(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='lines')
+    print '  for (i = start; i < (out_nr+start); i+=2) { '
     do_line( intype, outtype, 'out+i',  'i', 'i+1', inpv, outpv );
     print '   }'
     postamble()
 
-def linestrip(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='linestrip')
-    print '  for (i = start, j = 0; j < nr; j+=2, i++) { '
+def linestrip(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='linestrip')
+    print '  for (i = start, j = 0; j < out_nr; j+=2, i++) { '
     do_line( intype, outtype, 'out+j',  'i', 'i+1', inpv, outpv );
     print '   }'
     postamble()
 
-def lineloop(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='lineloop')
-    print '  for (i = start, j = 0; j < nr - 2; j+=2, i++) { '
+def lineloop(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='lineloop')
+    print '  for (i = start, j = 0; j < out_nr - 2; j+=2, i++) { '
     do_line( intype, outtype, 'out+j',  'i', 'i+1', inpv, outpv );
     print '   }'
     do_line( intype, outtype, 'out+j',  'i', 'start', inpv, outpv );
     postamble()
 
-def tris(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='tris')
-    print '  for (i = start; i < (nr+start); i+=3) { '
+def tris(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='tris')
+    print '  for (i = start; i < (out_nr+start); i+=3) { '
     do_tri( intype, outtype, 'out+i',  'i', 'i+1', 'i+2', inpv, outpv );
     print '   }'
     postamble()
 
 
-def tristrip(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='tristrip')
-    print '  for (i = start, j = 0; j < nr; j+=3, i++) { '
+def tristrip(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='tristrip')
+    print '  for (i = start, j = 0; j < out_nr; j+=3, i++) { '
     if inpv == FIRST:
         do_tri( intype, outtype, 'out+j',  'i', 'i+1+(i&1)', 'i+2-(i&1)', inpv, outpv );
     else:
@@ -215,18 +221,42 @@ def tristrip(intype, outtype, inpv, outpv):
     postamble()
 
 
-def trifan(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='trifan')
-    print '  for (i = start, j = 0; j < nr; j+=3, i++) { '
+def trifan(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='trifan')
+    print '  for (i = start, j = 0; j < out_nr; j+=3, i++) { '
     do_tri( intype, outtype, 'out+j',  'start', 'i+1', 'i+2', inpv, outpv );
     print '   }'
     postamble()
 
 
 
-def polygon(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='polygon')
-    print '  for (i = start, j = 0; j < nr; j+=3, i++) { '
+def polygon(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='polygon')
+    print '  for (i = start, j = 0; j < out_nr; j+=3, i++) { '
+    if pr == PRENABLE:
+        print 'restart:'
+        print '      if (i + 3 > in_nr) {'
+        print '         (out+j+0)[0] = restart_index;'
+        print '         (out+j+0)[1] = restart_index;'
+        print '         (out+j+0)[2] = restart_index;'
+        print '         continue;'
+        print '      }'
+        print '      if (in[i + 0] == restart_index) {'
+        print '         i += 1;'
+        print '         start = i;'
+        print '         goto restart;'
+        print '      }'
+        print '      if (in[i + 1] == restart_index) {'
+        print '         i += 2;'
+        print '         start = i;'
+        print '         goto restart;'
+        print '      }'
+        print '      if (in[i + 2] == restart_index) {'
+        print '         i += 3;'
+        print '         start = i;'
+        print '         goto restart;'
+        print '      }'
+
     if inpv == FIRST:
         do_tri( intype, outtype, 'out+j',  'start', 'i+1', 'i+2', inpv, outpv );
     else:
@@ -235,17 +265,72 @@ def polygon(intype, outtype, inpv, outpv):
     postamble()
 
 
-def quads(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='quads')
-    print '  for (i = start, j = 0; j < nr; j+=6, i+=4) { '
+def quads(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='quads')
+    print '  for (i = start, j = 0; j < out_nr; j+=6, i+=4) { '
+    if pr == PRENABLE:
+        print 'restart:'
+        print '      if (i + 4 > in_nr) {'
+        print '         (out+j+0)[0] = restart_index;'
+        print '         (out+j+0)[1] = restart_index;'
+        print '         (out+j+0)[2] = restart_index;'
+        print '         (out+j+3)[0] = restart_index;'
+        print '         (out+j+3)[1] = restart_index;'
+        print '         (out+j+3)[2] = restart_index;'
+        print '         continue;'
+        print '      }'
+        print '      if (in[i + 0] == restart_index) {'
+        print '         i += 1;'
+        print '         goto restart;'
+        print '      }'
+        print '      if (in[i + 1] == restart_index) {'
+        print '         i += 2;'
+        print '         goto restart;'
+        print '      }'
+        print '      if (in[i + 2] == restart_index) {'
+        print '         i += 3;'
+        print '         goto restart;'
+        print '      }'
+        print '      if (in[i + 3] == restart_index) {'
+        print '         i += 4;'
+        print '         goto restart;'
+        print '      }'
+
     do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv );
     print '   }'
     postamble()
 
 
-def quadstrip(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='quadstrip')
-    print '  for (i = start, j = 0; j < nr; j+=6, i+=2) { '
+def quadstrip(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='quadstrip')
+    print '  for (i = start, j = 0; j < out_nr; j+=6, i+=2) { '
+    if pr == PRENABLE:
+        print 'restart:'
+        print '      if (i + 4 > in_nr) {'
+        print '         (out+j+0)[0] = restart_index;'
+        print '         (out+j+0)[1] = restart_index;'
+        print '         (out+j+0)[2] = restart_index;'
+        print '         (out+j+3)[0] = restart_index;'
+        print '         (out+j+3)[1] = restart_index;'
+        print '         (out+j+3)[2] = restart_index;'
+        print '         continue;'
+        print '      }'
+        print '      if (in[i + 0] == restart_index) {'
+        print '         i += 1;'
+        print '         goto restart;'
+        print '      }'
+        print '      if (in[i + 1] == restart_index) {'
+        print '         i += 2;'
+        print '         goto restart;'
+        print '      }'
+        print '      if (in[i + 2] == restart_index) {'
+        print '         i += 3;'
+        print '         goto restart;'
+        print '      }'
+        print '      if (in[i + 3] == restart_index) {'
+        print '         i += 4;'
+        print '         goto restart;'
+        print '      }'
     do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3', inpv, outpv );
     print '   }'
     postamble()
@@ -256,33 +341,37 @@ def emit_funcs():
         for outtype in OUTTYPES:
             for inpv in (FIRST, LAST):
                 for outpv in (FIRST, LAST):
-                    points(intype, outtype, inpv, outpv)
-                    lines(intype, outtype, inpv, outpv)
-                    linestrip(intype, outtype, inpv, outpv)
-                    lineloop(intype, outtype, inpv, outpv)
-                    tris(intype, outtype, inpv, outpv)
-                    tristrip(intype, outtype, inpv, outpv)
-                    trifan(intype, outtype, inpv, outpv)
-                    quads(intype, outtype, inpv, outpv)
-                    quadstrip(intype, outtype, inpv, outpv)
-                    polygon(intype, outtype, inpv, outpv)
-
-def init(intype, outtype, inpv, outpv, prim):
+                    for pr in (PRDISABLE, PRENABLE):
+                        if pr == PRENABLE and intype == GENERATE:
+                            continue
+                        points(intype, outtype, inpv, outpv, pr)
+                        lines(intype, outtype, inpv, outpv, pr)
+                        linestrip(intype, outtype, inpv, outpv, pr)
+                        lineloop(intype, outtype, inpv, outpv, pr)
+                        tris(intype, outtype, inpv, outpv, pr)
+                        tristrip(intype, outtype, inpv, outpv, pr)
+                        trifan(intype, outtype, inpv, outpv, pr)
+                        quads(intype, outtype, inpv, outpv, pr)
+                        quadstrip(intype, outtype, inpv, outpv, pr)
+                        polygon(intype, outtype, inpv, outpv, pr)
+
+def init(intype, outtype, inpv, outpv, pr, prim):
     if intype == GENERATE:
         print ('generate[' + 
                outtype_idx[outtype] + 
                '][' + pv_idx[inpv] + 
                '][' + pv_idx[outpv] + 
                '][' + longprim[prim] + 
-               '] = ' + name( intype, outtype, inpv, outpv, prim ) + ';')
+               '] = ' + name( intype, outtype, inpv, outpv, pr, prim ) + ';')
     else:
         print ('translate[' + 
                intype_idx[intype] + 
                '][' + outtype_idx[outtype] + 
                '][' + pv_idx[inpv] + 
-               '][' + pv_idx[outpv] + 
+               '][' + pv_idx[outpv] +
+               '][' + pr_idx[pr] + 
                '][' + longprim[prim] + 
-               '] = ' + name( intype, outtype, inpv, outpv, prim ) + ';')
+               '] = ' + name( intype, outtype, inpv, outpv, pr, prim ) + ';')
 
 
 def emit_all_inits():
@@ -290,8 +379,9 @@ def emit_all_inits():
         for outtype in OUTTYPES:
             for inpv in PVS:
                 for outpv in PVS:
-                    for prim in PRIMS:
-                        init(intype, outtype, inpv, outpv, prim)
+                    for pr in PRS:
+                        for prim in PRIMS:
+                            init(intype, outtype, inpv, outpv, pr, prim)
 
 def emit_init():
     print 'void u_index_init( void )'
index cebb81842d10781cc78e7fc871170186b5b5c041..00e65aaea31585e842613c0a2f2d76b9b3d925c9 100644 (file)
@@ -129,11 +129,13 @@ util_primconvert_draw_vbo(struct primconvert_context *pc,
    new_info.index_bias = info->index_bias;
    new_info.start_instance = info->start_instance;
    new_info.instance_count = info->instance_count;
-
+   new_info.primitive_restart = info->primitive_restart;
+   new_info.restart_index = info->restart_index;
    if (info->indexed) {
       u_index_translator(pc->primtypes_mask,
                          info->mode, pc->saved_ib.index_size, info->count,
                          pc->api_pv, pc->api_pv,
+                         info->primitive_restart ? PR_ENABLE : PR_DISABLE,
                          &new_info.mode, &new_ib.index_size, &new_info.count,
                          &trans_func);
       src = ib->user_buffer;
@@ -159,7 +161,7 @@ util_primconvert_draw_vbo(struct primconvert_context *pc,
                   &new_ib.offset, &new_ib.buffer, &dst);
 
    if (info->indexed) {
-      trans_func(src, info->start, new_info.count, dst);
+      trans_func(src, info->start, info->count, new_info.count, info->restart_index, dst);
    }
    else {
       gen_func(info->start, new_info.count, dst);
index 88649724521f928561f199547dba826ebfcd1729..873e78173c5b6dd512215d7b9f68aeae61b7c74e 100644 (file)
@@ -128,7 +128,11 @@ def preamble(intype, outtype, prim):
     if intype != GENERATE:
         print '    const void * _in,'
     print '    unsigned start,'
-    print '    unsigned nr,'
+    if intype != GENERATE:
+        print '    unsigned in_nr,'
+    print '    unsigned out_nr,'
+    if intype != GENERATE:
+        print '    unsigned restart_index,'
     print '    void *_out )'
     print '{'
     if intype != GENERATE:
@@ -143,7 +147,7 @@ def postamble():
 
 def tris(intype, outtype):
     preamble(intype, outtype, prim='tris')
-    print '  for (i = start, j = 0; j < nr; j+=6, i+=3) { '
+    print '  for (i = start, j = 0; j < out_nr; j+=6, i+=3) { '
     do_tri( intype, outtype, 'out+j',  'i', 'i+1', 'i+2' );
     print '   }'
     postamble()
@@ -151,7 +155,7 @@ def tris(intype, outtype):
 
 def tristrip(intype, outtype):
     preamble(intype, outtype, prim='tristrip')
-    print '  for (i = start, j = 0; j < nr; j+=6, i++) { '
+    print '  for (i = start, j = 0; j < out_nr; j+=6, i++) { '
     do_tri( intype, outtype, 'out+j',  'i', 'i+1/*+(i&1)*/', 'i+2/*-(i&1)*/' );
     print '   }'
     postamble()
@@ -159,7 +163,7 @@ def tristrip(intype, outtype):
 
 def trifan(intype, outtype):
     preamble(intype, outtype, prim='trifan')
-    print '  for (i = start, j = 0; j < nr; j+=6, i++) { '
+    print '  for (i = start, j = 0; j < out_nr; j+=6, i++) { '
     do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+2' );
     print '   }'
     postamble()
@@ -168,15 +172,15 @@ def trifan(intype, outtype):
 
 def polygon(intype, outtype):
     preamble(intype, outtype, prim='polygon')
-    print '  for (i = start, j = 0; j < nr; j+=2, i++) { '
-    line( intype, outtype, 'out+j', 'i', '(i+1)%(nr/2)' )
+    print '  for (i = start, j = 0; j < out_nr; j+=2, i++) { '
+    line( intype, outtype, 'out+j', 'i', '(i+1)%(out_nr/2)' )
     print '   }'
     postamble()
 
 
 def quads(intype, outtype):
     preamble(intype, outtype, prim='quads')
-    print '  for (i = start, j = 0; j < nr; j+=8, i+=4) { '
+    print '  for (i = start, j = 0; j < out_nr; j+=8, i+=4) { '
     do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3' );
     print '   }'
     postamble()
@@ -184,7 +188,7 @@ def quads(intype, outtype):
 
 def quadstrip(intype, outtype):
     preamble(intype, outtype, prim='quadstrip')
-    print '  for (i = start, j = 0; j < nr; j+=8, i+=2) { '
+    print '  for (i = start, j = 0; j < out_nr; j+=8, i+=2) { '
     do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3' );
     print '   }'
     postamble()
index 7a74c39135edac33d2976ce015bd7e720573338d..121877a60fbb2bff2f20e1b8b5a4a0a9a63d41b9 100644 (file)
 
 static void translate_ubyte_ushort( const void *in,
                                     unsigned start,
-                                    unsigned nr,
+                                    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++)
+   for (i = 0; i < out_nr; i++)
       out_us[i] = (ushort) in_ub[i+start];
 }
 
 static void translate_memcpy_ushort( const void *in,
                                      unsigned start,
-                                     unsigned nr,
+                                     unsigned in_nr,
+                                     unsigned out_nr,
+                                     unsigned restart_index,
                                      void *out )
 {
-   memcpy(out, &((short *)in)[start], nr*sizeof(short));
+   memcpy(out, &((short *)in)[start], out_nr*sizeof(short));
 }
                               
 static void translate_memcpy_uint( const void *in,
                                    unsigned start,
-                                   unsigned nr,
+                                   unsigned in_nr,
+                                   unsigned out_nr,
+                                   unsigned restart_index,
                                    void *out )
 {
-   memcpy(out, &((int *)in)[start], nr*sizeof(int));
+   memcpy(out, &((int *)in)[start], out_nr*sizeof(int));
 }
 
 
index 3384095e6f5f95fe11c803a677940e8846ece8b3..038500a35bde9b60f58e027dc649f72359c6b273 100644 (file)
@@ -70,7 +70,7 @@ translate_indices(struct svga_hwtnl *hwtnl, struct pipe_resource *src,
    if (dst_map == NULL)
       goto fail;
 
-   translate((const char *) src_map + offset, 0, nr, dst_map);
+   translate((const char *) src_map + offset, 0, 0, nr, 0, dst_map);
 
    pipe_buffer_unmap(pipe, src_transfer);
    pipe_buffer_unmap(pipe, dst_transfer);
@@ -153,6 +153,7 @@ svga_hwtnl_draw_range_elements(struct svga_hwtnl *hwtnl,
                                     count,
                                     hwtnl->api_pv,
                                     hwtnl->hw_pv,
+                                    PR_DISABLE,
                                     &gen_prim, &gen_size, &gen_nr, &gen_func);
    }