VirtualBox

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

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

crOpenGL: avoid eaxtra guest->host calls

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.5 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 (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(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#ifndef GL_EXT_framebuffer_object
121 || pname == GL_FRAMEBUFFER_BINDING_EXT
122 || pname == GL_READ_FRAMEBUFFER_BINDING_EXT
123 || pname == GL_DRAW_FRAMEBUFFER_BINDING_EXT
124#endif
125 )
126 {
127#ifdef DEBUG
128 if (!crPackIsPixelStoreParm(pname)
129#ifdef CR_ARB_vertex_program
130 && (pname!=GL_MAX_VERTEX_ATTRIBS_ARB)
131#endif
132 )
133 {
134 %s localparams;
135 localparams = (%s) crAlloc(__numValues(pname) * sizeof(*localparams));
136 crState%s(pname, localparams);
137 crPack%s(%s, &writeback);
138 packspuFlush( (void *) thread );
139 CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
140 for (i=0; i<__numValues(pname); ++i)
141 {
142 if (localparams[i] != params[i])
143 {
144 crWarning("Incorrect local state in %s for %%x param %%i", pname, i);
145 crWarning("Expected %%i but got %%i", (int)localparams[i], (int)params[i]);
146 }
147 }
148 crFree(localparams);
149 return;
150 }
151 else
152#endif
153 {
154 crState%s(pname, params);
155 return;
156 }
157
158 }
159 """ % (params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name, func_name)
160 params.append( ("&writeback", "foo", 0) )
161 print '\tif (pack_spu.swap)'
162 print '\t{'
163 print '\t\tcrPack%sSWAP( %s );' % (func_name, apiutil.MakeCallString( params ) )
164 print '\t}'
165 print '\telse'
166 print '\t{'
167 print '\t\tcrPack%s( %s );' % (func_name, apiutil.MakeCallString( params ) )
168 print '\t}'
169 print '\tpackspuFlush( (void *) thread );'
170 print '\tCRPACKSPU_WRITEBACK_WAIT(thread, writeback);'
171
172
173
174 lastParamName = params[-2][0]
175 if return_type != 'void':
176 print '\tif (pack_spu.swap)'
177 print '\t{'
178 print '\t\treturn_val = (%s) SWAP32(return_val);' % return_type
179 print '\t}'
180 print '\treturn return_val;'
181 if func_name in easy_swaps.keys() and easy_swaps[func_name] != '0':
182 limit = easy_swaps[func_name]
183 print '\tif (pack_spu.swap)'
184 print '\t{'
185 print '\t\tfor (i = 0 ; i < %s ; i++)' % limit
186 print '\t\t{'
187 if params[-2][1].find( "double" ) > -1:
188 print '\t\t\t%s[i] = SWAPDOUBLE(%s[i]);' % (lastParamName, lastParamName)
189 else:
190 print '\t\t\t%s[i] = SWAP32(%s[i]);' % (lastParamName, lastParamName)
191 print '\t\t}'
192 print '\t}'
193 for index in range(len(simple_funcs)):
194 if simple_funcs[index] == func_name:
195 print '\tif (pack_spu.swap)'
196 print '\t{'
197 print '\t\tfor (i = 0 ; i < __numValues( pname ) ; i++)'
198 print '\t\t{'
199 if simple_swaps[index] == 'SWAPDOUBLE':
200 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
201 else:
202 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName)
203 print '\t\t}'
204 print '\t}'
205 if func_name in hard_funcs.keys():
206 print '\tif (pack_spu.swap)'
207 print '\t{'
208 print '\t\tfor (i = 0 ; i < lookupComponents(pname) ; i++)'
209 print '\t\t{'
210 if hard_funcs[func_name] == 'SWAPDOUBLE':
211 print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
212 else:
213 print '\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName)
214 print '\t\t}'
215 print '\t}'
216 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