Kaynağa Gözat

gallium: add new aux lib for index list translations

Could this be the ultimate index list translating utility?  Maybe, but it
doesn't yet include support for splitting primitives.

Unlike previous attempts, this captures all possible combinations of API
and hardware provoking vertex, supports generated list reuse and various
other tricks.  Relies on python-generated code.
tags/mesa_20090313
Keith Whitwell 16 yıl önce
ebeveyn
işleme
3120894c6d

+ 1
- 1
configs/default Dosyayı Görüntüle

@@ -89,7 +89,7 @@ PROGRAM_DIRS = demos redbook samples glsl xdemos
EGL_DRIVERS_DIRS = demo

# Gallium directories and
GALLIUM_AUXILIARY_DIRS = draw translate cso_cache pipebuffer tgsi sct rtasm util
GALLIUM_AUXILIARY_DIRS = draw translate cso_cache pipebuffer tgsi sct rtasm util indices
GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
GALLIUM_DRIVER_DIRS = softpipe i915simple i965simple nv04 nv10 nv20 nv30 nv40 nv50 failover trace
GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVER_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)

+ 1
- 0
src/gallium/SConscript Dosyayı Görüntüle

@@ -21,6 +21,7 @@ SConscript([
'auxiliary/translate/SConscript',
'auxiliary/draw/SConscript',
'auxiliary/pipebuffer/SConscript',
'auxiliary/indices/SConscript',
])

for driver in env['drivers']:

+ 16
- 0
src/gallium/auxiliary/indices/Makefile Dosyayı Görüntüle

@@ -0,0 +1,16 @@
TOP = ../../../..
include $(TOP)/configs/current

LIBNAME = indices

C_SOURCES = \
u_indices_gen.c

include ../../Makefile.template

u_indices_gen.c: u_indices_gen.py
python $< > $@


symlinks:


+ 17
- 0
src/gallium/auxiliary/indices/SConscript Dosyayı Görüntüle

@@ -0,0 +1,17 @@
Import('*')

env.CodeGenerate(
target = 'u_indices_gen.c',
script = 'u_indices_gen.py',
source = [],
command = 'python $SCRIPT > $TARGET'
)

indices = env.ConvenienceLibrary(
target = 'indices',
source = [
# 'u_indices.c',
'u_indices_gen.c',
])

auxiliaries.insert(0, indices)

+ 253
- 0
src/gallium/auxiliary/indices/u_indices.c Dosyayı Görüntüle

