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 | void PACKSPU_APIENTRY packspu_Finish( void )
|
---|
44 | {
|
---|
45 | GET_THREAD(thread);
|
---|
46 | GLint writeback = pack_spu.thread[0].netServer.conn->actual_network;
|
---|
47 | if (pack_spu.swap)
|
---|
48 | {
|
---|
49 | crPackFinishSWAP( );
|
---|
50 | if (writeback)
|
---|
51 | crPackWritebackSWAP( &writeback );
|
---|
52 | }
|
---|
53 | else
|
---|
54 | {
|
---|
55 | crPackFinish( );
|
---|
56 | if (writeback)
|
---|
57 | crPackWriteback( &writeback );
|
---|
58 | }
|
---|
59 | packspuFlush( (void *) thread );
|
---|
60 | while (writeback)
|
---|
61 | crNetRecv();
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | GLint PACKSPU_APIENTRY packspu_WindowCreate( const char *dpyName, GLint visBits )
|
---|
66 | {
|
---|
67 | static int num_calls = 0;
|
---|
68 | int writeback = pack_spu.thread[0].netServer.conn->actual_network;
|
---|
69 | GLint return_val = (GLint) 0;
|
---|
70 |
|
---|
71 | /* WindowCreate is special - just like CreateContext.
|
---|
72 | * GET_THREAD(thread) doesn't work as the thread won't have called
|
---|
73 | * MakeCurrent yet, so we've got to use the first thread's packer
|
---|
74 | * buffer.
|
---|
75 | */
|
---|
76 |
|
---|
77 | crPackSetContext( pack_spu.thread[0].packer );
|
---|
78 |
|
---|
79 | if (pack_spu.swap)
|
---|
80 | {
|
---|
81 | crPackWindowCreateSWAP( dpyName, visBits, &return_val, &writeback );
|
---|
82 | }
|
---|
83 | else
|
---|
84 | {
|
---|
85 | crPackWindowCreate( dpyName, visBits, &return_val, &writeback );
|
---|
86 | }
|
---|
87 | packspuFlush( &pack_spu.thread[0] );
|
---|
88 | if (!(pack_spu.thread[0].netServer.conn->actual_network))
|
---|
89 | {
|
---|
90 | return num_calls++;
|
---|
91 | }
|
---|
92 | else
|
---|
93 | {
|
---|
94 | while (writeback)
|
---|
95 | crNetRecv();
|
---|
96 | if (pack_spu.swap)
|
---|
97 | {
|
---|
98 | return_val = (GLint) SWAP32(return_val);
|
---|
99 | }
|
---|
100 | return return_val;
|
---|
101 | }
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 |
|
---|
106 | GLboolean PACKSPU_APIENTRY
|
---|
107 | packspu_AreTexturesResident( GLsizei n, const GLuint * textures,
|
---|
108 | GLboolean * residences )
|
---|
109 | {
|
---|
110 | GET_THREAD(thread);
|
---|
111 | int writeback = 1;
|
---|
112 | GLboolean return_val = GL_TRUE;
|
---|
113 | GLsizei i;
|
---|
114 |
|
---|
115 | if (!(pack_spu.thread[0].netServer.conn->actual_network))
|
---|
116 | {
|
---|
117 | crError( "packspu_AreTexturesResident doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
|
---|
118 | }
|
---|
119 |
|
---|
120 | if (pack_spu.swap)
|
---|
121 | {
|
---|
122 | crPackAreTexturesResidentSWAP( n, textures, residences, &return_val, &writeback );
|
---|
123 | }
|
---|
124 | else
|
---|
125 | {
|
---|
126 | crPackAreTexturesResident( n, textures, residences, &return_val, &writeback );
|
---|
127 | }
|
---|
128 | packspuFlush( (void *) thread );
|
---|
129 |
|
---|
130 | while (writeback)
|
---|
131 | crNetRecv();
|
---|
132 |
|
---|
133 | /* Since the Chromium packer/unpacker can't return both 'residences'
|
---|
134 | * and the function's return value, compute the return value here.
|
---|
135 | */
|
---|
136 | for (i = 0; i < n; i++) {
|
---|
137 | if (!residences[i]) {
|
---|
138 | return_val = GL_FALSE;
|
---|
139 | break;
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 | return return_val;
|
---|
144 | }
|
---|
145 |
|
---|
146 |
|
---|
147 | GLboolean PACKSPU_APIENTRY
|
---|
148 | packspu_AreProgramsResidentNV( GLsizei n, const GLuint * ids,
|
---|
149 | GLboolean * residences )
|
---|
150 | {
|
---|
151 | GET_THREAD(thread);
|
---|
152 | int writeback = 1;
|
---|
153 | GLboolean return_val = GL_TRUE;
|
---|
154 | GLsizei i;
|
---|
155 |
|
---|
156 | if (!(pack_spu.thread[0].netServer.conn->actual_network))
|
---|
157 | {
|
---|
158 | crError( "packspu_AreProgramsResidentNV doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
|
---|
159 | }
|
---|
160 | if (pack_spu.swap)
|
---|
161 | {
|
---|
162 | crPackAreProgramsResidentNVSWAP( n, ids, residences, &return_val, &writeback );
|
---|
163 | }
|
---|
164 | else
|
---|
165 | {
|
---|
166 | crPackAreProgramsResidentNV( n, ids, residences, &return_val, &writeback );
|
---|
167 | }
|
---|
168 | packspuFlush( (void *) thread );
|
---|
169 |
|
---|
170 | while (writeback)
|
---|
171 | crNetRecv();
|
---|
172 |
|
---|
173 | /* Since the Chromium packer/unpacker can't return both 'residences'
|
---|
174 | * and the function's return value, compute the return value here.
|
---|
175 | */
|
---|
176 | for (i = 0; i < n; i++) {
|
---|
177 | if (!residences[i]) {
|
---|
178 | return_val = GL_FALSE;
|
---|
179 | break;
|
---|
180 | }
|
---|
181 | }
|
---|
182 |
|
---|
183 | return return_val;
|
---|
184 | }
|
---|