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 |
|
---|
7 | #include "cr_packfunctions.h"
|
---|
8 | #include "packspu.h"
|
---|
9 | #include "packspu_proto.h"
|
---|
10 |
|
---|
11 | void PACKSPU_APIENTRY packspu_ChromiumParametervCR(GLenum target, GLenum type, GLsizei count, const GLvoid *values)
|
---|
12 | {
|
---|
13 |
|
---|
14 | CRMessage msg;
|
---|
15 | int len;
|
---|
16 |
|
---|
17 | GET_THREAD(thread);
|
---|
18 |
|
---|
19 |
|
---|
20 | switch(target)
|
---|
21 | {
|
---|
22 | case GL_GATHER_PACK_CR:
|
---|
23 | /* flush the current pack buffer */
|
---|
24 | packspuFlush( (void *) thread );
|
---|
25 |
|
---|
26 | /* the connection is thread->server.conn */
|
---|
27 | msg.header.type = CR_MESSAGE_GATHER;
|
---|
28 | msg.gather.offset = 69;
|
---|
29 | len = sizeof(CRMessageGather);
|
---|
30 | crNetSend(thread->netServer.conn, NULL, &msg, len);
|
---|
31 | break;
|
---|
32 |
|
---|
33 | default:
|
---|
34 | if (pack_spu.swap)
|
---|
35 | crPackChromiumParametervCRSWAP(target, type, count, values);
|
---|
36 | else
|
---|
37 | crPackChromiumParametervCR(target, type, count, values);
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 | }
|
---|
42 |
|
---|
43 | GLboolean packspuSyncOnFlushes()
|
---|
44 | {
|
---|
45 | GLint buffer;
|
---|
46 |
|
---|
47 | /*Seems to still cause issues, always sync for now*/
|
---|
48 | return 1;
|
---|
49 |
|
---|
50 | crStateGetIntegerv(GL_DRAW_BUFFER, &buffer);
|
---|
51 | /*Usually buffer==GL_BACK, so put this extra check to simplify boolean eval on runtime*/
|
---|
52 | return (buffer != GL_BACK)
|
---|
53 | && (buffer == GL_FRONT_LEFT
|
---|
54 | || buffer == GL_FRONT_RIGHT
|
---|
55 | || buffer == GL_FRONT
|
---|
56 | || buffer == GL_FRONT_AND_BACK
|
---|
57 | || buffer == GL_LEFT
|
---|
58 | || buffer == GL_RIGHT);
|
---|
59 | }
|
---|
60 |
|
---|
61 | void PACKSPU_APIENTRY packspu_DrawBuffer(GLenum mode)
|
---|
62 | {
|
---|
63 | GLboolean hadtoflush;
|
---|
64 |
|
---|
65 | hadtoflush = packspuSyncOnFlushes();
|
---|
66 |
|
---|
67 | crStateDrawBuffer(mode);
|
---|
68 | crPackDrawBuffer(mode);
|
---|
69 |
|
---|
70 | if (hadtoflush && !packspuSyncOnFlushes())
|
---|
71 | packspu_Flush();
|
---|
72 | }
|
---|
73 |
|
---|
74 | void PACKSPU_APIENTRY packspu_Finish( void )
|
---|
75 | {
|
---|
76 | GET_THREAD(thread);
|
---|
77 | GLint writeback = pack_spu.thread[0].netServer.conn->actual_network;
|
---|
78 |
|
---|
79 | if (pack_spu.swap)
|
---|
80 | {
|
---|
81 | crPackFinishSWAP();
|
---|
82 | }
|
---|
83 | else
|
---|
84 | {
|
---|
85 | crPackFinish();
|
---|
86 | }
|
---|
87 |
|
---|
88 | if (packspuSyncOnFlushes())
|
---|
89 | {
|
---|
90 | if (writeback)
|
---|
91 | {
|
---|
92 | if (pack_spu.swap)
|
---|
93 | crPackWritebackSWAP(&writeback);
|
---|
94 | else
|
---|
95 | crPackWriteback(&writeback);
|
---|
96 |
|
---|
97 | packspuFlush( (void *) thread );
|
---|
98 |
|
---|
99 | while (writeback)
|
---|
100 | crNetRecv();
|
---|
101 | }
|
---|
102 | }
|
---|
103 | }
|
---|
104 |
|
---|
105 | void PACKSPU_APIENTRY packspu_Flush( void )
|
---|
106 | {
|
---|
107 | GET_THREAD(thread);
|
---|
108 | int writeback = 1;
|
---|
109 |
|
---|
110 | crPackFlush();
|
---|
111 |
|
---|
112 | if (packspuSyncOnFlushes())
|
---|
113 | {
|
---|
114 | crPackWriteback(&writeback);
|
---|
115 | packspuFlush( (void *) thread );
|
---|
116 | while (writeback)
|
---|
117 | crNetRecv();
|
---|
118 | }
|
---|
119 | }
|
---|
120 |
|
---|
121 | GLint PACKSPU_APIENTRY packspu_WindowCreate( const char *dpyName, GLint visBits )
|
---|
122 | {
|
---|
123 | GET_THREAD(thread);
|
---|
124 | static int num_calls = 0;
|
---|
125 | int writeback = pack_spu.thread[0].netServer.conn->actual_network;
|
---|
126 | GLint return_val = (GLint) 0;
|
---|
127 |
|
---|
128 | if (!thread) {
|
---|
129 | thread = packspuNewThread( crThreadID() );
|
---|
130 | }
|
---|
131 | CRASSERT(thread);
|
---|
132 | CRASSERT(thread->packer);
|
---|
133 |
|
---|
134 | crPackSetContext(thread->packer);
|
---|
135 |
|
---|
136 | if (pack_spu.swap)
|
---|
137 | {
|
---|
138 | crPackWindowCreateSWAP( dpyName, visBits, &return_val, &writeback );
|
---|
139 | }
|
---|
140 | else
|
---|
141 | {
|
---|
142 | crPackWindowCreate( dpyName, visBits, &return_val, &writeback );
|
---|
143 | }
|
---|
144 | packspuFlush(thread);
|
---|
145 | if (!(thread->netServer.conn->actual_network))
|
---|
146 | {
|
---|
147 | return num_calls++;
|
---|
148 | }
|
---|
149 | else
|
---|
150 | {
|
---|
151 | while (writeback)
|
---|
152 | crNetRecv();
|
---|
153 | if (pack_spu.swap)
|
---|
154 | {
|
---|
155 | return_val = (GLint) SWAP32(return_val);
|
---|
156 | }
|
---|
157 | return return_val;
|
---|
158 | }
|
---|
159 | }
|
---|
160 |
|
---|
161 |
|
---|
162 |
|
---|
163 | GLboolean PACKSPU_APIENTRY
|
---|
164 | packspu_AreTexturesResident( GLsizei n, const GLuint * textures,
|
---|
165 | GLboolean * residences )
|
---|
166 | {
|
---|
167 | GET_THREAD(thread);
|
---|
168 | int writeback = 1;
|
---|
169 | GLboolean return_val = GL_TRUE;
|
---|
170 | GLsizei i;
|
---|
171 |
|
---|
172 | if (!(pack_spu.thread[0].netServer.conn->actual_network))
|
---|
173 | {
|
---|
174 | crError( "packspu_AreTexturesResident doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
|
---|
175 | }
|
---|
176 |
|
---|
177 | if (pack_spu.swap)
|
---|
178 | {
|
---|
179 | crPackAreTexturesResidentSWAP( n, textures, residences, &return_val, &writeback );
|
---|
180 | }
|
---|
181 | else
|
---|
182 | {
|
---|
183 | crPackAreTexturesResident( n, textures, residences, &return_val, &writeback );
|
---|
184 | }
|
---|
185 | packspuFlush( (void *) thread );
|
---|
186 |
|
---|
187 | while (writeback)
|
---|
188 | crNetRecv();
|
---|
189 |
|
---|
190 | /* Since the Chromium packer/unpacker can't return both 'residences'
|
---|
191 | * and the function's return value, compute the return value here.
|
---|
192 | */
|
---|
193 | for (i = 0; i < n; i++) {
|
---|
194 | if (!residences[i]) {
|
---|
195 | return_val = GL_FALSE;
|
---|
196 | break;
|
---|
197 | }
|
---|
198 | }
|
---|
199 |
|
---|
200 | return return_val;
|
---|
201 | }
|
---|
202 |
|
---|
203 |
|
---|
204 | GLboolean PACKSPU_APIENTRY
|
---|
205 | packspu_AreProgramsResidentNV( GLsizei n, const GLuint * ids,
|
---|
206 | GLboolean * residences )
|
---|
207 | {
|
---|
208 | GET_THREAD(thread);
|
---|
209 | int writeback = 1;
|
---|
210 | GLboolean return_val = GL_TRUE;
|
---|
211 | GLsizei i;
|
---|
212 |
|
---|
213 | if (!(pack_spu.thread[0].netServer.conn->actual_network))
|
---|
214 | {
|
---|
215 | crError( "packspu_AreProgramsResidentNV doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
|
---|
216 | }
|
---|
217 | if (pack_spu.swap)
|
---|
218 | {
|
---|
219 | crPackAreProgramsResidentNVSWAP( n, ids, residences, &return_val, &writeback );
|
---|
220 | }
|
---|
221 | else
|
---|
222 | {
|
---|
223 | crPackAreProgramsResidentNV( n, ids, residences, &return_val, &writeback );
|
---|
224 | }
|
---|
225 | packspuFlush( (void *) thread );
|
---|
226 |
|
---|
227 | while (writeback)
|
---|
228 | crNetRecv();
|
---|
229 |
|
---|
230 | /* Since the Chromium packer/unpacker can't return both 'residences'
|
---|
231 | * and the function's return value, compute the return value here.
|
---|
232 | */
|
---|
233 | for (i = 0; i < n; i++) {
|
---|
234 | if (!residences[i]) {
|
---|
235 | return_val = GL_FALSE;
|
---|
236 | break;
|
---|
237 | }
|
---|
238 | }
|
---|
239 |
|
---|
240 | return return_val;
|
---|
241 | }
|
---|
242 |
|
---|
243 | void PACKSPU_APIENTRY packspu_GetPolygonStipple( GLubyte * mask )
|
---|
244 | {
|
---|
245 | GET_THREAD(thread);
|
---|
246 | int writeback = 1;
|
---|
247 |
|
---|
248 | if (pack_spu.swap)
|
---|
249 | {
|
---|
250 | crPackGetPolygonStippleSWAP( mask, &writeback );
|
---|
251 | }
|
---|
252 | else
|
---|
253 | {
|
---|
254 | crPackGetPolygonStipple( mask, &writeback );
|
---|
255 | }
|
---|
256 |
|
---|
257 | #ifdef CR_ARB_pixel_buffer_object
|
---|
258 | if (!crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
|
---|
259 | #endif
|
---|
260 | {
|
---|
261 | packspuFlush( (void *) thread );
|
---|
262 | while (writeback)
|
---|
263 | crNetRecv();
|
---|
264 | }
|
---|
265 | }
|
---|
266 |
|
---|
267 | void PACKSPU_APIENTRY packspu_GetPixelMapfv( GLenum map, GLfloat * values )
|
---|
268 | {
|
---|
269 | GET_THREAD(thread);
|
---|
270 | int writeback = 1;
|
---|
271 |
|
---|
272 | if (pack_spu.swap)
|
---|
273 | {
|
---|
274 | crPackGetPixelMapfvSWAP( map, values, &writeback );
|
---|
275 | }
|
---|
276 | else
|
---|
277 | {
|
---|
278 | crPackGetPixelMapfv( map, values, &writeback );
|
---|
279 | }
|
---|
280 |
|
---|
281 | #ifdef CR_ARB_pixel_buffer_object
|
---|
282 | if (!crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
|
---|
283 | #endif
|
---|
284 | {
|
---|
285 | packspuFlush( (void *) thread );
|
---|
286 | while (writeback)
|
---|
287 | crNetRecv();
|
---|
288 | }
|
---|
289 | }
|
---|
290 |
|
---|
291 | void PACKSPU_APIENTRY packspu_GetPixelMapuiv( GLenum map, GLuint * values )
|
---|
292 | {
|
---|
293 | GET_THREAD(thread);
|
---|
294 | int writeback = 1;
|
---|
295 |
|
---|
296 | if (pack_spu.swap)
|
---|
297 | {
|
---|
298 | crPackGetPixelMapuivSWAP( map, values, &writeback );
|
---|
299 | }
|
---|
300 | else
|
---|
301 | {
|
---|
302 | crPackGetPixelMapuiv( map, values, &writeback );
|
---|
303 | }
|
---|
304 |
|
---|
305 | #ifdef CR_ARB_pixel_buffer_object
|
---|
306 | if (!crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
|
---|
307 | #endif
|
---|
308 | {
|
---|
309 | packspuFlush( (void *) thread );
|
---|
310 | while (writeback)
|
---|
311 | crNetRecv();
|
---|
312 | }
|
---|
313 | }
|
---|
314 |
|
---|
315 | void PACKSPU_APIENTRY packspu_GetPixelMapusv( GLenum map, GLushort * values )
|
---|
316 | {
|
---|
317 | GET_THREAD(thread);
|
---|
318 | int writeback = 1;
|
---|
319 |
|
---|
320 | if (pack_spu.swap)
|
---|
321 | {
|
---|
322 | crPackGetPixelMapusvSWAP( map, values, &writeback );
|
---|
323 | }
|
---|
324 | else
|
---|
325 | {
|
---|
326 | crPackGetPixelMapusv( map, values, &writeback );
|
---|
327 | }
|
---|
328 |
|
---|
329 | #ifdef CR_ARB_pixel_buffer_object
|
---|
330 | if (!crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
|
---|
331 | #endif
|
---|
332 | {
|
---|
333 | packspuFlush( (void *) thread );
|
---|
334 | while (writeback)
|
---|
335 | crNetRecv();
|
---|
336 | }
|
---|
337 | }
|
---|