VirtualBox

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

Last change on this file since 69922 was 69310, checked in by vboxsync, 7 years ago

common/crOpenGL: scm updates

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