1 | # Copyright (c) 2001, Stanford University
|
---|
2 | # All rights reserved.
|
---|
3 | #
|
---|
4 | # See the file LICENSE.txt for information on redistributing this software.
|
---|
5 |
|
---|
6 | from __future__ import print_function
|
---|
7 | import sys
|
---|
8 |
|
---|
9 | import apiutil
|
---|
10 |
|
---|
11 |
|
---|
12 | apiutil.CopyrightC()
|
---|
13 |
|
---|
14 | print("""
|
---|
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 |
|
---|
23 | print("""
|
---|
24 | static 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 |
|
---|
51 | print('#ifdef DEBUG');
|
---|
52 | from get_sizes import *
|
---|
53 | print('#endif');
|
---|
54 |
|
---|
55 | simple_funcs = [ 'GetIntegerv', 'GetFloatv', 'GetDoublev', 'GetBooleanv' ]
|
---|
56 | vertattr_get_funcs = [ 'GetVertexAttribdv' 'GetVertexAttribfv' 'GetVertexAttribiv' ]
|
---|
57 |
|
---|
58 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
59 |
|
---|
60 | for func_name in keys:
|
---|
61 | params = apiutil.Parameters(func_name)
|
---|
62 | return_type = apiutil.ReturnType(func_name)
|
---|
63 | if apiutil.FindSpecial( "packspu", func_name ):
|
---|
64 | continue
|
---|
65 |
|
---|
66 | if "get" in apiutil.Properties(func_name):
|
---|
67 | print('%s PACKSPU_APIENTRY packspu_%s(%s)' % ( return_type, func_name, apiutil.MakeDeclarationString( params ) ))
|
---|
68 | print('{')
|
---|
69 | print('\tGET_THREAD(thread);')
|
---|
70 | print('\tint writeback = 1;')
|
---|
71 | if return_type != 'void':
|
---|
72 | print('\t%s return_val = (%s) 0;' % (return_type, return_type))
|
---|
73 | params.append( ("&return_val", "foo", 0) )
|
---|
74 | print('\tif (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network))')
|
---|
75 | print('\t{')
|
---|
76 | 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)
|
---|
77 | print('\t}')
|
---|
78 | if func_name in simple_funcs:
|
---|
79 | print("""
|
---|
80 | if (crPackIsPixelStoreParm(pname)
|
---|
81 | || pname == GL_DRAW_BUFFER
|
---|
82 | #ifdef CR_OPENGL_VERSION_1_3
|
---|
83 | || pname == GL_ACTIVE_TEXTURE
|
---|
84 | #endif
|
---|
85 | #ifdef CR_ARB_multitexture
|
---|
86 | || pname == GL_ACTIVE_TEXTURE_ARB
|
---|
87 | #endif
|
---|
88 | || pname == GL_TEXTURE_BINDING_1D
|
---|
89 | || pname == GL_TEXTURE_BINDING_2D
|
---|
90 | #ifdef CR_NV_texture_rectangle
|
---|
91 | || pname == GL_TEXTURE_BINDING_RECTANGLE_NV
|
---|
92 | #endif
|
---|
93 | #ifdef CR_ARB_texture_cube_map
|
---|
94 | || pname == GL_TEXTURE_BINDING_CUBE_MAP_ARB
|
---|
95 | #endif
|
---|
96 | #ifdef CR_ARB_vertex_program
|
---|
97 | || pname == GL_MAX_VERTEX_ATTRIBS_ARB
|
---|
98 | #endif
|
---|
99 | #ifdef GL_EXT_framebuffer_object
|
---|
100 | || pname == GL_FRAMEBUFFER_BINDING_EXT
|
---|
101 | || pname == GL_READ_FRAMEBUFFER_BINDING_EXT
|
---|
102 | || pname == GL_DRAW_FRAMEBUFFER_BINDING_EXT
|
---|
103 | #endif
|
---|
104 | || pname == GL_ARRAY_BUFFER_BINDING
|
---|
105 | || pname == GL_ELEMENT_ARRAY_BUFFER_BINDING
|
---|
106 | || pname == GL_PIXEL_PACK_BUFFER_BINDING
|
---|
107 | || pname == GL_PIXEL_UNPACK_BUFFER_BINDING
|
---|
108 | )
|
---|
109 | {
|
---|
110 | #ifdef DEBUG
|
---|
111 | if (!crPackIsPixelStoreParm(pname)
|
---|
112 | #ifdef CR_ARB_vertex_program
|
---|
113 | && (pname!=GL_MAX_VERTEX_ATTRIBS_ARB)
|
---|
114 | #endif
|
---|
115 | )
|
---|
116 | {
|
---|
117 | unsigned int i = 0;
|
---|
118 | %s localparams;
|
---|
119 | localparams = (%s) crAlloc(__numValues(pname) * sizeof(*localparams));
|
---|
120 | crState%s(&pack_spu.StateTracker, pname, localparams);
|
---|
121 | crPack%s(%s, &writeback);
|
---|
122 | packspuFlush( (void *) thread );
|
---|
123 | CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
|
---|
124 | for (i=0; i<__numValues(pname); ++i)
|
---|
125 | {
|
---|
126 | if (localparams[i] != params[i])
|
---|
127 | {
|
---|
128 | crWarning("Incorrect local state in %s for %%x param %%i", pname, i);
|
---|
129 | crWarning("Expected %%i but got %%i", (int)localparams[i], (int)params[i]);
|
---|
130 | }
|
---|
131 | }
|
---|
132 | crFree(localparams);
|
---|
133 | return;
|
---|
134 | }
|
---|
135 | else
|
---|
136 | #endif
|
---|
137 | {
|
---|
138 | crState%s(&pack_spu.StateTracker, pname, params);
|
---|
139 | return;
|
---|
140 | }
|
---|
141 |
|
---|
142 | }
|
---|
143 | """ % (params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name, func_name))
|
---|
144 |
|
---|
145 | if func_name in vertattr_get_funcs:
|
---|
146 | print("""
|
---|
147 | if (pname != GL_CURRENT_VERTEX_ATTRIB_ARB)
|
---|
148 | {
|
---|
149 | #ifdef DEBUG
|
---|
150 | %s localparams;
|
---|
151 | localparams = (%s) crAlloc(__numValues(pname) * sizeof(*localparams));
|
---|
152 | crState%s(&pack_spu.StateTracker, index, pname, localparams);
|
---|
153 | crPack%s(index, %s, &writeback);
|
---|
154 | packspuFlush( (void *) thread );
|
---|
155 | CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
|
---|
156 | for (i=0; i<crStateHlpComponentsCount(pname); ++i)
|
---|
157 | {
|
---|
158 | if (localparams[i] != params[i])
|
---|
159 | {
|
---|
160 | crWarning("Incorrect local state in %s for %%x param %%i", pname, i);
|
---|
161 | crWarning("Expected %%i but got %%i", (int)localparams[i], (int)params[i]);
|
---|
162 | }
|
---|
163 | }
|
---|
164 | crFree(localparams);
|
---|
165 | #else
|
---|
166 | crState%s(&pack_spu.StateTracker, pname, params);
|
---|
167 | #endif
|
---|
168 | return;
|
---|
169 | }
|
---|
170 | """ % (params[-1][1], params[-1][1], func_name, func_name, apiutil.MakeCallString(params), func_name, func_name))
|
---|
171 |
|
---|
172 | params.append( ("&writeback", "foo", 0) )
|
---|
173 | print('\tcrPack%s(%s);' % (func_name, apiutil.MakeCallString( params ) ))
|
---|
174 | print('\tpackspuFlush( (void *) thread );')
|
---|
175 | print('\tCRPACKSPU_WRITEBACK_WAIT(thread, writeback);')
|
---|
176 |
|
---|
177 |
|
---|
178 |
|
---|
179 | lastParamName = params[-2][0]
|
---|
180 | if return_type != 'void':
|
---|
181 | print('\treturn return_val;')
|
---|
182 | print('}\n')
|
---|