VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py@ 21094

Last change on this file since 21094 was 20084, checked in by vboxsync, 16 years ago

crOpenGL: reduce amount of sync calls to speed up d3d

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.1 KB
Line 
1# Copyright (c) 2001, Stanford University
2# All rights reserved.
3#
4# See the file LICENSE.txt for information on redistributing this software.
5
6import sys
7
8import apiutil
9
10
11apiutil.CopyrightC()
12
13print """
14/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY packspu_get.py SCRIPT */
15#include "packspu.h"
16#include "cr_packfunctions.h"
17#include "cr_net.h"
18#include "packspu_proto.h"
19"""
20
21from get_sizes import *
22from get_components import *
23
24easy_swaps = {
25 'GenTextures': '(unsigned int) n',
26 'GetClipPlane': '4',
27 'GetPolygonStipple': '0'
28}
29
30simple_funcs = [ 'GetIntegerv', 'GetFloatv', 'GetDoublev', 'GetBooleanv' ]
31simple_swaps = [ 'SWAP32', 'SWAPFLOAT', 'SWAPDOUBLE', '(GLboolean) SWAP32' ]
32
33hard_funcs = {
34 'GetLightfv': 'SWAPFLOAT',
35 'GetLightiv': 'SWAP32',
36 'GetMaterialfv': 'SWAPFLOAT',
37 'GetMaterialiv': 'SWAP32',
38 'GetTexEnvfv': 'SWAPFLOAT',
39 'GetTexEnviv': 'SWAP32',
40 'GetTexGendv': 'SWAPDOUBLE',
41 'GetTexGenfv': 'SWAPFLOAT',
42 'GetTexGeniv': 'SWAP32',
43 'GetTexLevelParameterfv': 'SWAPFLOAT',
44 'GetTexLevelParameteriv': 'SWAP32',
45 'GetTexParameterfv': 'SWAPFLOAT',
46 'GetTexParameteriv': 'SWAP32' }
47
48keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
49
50for func_name in keys:
51 params = apiutil.Parameters(func_name)
52 return_type = apiutil.ReturnType(func_name)
53 if apiutil.FindSpecial( "packspu", func_name ):
54 continue
55
56 if "get" in apiutil.Properties(func_name):
57 print '%s PACKSPU_APIENTRY packspu_%s( %s )' % ( return_type, func_name, apiutil.MakeDeclarationString( params ) )
58 print '{'
59 print '\tGET_THREAD(thread);'
60 print '\tint writeback = 1;'
61 if return_type != 'void':
62 print '\t%s return_val = (%s) 0;' % (return_type, return_type)
63 params.append( ("&return_val", "foo", 0) )
64 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():
65 print '\tunsigned int i;'
66 print '\tif (!(pack_spu.thread[0].netServer.conn->actual_network))'
67 print '\t{'
68 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
69 print '\t}'
70 if func_name in simple_funcs:
71 print '\tif (pname == GL_UNPACK_ALIGNMENT ||'
72 print '\t\tpname == GL_UNPACK_ROW_LENGTH ||'
73 print '\t\tpname == GL_UNPACK_SKIP_PIXELS ||'
74 print '\t\tpname == GL_UNPACK_LSB_FIRST ||'
75 print '\t\tpname == GL_UNPACK_SWAP_BYTES ||'
76 print '#ifdef CR_OPENGL_VERSION_1_2'
77 print '\t\tpname == GL_UNPACK_IMAGE_HEIGHT ||'
78 print '#endif'
79 print '\t\tpname == GL_UNPACK_SKIP_ROWS ||'
80 print '\t\tpname == GL_PACK_ALIGNMENT ||'
81 print '\t\tpname == GL_PACK_ROW_LENGTH ||'
82 print '\t\tpname == GL_PACK_SKIP_PIXELS ||'
83 print '\t\tpname == GL_PACK_LSB_FIRST ||'
84 print '\t\tpname == GL_PACK_SWAP_BYTES ||'
85 print '#ifdef CR_OPENGL_VERSION_1_2'
86 print '\t\tpname == GL_PACK_IMAGE_HEIGHT ||'
87 print '#endif'
88 print '\t\tpname == GL_PACK_SKIP_ROWS'
89 print '\t\t|| pname == GL_DRAW_BUFFER'
90 print '#ifdef CR_OPENGL_VERSION_1_3'
91 print '\t\t|| pname == GL_ACTIVE_TEXTURE'
92 print '#endif'
93 print '#ifdef CR_ARB_multitexture'
94 print '\t\t|| pname == GL_ACTIVE_TEXTURE_ARB'
95 print '#endif'
96 print ') {'
97 print '\t\t\tcrState%s( pname, params );' % func_name
98 print '\t\t\treturn;'
99 print '\t}'
100 params.append( ("&writeback", "foo", 0) )
101 print '\tif (pack_spu.swap)'
102 print '\t{'
103 print '\t\tcrPack%sSWAP( %s );' % (func_name, apiutil.MakeCallString( params ) )
104 print '\t}'
105 print '\telse'
106 print '\t{'
107 print '\t\tcrPack%s( %s );' % (func_name, apiutil.MakeCallString( params ) )
108 print '\t}'
109 print '\tpackspuFlush( (void *) thread );'
110 print '\twhile (writeback)'
111 print '\t\tcrNetRecv();'
112 lastParamName = params[-2][0]
113 if return_type != 'void':
114 print '\tif (pack_spu.swap)'
115 print '\t{'
116 print '\t\treturn_val = (%s) SWAP32(return_val);' % return_type
117 print '\t}'
118 print '\treturn return_val;'
119 if func_name in easy_swaps.keys() and easy_swaps[func_name] != '0':
120 limit = easy_swaps[func_name]
121 print '\tif (pack_spu.swap)'
122 print '\t{'
123 print '\t\tfor (i = 0 ; i < %s ; i++)' % limit
124 print '\t\t{'
125 if params[-2][1].find( "double" ) > -1:
126 print '\t\t\t%s[i] = SWAPDOUBLE(%s[i]);' % (lastParamName, lastParamName)
127 else:
128 print '\t\t\t%s[i] = SWAP32(%s[i]);' % (lastParamName, lastParamName)
129 print '\t\t}'
130 print '\t}'
131 for index in range(len(simple_funcs)):
132 if simple_funcs[index] == func_name:
133 print '\tif (pack_spu.swap)'
134 print '\t{'
135 print '\t\tfor (i = 0 ; i < __numValues( pname ) ; i++)'
136 print '\t\t{'
137 if simple_swaps[index] == 'SWAPDOUBLE':
138 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
139 else:
140 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
141 print '\t\t}'
142 print '\t}'
143 if func_name in hard_funcs.keys():
144 print '\tif (pack_spu.swap)'
145 print '\t{'
146 print '\t\tfor (i = 0 ; i < lookupComponents(pname) ; i++)'
147 print '\t\t{'
148 if hard_funcs[func_name] == 'SWAPDOUBLE':
149 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
150 else:
151 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
152 print '\t\t}'
153 print '\t}'
154 print '}\n'
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette