translate: Move loop variable declaration outside for loop.
[mesa.git] / src / gallium / auxiliary / indices / u_indices_gen.py
index 397eea306b21c2abeb9246f3e3b52c916af995b6..af63d099302a411049fb35e455069a4c7a606a41 100644 (file)
@@ -72,7 +72,7 @@ def prolog():
 #include "indices/u_indices.h"
 #include "indices/u_indices_priv.h"
 #include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
 #include "pipe/p_defines.h"
 #include "util/u_memory.h"
 
@@ -139,6 +139,9 @@ def do_tri( intype, outtype, ptr, v0, v1, v2, inpv, outpv ):
         else:
             tri( intype, outtype, ptr, v2, v0, v1 )
 
+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):
     if intype == GENERATE:
@@ -154,7 +157,7 @@ def preamble(intype, outtype, inpv, outpv, prim):
     print '    void *_out )'
     print '{'
     if intype != GENERATE:
-        print '  const ' + intype + '*in = (const ' + intype + '*)in;'
+        print '  const ' + intype + '*in = (const ' + intype + '*)_in;'
     print '  ' + outtype + ' *out = (' + outtype + '*)_out;'
     print '  unsigned i, j;'
     print '  (void)j;'
@@ -234,8 +237,7 @@ def polygon(intype, outtype, inpv, outpv):
 def quads(intype, outtype, inpv, outpv):
     preamble(intype, outtype, inpv, outpv, prim='quads')
     print '  for (j = i = 0; j < nr; j+=6, i+=4) { '
-    do_tri( intype, outtype, 'out+j+0',  'i+0', 'i+1', 'i+3', inpv, outpv );
-    do_tri( intype, outtype, 'out+j+3',  'i+1', 'i+2', 'i+3', inpv, outpv );
+    do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv );
     print '   }'
     postamble()
 
@@ -243,8 +245,7 @@ def quads(intype, outtype, inpv, outpv):
 def quadstrip(intype, outtype, inpv, outpv):
     preamble(intype, outtype, inpv, outpv, prim='quadstrip')
     print '  for (j = i = 0; j < nr; j+=6, i+=2) { '
-    do_tri( intype, outtype, 'out+j+0',  'i+0', 'i+1', 'i+3', inpv, outpv );
-    do_tri( intype, outtype, 'out+j+3',  'i+1', 'i+2', 'i+3', inpv, outpv );
+    do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3', inpv, outpv );
     print '   }'
     postamble()