VirtualBox

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

Last change on this file since 62842 was 51313, checked in by vboxsync, 11 years ago

crOpenGL: bugfixes and work-arounds for wine issues

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.7 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
22print """
23GLboolean crPackIsPixelStoreParm(GLenum pname)
24{
25 if (pname == GL_UNPACK_ALIGNMENT
26 || pname == GL_UNPACK_ROW_LENGTH
27 || pname == GL_UNPACK_SKIP_PIXELS
28 || pname == GL_UNPACK_LSB_FIRST
29 || pname == GL_UNPACK_SWAP_BYTES
30#ifdef CR_OPENGL_VERSION_1_2
31 || pname == GL_UNPACK_IMAGE_HEIGHT
32#endif
33 || pname == GL_UNPACK_SKIP_ROWS
34 || pname == GL_PACK_ALIGNMENT
35 || pname == GL_PACK_ROW_LENGTH
36 || pname == GL_PACK_SKIP_PIXELS
37 || pname == GL_PACK_LSB_FIRST
38 || pname == GL_PACK_SWAP_BYTES
39#ifdef CR_OPENGL_VERSION_1_2
40 || pname == GL_PACK_IMAGE_HEIGHT
41#endif
42 || pname == GL_PACK_SKIP_ROWS)
43 {
44 return GL_TRUE;
45 }
46 return GL_FALSE;
47}
48"""
49
50from get_sizes import *
51
52easy_swaps = {
53 'GenTextures': '(unsigned int) n',
54 'GetClipPlane': '4',
55 'GetPolygonStipple': '0'
56}
57
58simple_funcs = [ 'GetIntegerv', 'GetFloatv', 'GetDoublev', 'GetBooleanv' ]
59simple_swaps = [ 'SWAP32', 'SWAPFLOAT', 'SWAPDOUBLE', '(GLboolean) SWAP32' ]
60
61vertattr_get_funcs = [ 'GetVertexAttribdv' 'GetVertexAttribfv' 'GetVertexAttribiv' ]
62
63hard_funcs = {
64 'GetLightfv': 'SWAPFLOAT',
65 'GetLightiv': 'SWAP32',
66 'GetMaterialfv': 'SWAPFLOAT',
67 'GetMaterialiv': 'SWAP32',
68 'GetTexEnvfv': 'SWAPFLOAT',
69 'GetTexEnviv': 'SWAP32',
70 'GetTexGendv': 'SWAPDOUBLE',
71 'GetTexGenfv': 'SWAPFLOAT',
72 'GetTexGeniv': 'SWAP32',
73 'GetTexLevelParameterfv': 'SWAPFLOAT',
74 'GetTexLevelParameteriv': 'SWAP32',
75 'GetTexParameterfv': 'SWAPFLOAT',
76 'GetTexParameteriv': 'SWAP32' }
77
78keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
79
80for func_name in keys:
81 params = apiutil.Parameters(func_name)
82 return_type = apiutil.ReturnType(func_name)
83 if apiutil.FindSpecial( "packspu", func_name ):
84 continue
85
86 if "get" in apiutil.Properties(func_name):
87 print '%s PACKSPU_APIENTRY packspu_%s( %s )' % ( return_type, func_name, apiutil.MakeDeclarationString( params ) )
88 print '{'
89 print '\tGET_THREAD(thread);'
90 print '\tint writeback = 1;'
91 if return_type != 'void':
92 print '\t%s return_val = (%s) 0;' % (return_type, return_type)
93 params.append( ("&return_val", "foo", 0) )
94 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():
95 print '\tunsigned int i;'
96 print '\tif (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network))'
97 print '\t{'
98 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
99 print '\t}'
100 if func_name in simple_funcs:
101 print """
102 if (crPackIsPixelStoreParm(pname)
103 || pname == GL_DRAW_BUFFER
104#ifdef CR_OPENGL_VERSION_1_3
105 || pname == GL_ACTIVE_TEXTURE
106#endif
107#ifdef CR_ARB_multitexture
108 || pname == GL_ACTIVE_TEXTURE_ARB
109#endif
110 || pname == GL_TEXTURE_BINDING_1D
111 || pname == GL_TEXTURE_BINDING_2D
112#ifdef CR_NV_texture_rectangle
113 || pname == GL_TEXTURE_BINDING_RECTANGLE_NV
114#endif
115#ifdef CR_ARB_texture_cube_map
116 || pname == GL_TEXTURE_BINDING_CUBE_MAP_ARB
117#endif
118#ifdef CR_ARB_vertex_program
119 || pname == GL_MAX_VERTEX_ATTRIBS_ARB
120#endif
121#ifdef GL_EXT_framebuffer_object
122 || pname == GL_FRAMEBUFFER_BINDING_EXT
123 || pname == GL_READ_FRAMEBUFFER_BINDING_EXT
124 || pname == GL_DRAW_FRAMEBUFFER_BINDING_EXT
125#endif
126 || pname == GL_ARRAY_BUFFER_BINDING
127 || pname == GL_ELEMENT_ARRAY_BUFFER_BINDING
128 || pname == GL_PIXEL_PACK_BUFFER_BINDING
129 || pname == GL_PIXEL_UNPACK_BUFFER_BINDING
130 )
131 {
132#ifdef DEBUG
133 if (!crPackIsPixelStoreParm(pname)
134#ifdef CR_ARB_vertex_program
135 && (pname!=GL_MAX_VERTEX_ATTRIBS_ARB)
136#endif
137 )
138 {
139 %s localparams;
140 localparams = (%s) crAlloc(__numValues(pname) * sizeof(*localparams));
141 crState%s(pname, localparams);
142 crPack%s(%s, &writeback);
143 packspuFlush( (void *) thread );
144 CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
145 for (i=0; i<__numValues(pname); ++i)
146 {
147 if (localparams[i] != params[i])
148 {
149 crWarning("Incorrect local state in %s for %%x param %%i", pname, i);
150 crWarning("Expected %%i but got %%i", (int)localparams[i], (int)params[i]);
151 }
152 }
153 crFree(localparams);
154 return;
155 }
156 else
157#endif
158 {
159 crState%s(pname, params);
160 return;
161 }
162
163 }
164 """ % (params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name, func_name)
165
166 if func_name in vertattr_get_funcs:
167 print """
168 if (pname != GL_CURRENT_VERTEX_ATTRIB_ARB)
169 {
170#ifdef DEBUG
171 %s localparams;
172 localparams = (%s) crAlloc(__numValues(pname) * sizeof(*localparams));
173 crState%s(index, pname, localparams);
174 crPack%s(index, %s, &writeback);
175 packspuFlush( (void *) thread );
176 CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
177 for (i=0; i<crStateHlpComponentsCount(pname); ++i)
178 {
179 if (localparams[i] != params[i])
180 {
181 crWarning("Incorrect local state in %s for %%x param %%i", pname, i);
182 crWarning("Expected %%i but got %%i", (int)localparams[i], (int)params[i]);
183 }
184 }
185 crFree(localparams);
186#else
187 crState%s(pname, params);
188#endif
189 return;
190 }
191 """ % (params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name, func_name)
192
193 params.append( ("&writeback", "foo", 0) )
194 print '\tif (pack_spu.swap)'
195 print '\t{'
196 print '\t\tcrPack%sSWAP( %s );' % (func_name, apiutil.MakeCallString( params ) )
197 print '\t}'
198 print '\telse'
199 print '\t{'
200 print '\t\tcrPack%s( %s );' % (func_name, apiutil.MakeCallString( params ) )
201 print '\t}'
202 print '\tpackspuFlush( (void *) thread );'
203 print '\tCRPACKSPU_WRITEBACK_WAIT(thread, writeback);'
204
205
206
207 lastParamName = params[-2][0]
208 if return_type != 'void':
209 print '\tif (pack_spu.swap)'
210 print '\t{'
211 print '\t\treturn_val = (%s) SWAP32(return_val);' % return_type
212 print '\t}'
213 print '\treturn return_val;'
214 if func_name in easy_swaps.keys() and easy_swaps[func_name] != '0':
215 limit = easy_swaps[func_name]
216 print '\tif (pack_spu.swap)'
217 print '\t{'
218 print '\t\tfor (i = 0 ; i < %s ; i++)' % limit
219 print '\t\t{'
220 if params[-2][1].find( "double" ) > -1:
221 print '\t\t\t%s[i] = SWAPDOUBLE(%s[i]);' % (lastParamName, lastParamName)
222 else:
223 print '\t\t\t%s[i] = SWAP32(%s[i]);' % (lastParamName, lastParamName)
224 print '\t\t}'
225 print '\t}'
226 for index in range(len(simple_funcs)):
227 if simple_funcs[index] == func_name:
228 print '\tif (pack_spu.swap)'
229 print '\t{'
230 print '\t\tfor (i = 0 ; i < __numValues( pname ) ; i++)'
231 print '\t\t{'
232 if simple_swaps[index] == 'SWAPDOUBLE':
233 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
234 else:
235 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
236 print '\t\t}'
237 print '\t}'
238 if func_name in hard_funcs.keys():
239 print '\tif (pack_spu.swap)'
240 print '\t{'
241 print '\t\tfor (i = 0 ; i < crStateHlpComponentsCount(pname) ; i++)'
242 print '\t\t{'
243 if hard_funcs[func_name] == 'SWAPDOUBLE':
244 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
245 else:
246 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
247 print '\t\t}'
248 print '\t}'
249 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