gallium: Do not add -Wframe-address option for gcc <= 4.4.
[mesa.git] / src / gallium / auxiliary / indices / u_unfilled_gen.py
index 36896ce605de62ceecc14be50d78c1dfd88892e2..4780d98383a1186fd7600056a7d1d151ea9a98ce 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 copyright = '''
 /*
  * Copyright 2009 VMware, Inc.
@@ -35,14 +34,18 @@ PRIMS=('tris',
        'tristrip', 
        'quads', 
        'quadstrip', 
-       'polygon')
+       'polygon',
+       'trisadj',
+       'tristripadj')
 
 LONGPRIMS=('PIPE_PRIM_TRIANGLES', 
            'PIPE_PRIM_TRIANGLE_FAN', 
            'PIPE_PRIM_TRIANGLE_STRIP', 
            'PIPE_PRIM_QUADS', 
            'PIPE_PRIM_QUAD_STRIP', 
-           'PIPE_PRIM_POLYGON')
+           'PIPE_PRIM_POLYGON',
+           'PIPE_PRIM_TRIANGLES_ADJACENCY',
+           'PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY')
 
 longprim = dict(zip(PRIMS, LONGPRIMS))
 intype_idx = dict(ubyte='IN_UBYTE', ushort='IN_USHORT', uint='IN_UINT')
@@ -127,7 +130,12 @@ def preamble(intype, outtype, prim):
     print 'static void ' + name( intype, outtype, prim ) + '('
     if intype != GENERATE:
         print '    const void * _in,'
-    print '    unsigned nr,'
+    print '    unsigned start,'
+    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:
@@ -142,7 +150,7 @@ def postamble():
 
 def tris(intype, outtype):
     preamble(intype, outtype, prim='tris')
-    print '  for (j = i = 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()
@@ -150,7 +158,7 @@ def tris(intype, outtype):
 
 def tristrip(intype, outtype):
     preamble(intype, outtype, prim='tristrip')
-    print '  for (j = i = 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()
@@ -158,7 +166,7 @@ def tristrip(intype, outtype):
 
 def trifan(intype, outtype):
     preamble(intype, outtype, prim='trifan')
-    print '  for (j = i = 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()
@@ -167,15 +175,15 @@ def trifan(intype, outtype):
 
 def polygon(intype, outtype):
     preamble(intype, outtype, prim='polygon')
-    print '  for (j = i = 0; j < nr; j+=6, i++) { '
-    do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+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 (j = i = 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()
@@ -183,12 +191,28 @@ def quads(intype, outtype):
 
 def quadstrip(intype, outtype):
     preamble(intype, outtype, prim='quadstrip')
-    print '  for (j = i = 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()
 
 
+def trisadj(intype, outtype):
+    preamble(intype, outtype, prim='trisadj')
+    print '  for (i = start, j = 0; j < out_nr; j+=6, i+=6) { '
+    do_tri( intype, outtype, 'out+j',  'i', 'i+2', 'i+4' );
+    print '   }'
+    postamble()
+
+
+def tristripadj(intype, outtype):
+    preamble(intype, outtype, prim='tristripadj')
+    print '  for (i = start, j = 0; j < out_nr; j+=6, i+=2) { '
+    do_tri( intype, outtype, 'out+j',  'i', 'i+2', 'i+4' );
+    print '   }'
+    postamble()
+
+
 def emit_funcs():
     for intype in INTYPES:
         for outtype in OUTTYPES:
@@ -198,6 +222,8 @@ def emit_funcs():
             quads(intype, outtype)
             quadstrip(intype, outtype)
             polygon(intype, outtype)
+            trisadj(intype, outtype)
+            tristripadj(intype, outtype)
 
 def init(intype, outtype, prim):
     if intype == GENERATE: