VirtualBox

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

Last change on this file since 33988 was 33988, checked in by vboxsync, 14 years ago

crOpenGL/wddm: more multithreading fixes, vista expirience index works now

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.8 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 "cr_mem.h"
19#include "packspu_proto.h"
20"""
21
22from get_sizes import *
23from get_components import *
24
25easy_swaps = {
26 'GenTextures': '(unsigned int) n',
27 'GetClipPlane': '4',
28 'GetPolygonStipple': '0'
29}
30
31simple_funcs = [ 'GetIntegerv', 'GetFloatv', 'GetDoublev', 'GetBooleanv' ]
32simple_swaps = [ 'SWAP32', 'SWAPFLOAT', 'SWAPDOUBLE', '(GLboolean) SWAP32' ]
33
34hard_funcs = {
35 'GetLightfv': 'SWAPFLOAT',
36 'GetLightiv': 'SWAP32',
37 'GetMaterialfv': 'SWAPFLOAT',
38 'GetMaterialiv': 'SWAP32',
39 'GetTexEnvfv': 'SWAPFLOAT',
40 'GetTexEnviv': 'SWAP32',
41 'GetTexGendv': 'SWAPDOUBLE',
42 'GetTexGenfv': 'SWAPFLOAT',
43 'GetTexGeniv': 'SWAP32',
44 'GetTexLevelParameterfv': 'SWAPFLOAT',
45 'GetTexLevelParameteriv': 'SWAP32',
46 'GetTexParameterfv': 'SWAPFLOAT',
47 'GetTexParameteriv': 'SWAP32' }
48
49keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
50
51for func_name in keys:
52 params = apiutil.Parameters(func_name)
53 return_type = apiutil.ReturnType(func_name)
54 if apiutil.FindSpecial( "packspu", func_name ):
55 continue
56
57 if "get" in apiutil.Properties(func_name):
58 print '%s PACKSPU_APIENTRY packspu_%s( %s )' % ( return_type, func_name, apiutil.MakeDeclarationString( params ) )
59 print '{'
60 print '\tGET_THREAD(thread);'
61 print '\tint writeback = 1;'
62 if return_type != 'void':
63 print '\t%s return_val = (%s) 0;' % (return_type, return_type)
64 params.append( ("&return_val", "foo", 0) )
65 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():
66 print '\tunsigned int i;'
67 print '\tif (!(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network))'
68 print '\t{'
69 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
70 print '\t}'
71 if func_name in simple_funcs:
72 print """
73 if (pname == GL_UNPACK_ALIGNMENT
74 || pname == GL_UNPACK_ROW_LENGTH
75 || pname == GL_UNPACK_SKIP_PIXELS
76 || pname == GL_UNPACK_LSB_FIRST
77 || pname == GL_UNPACK_SWAP_BYTES
78#ifdef CR_OPENGL_VERSION_1_2
79 || pname == GL_UNPACK_IMAGE_HEIGHT
80#endif
81 || pname == GL_UNPACK_SKIP_ROWS
82 || pname == GL_PACK_ALIGNMENT
83 || pname == GL_PACK_ROW_LENGTH
84 || pname == GL_PACK_SKIP_PIXELS
85 || pname == GL_PACK_LSB_FIRST
86 || pname == GL_PACK_SWAP_BYTES
87#ifdef CR_OPENGL_VERSION_1_2
88 || pname == GL_PACK_IMAGE_HEIGHT
89#endif
90 || pname == GL_PACK_SKIP_ROWS
91 || pname == GL_DRAW_BUFFER
92#ifdef CR_OPENGL_VERSION_1_3
93 || pname == GL_ACTIVE_TEXTURE
94#endif
95#ifdef CR_ARB_multitexture
96 || pname == GL_ACTIVE_TEXTURE_ARB
97#endif
98 || pname == GL_TEXTURE_BINDING_1D
99 || pname == GL_TEXTURE_BINDING_2D
100#ifdef CR_NV_texture_rectangle
101 || pname == GL_TEXTURE_BINDING_RECTANGLE_NV
102#endif
103#ifdef CR_ARB_texture_cube_map
104 || pname == GL_TEXTURE_BINDING_CUBE_MAP_ARB
105#endif
106 )
107 {
108#ifndef DEBUG
109 crState%s( pname, params );
110 return;
111#else
112 %s localparams;
113 localparams = (%s) crAlloc(__numValues(pname) * sizeof(*localparams));
114 crState%s(pname, localparams);
115 crPack%s(%s, &writeback);
116 packspuFlush( (void *) thread );
117 while (writeback)
118 crNetRecv();
119 for (i=0; i<__numValues(pname); ++i)
120 {
121 if (localparams[i] != params[i])
122 {
123 crWarning("Incorrect local state in %s for %%x param %%i", pname, i);
124 crWarning("Expected %%i but got %%i", (int)localparams[i], (int)params[i]);
125 }
126 }
127 crFree(localparams);
128 return;
129#endif
130
131 }
132 """ % (func_name, params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name)
133 params.append( ("&writeback", "foo", 0) )
134 print '\tif (pack_spu.swap)'
135 print '\t{'
136 print '\t\tcrPack%sSWAP( %s );' % (func_name, apiutil.MakeCallString( params ) )
137 print '\t}'
138 print '\telse'
139 print '\t{'
140 print '\t\tcrPack%s( %s );' % (func_name, apiutil.MakeCallString( params ) )
141 print '\t}'
142 print '\tpackspuFlush( (void *) thread );'
143 print '\twhile (writeback)'
144 print '\t\tcrNetRecv();'
145
146
147
148 lastParamName = params[-2][0]
149 if return_type != 'void':
150 print '\tif (pack_spu.swap)'
151 print '\t{'
152 print '\t\treturn_val = (%s) SWAP32(return_val);' % return_type
153 print '\t}'
154 print '\treturn return_val;'
155 if func_name in easy_swaps.keys() and easy_swaps[func_name] != '0':
156 limit = easy_swaps[func_name]
157 print '\tif (pack_spu.swap)'
158 print '\t{'
159 print '\t\tfor (i = 0 ; i < %s ; i++)' % limit
160 print '\t\t{'
161 if params[-2][1].find( "double" ) > -1:
162 print '\t\t\t%s[i] = SWAPDOUBLE(%s[i]);' % (lastParamName, lastParamName)
163 else:
164 print '\t\t\t%s[i] = SWAP32(%s[i]);' % (lastParamName, lastParamName)
165 print '\t\t}'
166 print '\t}'
167 for index in range(len(simple_funcs)):
168 if simple_funcs[index] == func_name:
169 print '\tif (pack_spu.swap)'
170 print '\t{'
171 print '\t\tfor (i = 0 ; i < __numValues( pname ) ; i++)'
172 print '\t\t{'
173 if simple_swaps[index] == 'SWAPDOUBLE':
174 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
175 else:
176 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
177 print '\t\t}'
178 print '\t}'
179 if func_name in hard_funcs.keys():
180 print '\tif (pack_spu.swap)'
181 print '\t{'
182 print '\t\tfor (i = 0 ; i < lookupComponents(pname) ; i++)'
183 print '\t\t{'
184 if hard_funcs[func_name] == 'SWAPDOUBLE':
185 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
186 else:
187 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
188 print '\t\t}'
189 print '\t}'
190 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