-#!/usr/bin/env python
copyright = '''
/*
* Copyright 2009 VMware, Inc.
'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')
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:
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()
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()
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()
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()
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:
quads(intype, outtype)
quadstrip(intype, outtype)
polygon(intype, outtype)
+ trisadj(intype, outtype)
+ tristripadj(intype, outtype)
def init(intype, outtype, prim):
if intype == GENERATE: