packspu_get.py revision 6457f9bc953a052259ba55fbf6f3d6faace120fa
# Copyright (c) 2001, Stanford University
# All rights reserved.
#
# See the file LICENSE.txt for information on redistributing this software.
import sys
import apiutil
print """
/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY packspu_get.py SCRIPT */
#include "packspu.h"
#include "cr_packfunctions.h"
#include "cr_net.h"
#include "packspu_proto.h"
"""
from get_sizes import *
from get_components import *
easy_swaps = {
'GenTextures': '(unsigned int) n',
'GetClipPlane': '4',
'GetPolygonStipple': '0'
}
hard_funcs = {
'GetLightfv': 'SWAPFLOAT',
'GetLightiv': 'SWAP32',
'GetMaterialfv': 'SWAPFLOAT',
'GetMaterialiv': 'SWAP32',
'GetTexEnvfv': 'SWAPFLOAT',
'GetTexEnviv': 'SWAP32',
'GetTexGendv': 'SWAPDOUBLE',
'GetTexGenfv': 'SWAPFLOAT',
'GetTexGeniv': 'SWAP32',
'GetTexLevelParameterfv': 'SWAPFLOAT',
'GetTexLevelParameteriv': 'SWAP32',
'GetTexParameterfv': 'SWAPFLOAT',
'GetTexParameteriv': 'SWAP32' }
continue
print '%s PACKSPU_APIENTRY packspu_%s( %s )' % ( return_type, func_name, apiutil.MakeDeclarationString( params ) )
print '{'
print '\tGET_THREAD(thread);'
print '\tint writeback = 1;'
if return_type != 'void':
if (func_name in easy_swaps.keys() and easy_swaps[func_name] != '0') or func_name in simple_funcs or func_name in hard_funcs.keys():
print '\tunsigned int i;'
print '\tif (!(pack_spu.thread[0].netServer.conn->actual_network))'
print '\t{'
print '\t\tcrError( "packspu_%s doesn\'t work when there\'s no actual network involved!\\nTry using the simplequery SPU in your chain!" );' % func_name
print '\t}'
if func_name in simple_funcs:
print '\tif (pname == GL_UNPACK_ALIGNMENT ||'
print '\t\tpname == GL_UNPACK_ROW_LENGTH ||'
print '\t\tpname == GL_UNPACK_SKIP_PIXELS ||'
print '\t\tpname == GL_UNPACK_LSB_FIRST ||'
print '\t\tpname == GL_UNPACK_SWAP_BYTES ||'
print '#ifdef CR_OPENGL_VERSION_1_2'
print '\t\tpname == GL_UNPACK_IMAGE_HEIGHT ||'
print '#endif'
print '\t\tpname == GL_UNPACK_SKIP_ROWS ||'
print '\t\tpname == GL_PACK_ALIGNMENT ||'
print '\t\tpname == GL_PACK_ROW_LENGTH ||'
print '\t\tpname == GL_PACK_SKIP_PIXELS ||'
print '\t\tpname == GL_PACK_LSB_FIRST ||'
print '\t\tpname == GL_PACK_SWAP_BYTES ||'
print '#ifdef CR_OPENGL_VERSION_1_2'
print '\t\tpname == GL_PACK_IMAGE_HEIGHT ||'
print '#endif'
print '\t\tpname == GL_PACK_SKIP_ROWS) {'
print '\t\t\tcrState%s( pname, params );' % func_name
print '\t\t\treturn;'
print '\t}'
print '\tif (pack_spu.swap)'
print '\t{'
print '\t}'
print '\telse'
print '\t{'
print '\t}'
print '\tpackspuFlush( (void *) thread );'
print '\twhile (writeback)'
print '\t\tcrNetRecv();'
if return_type != 'void':
print '\tif (pack_spu.swap)'
print '\t{'
print '\t\treturn_val = (%s) SWAP32(return_val);' % return_type
print '\t}'
print '\treturn return_val;'
print '\tif (pack_spu.swap)'
print '\t{'
print '\t\tfor (i = 0 ; i < %s ; i++)' % limit
print '\t\t{'
else:
print '\t\t}'
print '\t}'
print '\tif (pack_spu.swap)'
print '\t{'
print '\t\tfor (i = 0 ; i < __numValues( pname ) ; i++)'
print '\t\t{'
else:
print '\t\t}'
print '\t}'
print '\tif (pack_spu.swap)'
print '\t{'
print '\t\tfor (i = 0 ; i < lookupComponents(pname) ; i++)'
print '\t\t{'
else:
print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
print '\t\t}'
print '\t}'
print '}\n'