@@ -0,0 +1,253 @@
/*
* Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "u_indices.h"
#include "u_indices_priv.h"

static void translate_memcpy_ushort( const void *in,
unsigned nr,
void *out )
{
memcpy(out, in, nr*sizeof(short));
}
static void translate_memcpy_uint( const void *in,
unsigned nr,
void *out )
{
memcpy(out, in, nr*sizeof(int));
}

int u_index_translator( unsigned hw_mask,
unsigned prim,
unsigned in_index_size,
unsigned nr,
unsigned in_pv,
unsigned out_pv,
unsigned *out_prim,
unsigned *out_index_size,
unsigned *out_nr,
u_translate_func *out_translate )
{
unsigned in_idx;
unsigned out_idx;
int ret = U_TRANSLATE_NORMAL;

u_index_init();

in_idx = in_size_idx(in_index_size);
*out_index_size = (in_index_size == 4) ? 4 : 2;
out_idx = out_size_idx(*out_index_size);

if ((hw_mask & (1<<prim)) &&
in_index_size == *out_index_size &&
in_pv == out_pv)
{
if (in_index_size == 4)
*out_translate = translate_memcpy_uint;
else
*out_translate = translate_memcpy_ushort;

*out_prim = prim;
*out_nr = nr;

return U_TRANSLATE_MEMCPY;
}
else {
switch (prim) {
case PIPE_PRIM_POINTS:
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][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_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_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_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_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_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_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_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_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_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_prim = PIPE_PRIM_POINTS;
*out_nr = nr;
return U_TRANSLATE_ERROR;
}
}

return ret;
}





int u_index_generator( unsigned hw_mask,
unsigned prim,
unsigned start,
unsigned nr,
unsigned in_pv,
unsigned out_pv,
unsigned *out_prim,
unsigned *out_index_size,
unsigned *out_nr,
u_generate_func *out_generate )

{
unsigned out_idx;

u_index_init();

*out_index_size = ((start + nr) > 0xfffe) ? 4 : 2;
out_idx = out_size_idx(*out_index_size);

if ((hw_mask & (1<<prim)) &&
(in_pv == out_pv)) {
*out_generate = generate[out_idx][in_pv][out_pv][PIPE_PRIM_POINTS];
*out_prim = prim;
*out_nr = nr;
return U_GENERATE_LINEAR;
}
else {
switch (prim) {
case PIPE_PRIM_POINTS:
*out_generate = generate[out_idx][in_pv][out_pv][prim];
*out_prim = PIPE_PRIM_POINTS;
*out_nr = nr;
return U_GENERATE_REUSABLE;

case PIPE_PRIM_LINES:
*out_generate = generate[out_idx][in_pv][out_pv][prim];
*out_prim = PIPE_PRIM_LINES;
*out_nr = nr;
return U_GENERATE_REUSABLE;

case PIPE_PRIM_LINE_STRIP:
*out_generate = generate[out_idx][in_pv][out_pv][prim];
*out_prim = PIPE_PRIM_LINES;
*out_nr = (nr - 1) * 2;
return U_GENERATE_REUSABLE;

case PIPE_PRIM_LINE_LOOP:
*out_generate = generate[out_idx][in_pv][out_pv][prim];
*out_prim = PIPE_PRIM_LINES;
*out_nr = nr * 2;
return U_GENERATE_ONE_OFF;

case PIPE_PRIM_TRIANGLES:
*out_generate = generate[out_idx][in_pv][out_pv][prim];
*out_prim = PIPE_PRIM_TRIANGLES;
*out_nr = nr;
return U_GENERATE_REUSABLE;

case PIPE_PRIM_TRIANGLE_STRIP:
*out_generate = generate[out_idx][in_pv][out_pv][prim];
*out_prim = PIPE_PRIM_TRIANGLES;
*out_nr = (nr - 2) * 3;
return U_GENERATE_REUSABLE;

case PIPE_PRIM_TRIANGLE_FAN:
*out_generate = generate[out_idx][in_pv][out_pv][prim];
*out_prim = PIPE_PRIM_TRIANGLES;
*out_nr = (nr - 2) * 3;
return U_GENERATE_REUSABLE;

case PIPE_PRIM_QUADS:
*out_generate = generate[out_idx][in_pv][out_pv][prim];
*out_prim = PIPE_PRIM_TRIANGLES;
*out_nr = (nr / 4) * 6;
return U_GENERATE_REUSABLE;

case PIPE_PRIM_QUAD_STRIP:
*out_generate = generate[out_idx][in_pv][out_pv][prim];
*out_prim = PIPE_PRIM_TRIANGLES;
*out_nr = (nr - 2) * 3;
return U_GENERATE_REUSABLE;

case PIPE_PRIM_POLYGON:
*out_generate = generate[out_idx][in_pv][out_pv][prim];
*out_prim = PIPE_PRIM_TRIANGLES;
*out_nr = (nr - 2) * 3;
return U_GENERATE_REUSABLE;

default:
assert(0);
*out_generate = generate[out_idx][in_pv][out_pv][prim];
*out_prim = PIPE_PRIM_POINTS;
*out_nr = nr;
return U_TRANSLATE_ERROR;
}
}
}

+ 83
- 0
src/gallium/auxiliary/indices/u_indices.h Dosyayı Görüntüle

@@ -0,0 +1,83 @@
/*
* Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef U_INDICES_H
#define U_INDICES_H

#include "pipe/p_compiler.h"

#define PV_FIRST 0
#define PV_LAST 1
#define PV_COUNT 2

typedef void (*u_translate_func)( const void *in,
unsigned nr,
void *out );

typedef void (*u_generate_func)( unsigned nr,
void *out );


/* Return codes describe the translate/generate operation. Caller may
* be able to reuse translated indices under some circumstances.
*/
#define U_TRANSLATE_ERROR -1
#define U_TRANSLATE_NORMAL 1
#define U_TRANSLATE_MEMCPY 2
#define U_GENERATE_LINEAR 3
#define U_GENERATE_REUSABLE 4
#define U_GENERATE_ONE_OFF 5


void u_index_init( void );

int u_index_translator( unsigned hw_mask,
unsigned prim,
unsigned in_index_size,
unsigned nr,
unsigned in_pv, /* API */
unsigned out_pv, /* hardware */
unsigned *out_prim,
unsigned *out_index_size,
unsigned *out_nr,
u_translate_func *out_translate );

/* Note that even when generating it is necessary to know what the
* API's PV is, as the indices generated will depend on whether it is
* the same as hardware or not, and in the case of triangle strips,
* whether it is first or last.
*/
int u_index_generator( unsigned hw_mask,
unsigned prim,
unsigned start,
unsigned nr,
unsigned in_pv, /* API */
unsigned out_pv, /* hardware */
unsigned *out_prim,
unsigned *out_index_size,
unsigned *out_nr,
u_generate_func *out_generate );


#endif

+ 5129
- 0
src/gallium/auxiliary/indices/u_indices_gen.c
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 318
- 0
src/gallium/auxiliary/indices/u_indices_gen.py Dosyayı Görüntüle

@@ -0,0 +1,318 @@
#!/usr/bin/env python
copyright = '''
/*
* Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
'''

GENERATE, UBYTE, USHORT, UINT = 'generate', 'ubyte', 'ushort', 'uint'
FIRST, LAST = 'first', 'last'

INTYPES = (GENERATE, UBYTE, USHORT, UINT)
OUTTYPES = (USHORT, UINT)
PVS=(FIRST, LAST)
PRIMS=('points',
'lines',
'linestrip',
'lineloop',
'tris',
'trifan',
'tristrip',
'quads',
'quadstrip',
'polygon')

LONGPRIMS=('PIPE_PRIM_POINTS',
'PIPE_PRIM_LINES',
'PIPE_PRIM_LINE_STRIP',
'PIPE_PRIM_LINE_LOOP',
'PIPE_PRIM_TRIANGLES',
'PIPE_PRIM_TRIANGLE_FAN',
'PIPE_PRIM_TRIANGLE_STRIP',
'PIPE_PRIM_QUADS',
'PIPE_PRIM_QUAD_STRIP',
'PIPE_PRIM_POLYGON')

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')


def prolog():
print '''/* File automatically generated by indices.py */'''
print copyright
print r'''

/**
* @file
* Functions to translate and generate index lists
*/

#include "indices/u_indices.h"
#include "indices/u_indices_priv.h"
#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"


static unsigned out_size_idx( unsigned index_size )
{
switch (index_size) {
case 4: return OUT_UINT;
case 2: return OUT_USHORT;
default: assert(0); return OUT_USHORT;
}
}

static unsigned in_size_idx( unsigned index_size )
{
switch (index_size) {
case 4: return IN_UINT;
case 2: return IN_USHORT;
case 1: return IN_UBYTE;
default: assert(0); return IN_UBYTE;
}
}


static u_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];
static u_generate_func generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];


'''

def vert( intype, outtype, v0 ):
if intype == GENERATE:
return '(' + outtype + ')(' + v0 + ')'
else:
return '(' + outtype + ')in[' + v0 + ']'

def point( intype, outtype, ptr, v0 ):
print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'

def line( intype, outtype, ptr, v0, v1 ):
print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'

def tri( intype, outtype, ptr, v0, v1, v2 ):
print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
print ' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';'

def do_point( intype, outtype, ptr, v0 ):
point( intype, outtype, ptr, v0 )

def do_line( intype, outtype, ptr, v0, v1, inpv, outpv ):
if inpv == outpv:
line( intype, outtype, ptr, v0, v1 )
else:
line( intype, outtype, ptr, v1, v0 )

def do_tri( intype, outtype, ptr, v0, v1, v2, inpv, outpv ):
if inpv == outpv:
tri( intype, outtype, ptr, v0, v1, v2 )
else:
if inpv == FIRST:
tri( intype, outtype, ptr, v1, v2, v0 )
else:
tri( intype, outtype, ptr, v2, v0, v1 )


def name(intype, outtype, inpv, outpv, prim):
if intype == GENERATE:
return 'generate_' + prim + '_' + outtype + '_' + inpv + '2' + outpv
else:
return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv

def preamble(intype, outtype, inpv, outpv, prim):
print 'static void ' + name( intype, outtype, inpv, outpv, prim ) + '('
if intype != GENERATE:
print ' const void * _in,'
print ' unsigned nr,'
print ' void *_out )'
print '{'
if intype != GENERATE:
print ' const ' + intype + '*in = (const ' + intype + '*)in;'
print ' ' + outtype + ' *out = (' + outtype + '*)_out;'
print ' unsigned i, j;'
print ' (void)j;'

def postamble():
print '}'


def points(intype, outtype, inpv, outpv):
preamble(intype, outtype, inpv, outpv, prim='points')
print ' for (i = 0; i < nr; 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 = 0; i < nr; 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 (j = i = 0; j < 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 (j = i = 0; j < nr - 2; j+=2, i++) { '
do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv );
print ' }'
do_line( intype, outtype, 'out+j', 'i', '0', inpv, outpv );
postamble()

def tris(intype, outtype, inpv, outpv):
preamble(intype, outtype, inpv, outpv, prim='tris')
print ' for (i = 0; i < nr; 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 (j = i = 0; j < 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:
do_tri( intype, outtype, 'out+j', 'i+(i&1)', 'i+1-(i&1)', 'i+2', inpv, outpv );
print ' }'
postamble()


def trifan(intype, outtype, inpv, outpv):
preamble(intype, outtype, inpv, outpv, prim='trifan')
print ' for (j = i = 0; j < nr; j+=3, i++) { '
do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2', inpv, outpv );
print ' }'
postamble()



def polygon(intype, outtype, inpv, outpv):
preamble(intype, outtype, inpv, outpv, prim='polygon')
print ' for (j = i = 0; j < nr; j+=3, i++) { '
if inpv == FIRST:
do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2', inpv, outpv );
else:
do_tri( intype, outtype, 'out+j', 'i+1', 'i+2', '0', inpv, outpv );
print ' }'
postamble()


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 );
print ' }'
postamble()


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 );
print ' }'
postamble()


def emit_funcs():
for intype in INTYPES:
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):
if intype == GENERATE:
print ('generate[' +
outtype_idx[outtype] +
'][' + pv_idx[inpv] +
'][' + pv_idx[outpv] +
'][' + longprim[prim] +
'] = ' + name( intype, outtype, inpv, outpv, prim ) + ';')
else:
print ('translate[' +
intype_idx[intype] +
'][' + outtype_idx[outtype] +
'][' + pv_idx[inpv] +
'][' + pv_idx[outpv] +
'][' + longprim[prim] +
'] = ' + name( intype, outtype, inpv, outpv, prim ) + ';')


def emit_all_inits():
for intype in INTYPES:
for outtype in OUTTYPES:
for inpv in PVS:
for outpv in PVS:
for prim in PRIMS:
init(intype, outtype, inpv, outpv, prim)

def emit_init():
print 'void u_index_init( void )'
print '{'
print ' static int firsttime = 1;'
print ' if (!firsttime) return;'
print ' firsttime = 0;'
emit_all_inits()
print '}'



def epilog():
print '#include "indices/u_indices.c"'


def main():
prolog()
emit_funcs()
emit_init()
epilog()


if __name__ == '__main__':
main()

+ 43
- 0
src/gallium/auxiliary/indices/u_indices_priv.h Dosyayı Görüntüle

@@ -0,0 +1,43 @@
/*
* Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef U_INDICES_PRIV_H
#define U_INDICES_PRIV_H

#include "pipe/p_compiler.h"
#include "u_indices.h"

#define IN_UBYTE 0
#define IN_USHORT 1
#define IN_UINT 2
#define IN_COUNT 3

#define OUT_USHORT 0
#define OUT_UINT 1
#define OUT_COUNT 2


#define PRIM_COUNT (PIPE_PRIM_POLYGON + 1)

#endif

Loading…
İptal
Kaydet