VirtualBox

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

Last change on this file since 42499 was 42499, checked in by vboxsync, 12 years ago

crOgl/wddm: per-context connections

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.3 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 *
51from get_components 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
62hard_funcs = {
63 'GetLightfv': 'SWAPFLOAT',
64 'GetLightiv': 'SWAP32',
65 'GetMaterialfv': 'SWAPFLOAT',
66 'GetMaterialiv': 'SWAP32',
67 'GetTexEnvfv': 'SWAPFLOAT',
68 'GetTexEnviv': 'SWAP32',
69 'GetTexGendv': 'SWAPDOUBLE',
70 'GetTexGenfv': 'SWAPFLOAT',
71 'GetTexGeniv': 'SWAP32',
72 'GetTexLevelParameterfv': 'SWAPFLOAT',
73 'GetTexLevelParameteriv': 'SWAP32',
74 'GetTexParameterfv': 'SWAPFLOAT',
75 'GetTexParameteriv': 'SWAP32' }
76
77keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
78
79for func_name in keys:
80 params = apiutil.Parameters(func_name)
81 return_type = apiutil.ReturnType(func_name)
82 if apiutil.FindSpecial( "packspu", func_name ):
83 continue
84
85 if "get" in apiutil.Properties(func_name):
86 print '%s PACKSPU_APIENTRY packspu_%s( %s )' % ( return_type, func_name, apiutil.MakeDeclarationString( params ) )
87 print '{'
88 print '\tGET_THREAD(thread);'
89 print '\tint writeback = 1;'
90 if return_type != 'void':
91 print '\t%s return_val = (%s) 0;' % (return_type, return_type)
92 params.append( ("&return_val", "foo", 0) )
93 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():
94 print '\tunsigned int i;'
95 print '\tif (!(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network))'
96 print '\t{'
97 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
98 print '\t}'
99 if func_name in simple_funcs:
100 print """
101 if (crPackIsPixelStoreParm(pname)
102 || pname == GL_DRAW_BUFFER
103#ifdef CR_OPENGL_VERSION_1_3
104 || pname == GL_ACTIVE_TEXTURE
105#endif
106#ifdef CR_ARB_multitexture
107 || pname == GL_ACTIVE_TEXTURE_ARB
108#endif
109 || pname == GL_TEXTURE_BINDING_1D
110 || pname == GL_TEXTURE_BINDING_2D
111#ifdef CR_NV_texture_rectangle
112 || pname == GL_TEXTURE_BINDING_RECTANGLE_NV
113#endif
114#ifdef CR_ARB_texture_cube_map
115 || pname == GL_TEXTURE_BINDING_CUBE_MAP_ARB
116#endif
117#ifdef CR_ARB_vertex_program
118 || pname == GL_MAX_VERTEX_ATTRIBS_ARB
119#endif
120 )
121 {
122#ifdef DEBUG
123 if (!crPackIsPixelStoreParm(pname)
124#ifdef CR_ARB_vertex_program
125 && (pname!=GL_MAX_VERTEX_ATTRIBS_ARB)
126#endif
127 )
128 {
129 %s localparams;
130 localparams = (%s) crAlloc(__numValues(pname) * sizeof(*localparams));
131 crState%s(pname, localparams);
132 crPack%s(%s, &writeback);
133 packspuFlush( (void *) thread );
134 CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
135 for (i=0; i<__numValues(pname); ++i)
136 {
137 if (localparams[i] != params[i])
138 {
139 crWarning("Incorrect local state in %s for %%x param %%i", pname, i);
140 crWarning("Expected %%i but got %%i", (int)localparams[i], (int)params[i]);
141 }
142 }
143 crFree(localparams);
144 return;
145 }
146 else
147#endif
148 {
149 crState%s(pname, params);
150 return;
151 }
152
153 }
154 """ % (params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name, func_name)
155 params.append( ("&writeback", "foo", 0) )
156 print '\tif (pack_spu.swap)'
157 print '\t{'
158 print '\t\tcrPack%sSWAP( %s );' % (func_name, apiutil.MakeCallString( params ) )
159 print '\t}'
160 print '\telse'
161 print '\t{'
162 print '\t\tcrPack%s( %s );' % (func_name, apiutil.MakeCallString( params ) )
163 print '\t}'
164 print '\tpackspuFlush( (void *) thread );'
165 print '\tCRPACKSPU_WRITEBACK_WAIT(thread, writeback);'
166
167
168
169 lastParamName = params[-2][0]
170 if return_type != 'void':
171 print '\tif (pack_spu.swap)'
172 print '\t{'
173 print '\t\treturn_val = (%s) SWAP32(return_val);' % return_type
174 print '\t}'
175 print '\treturn return_val;'
176 if func_name in easy_swaps.keys() and easy_swaps[func_name] != '0':
177 limit = easy_swaps[func_name]
178 print '\tif (pack_spu.swap)'
179 print '\t{'
180 print '\t\tfor (i = 0 ; i < %s ; i++)' % limit
181 print '\t\t{'
182 if params[-2][1].find( "double" ) > -1:
183 print '\t\t\t%s[i] = SWAPDOUBLE(%s[i]);' % (lastParamName, lastParamName)
184 else:
185 print '\t\t\t%s[i] = SWAP32(%s[i]);' % (lastParamName, lastParamName)
186 print '\t\t}'
187 print '\t}'
188 for index in range(len(simple_funcs)):
189 if simple_funcs[index] == func_name:
190 print '\tif (pack_spu.swap)'
191 print '\t{'
192 print '\t\tfor (i = 0 ; i < __numValues( pname ) ; i++)'
193 print '\t\t{'
194 if simple_swaps[index] == 'SWAPDOUBLE':
195 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
196 else:
197 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
198 print '\t\t}'
199 print '\t}'
200 if func_name in hard_funcs.keys():
201 print '\tif (pack_spu.swap)'
202 print '\t{'
203 print '\t\tfor (i = 0 ; i < lookupComponents(pname) ; i++)'
204 print '\t\t{'
205 if hard_funcs[func_name] == 'SWAPDOUBLE':
206 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
207 else:
208 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
209 print '\t\t}'
210 print '\t}'
211 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