VirtualBox

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

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

wddm/3d: fix google earth rendering

  • 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 while (writeback)
135 crNetRecv();
136 for (i=0; i<__numValues(pname); ++i)
137 {
138 if (localparams[i] != params[i])
139 {
140 crWarning("Incorrect local state in %s for %%x param %%i", pname, i);
141 crWarning("Expected %%i but got %%i", (int)localparams[i], (int)params[i]);
142 }
143 }
144 crFree(localparams);
145 return;
146 }
147 else
148#endif
149 {
150 crState%s(pname, params);
151 return;
152 }
153
154 }
155 """ % (params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name, func_name)
156 params.append( ("&writeback", "foo", 0) )
157 print '\tif (pack_spu.swap)'
158 print '\t{'
159 print '\t\tcrPack%sSWAP( %s );' % (func_name, apiutil.MakeCallString( params ) )
160 print '\t}'
161 print '\telse'
162 print '\t{'
163 print '\t\tcrPack%s( %s );' % (func_name, apiutil.MakeCallString( params ) )
164 print '\t}'
165 print '\tpackspuFlush( (void *) thread );'
166 print '\twhile (writeback)'
167 print '\t\tcrNetRecv();'
168
169
170
171 lastParamName = params[-2][0]
172 if return_type != 'void':
173 print '\tif (pack_spu.swap)'
174 print '\t{'
175 print '\t\treturn_val = (%s) SWAP32(return_val);' % return_type
176 print '\t}'
177 print '\treturn return_val;'
178 if func_name in easy_swaps.keys() and easy_swaps[func_name] != '0':
179 limit = easy_swaps[func_name]
180 print '\tif (pack_spu.swap)'
181 print '\t{'
182 print '\t\tfor (i = 0 ; i < %s ; i++)' % limit
183 print '\t\t{'
184 if params[-2][1].find( "double" ) > -1:
185 print '\t\t\t%s[i] = SWAPDOUBLE(%s[i]);' % (lastParamName, lastParamName)
186 else:
187 print '\t\t\t%s[i] = SWAP32(%s[i]);' % (lastParamName, lastParamName)
188 print '\t\t}'
189 print '\t}'
190 for index in range(len(simple_funcs)):
191 if simple_funcs[index] == func_name:
192 print '\tif (pack_spu.swap)'
193 print '\t{'
194 print '\t\tfor (i = 0 ; i < __numValues( pname ) ; i++)'
195 print '\t\t{'
196 if simple_swaps[index] == 'SWAPDOUBLE':
197 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
198 else:
199 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
200 print '\t\t}'
201 print '\t}'
202 if func_name in hard_funcs.keys():
203 print '\tif (pack_spu.swap)'
204 print '\t{'
205 print '\t\tfor (i = 0 ; i < lookupComponents(pname) ; i++)'
206 print '\t\t{'
207 if hard_funcs[func_name] == 'SWAPDOUBLE':
208 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
209 else:
210 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
211 print '\t\t}'
212 print '\t}'
213 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