VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c@ 23021

最後變更 在這個檔案從23021是 21127,由 vboxsync 提交於 16 年 前

crOpenGL: fix window/context management for multithreaded apps

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 5.6 KB
 
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
11void 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
43GLboolean packspuSyncOnFlushes()
44{
45 GLint buffer;
46 crStateGetIntegerv(GL_DRAW_BUFFER, &buffer);
47 /*Usually buffer==GL_BACK, so put this extra check to simplify boolean eval on runtime*/
48 return (buffer != GL_BACK)
49 && (buffer == GL_FRONT_LEFT
50 || buffer == GL_FRONT_RIGHT
51 || buffer == GL_FRONT
52 || buffer == GL_FRONT_AND_BACK
53 || buffer == GL_LEFT
54 || buffer == GL_RIGHT);
55}
56
57void PACKSPU_APIENTRY packspu_DrawBuffer(GLenum mode)
58{
59 crStateDrawBuffer(mode);
60 crPackDrawBuffer(mode);
61}
62
63void PACKSPU_APIENTRY packspu_Finish( void )
64{
65 GET_THREAD(thread);
66 GLint writeback = pack_spu.thread[0].netServer.conn->actual_network;
67
68 if (pack_spu.swap)
69 {
70 crPackFinishSWAP();
71 }
72 else
73 {
74 crPackFinish();
75 }
76
77 if (packspuSyncOnFlushes())
78 {
79 packspuFlush( (void *) thread );
80
81 if (writeback)
82 {
83 if (pack_spu.swap)
84 crPackWritebackSWAP(&writeback);
85 else
86 crPackWriteback(&writeback);
87 }
88
89 while (writeback)
90 crNetRecv();
91 }
92}
93
94void PACKSPU_APIENTRY packspu_Flush( void )
95{
96 GET_THREAD(thread);
97 if (pack_spu.swap)
98 {
99 crPackFlushSWAP();
100 }
101 else
102 {
103 crPackFlush();
104 }
105
106 if (packspuSyncOnFlushes())
107 {
108 packspuFlush( (void *) thread );
109 }
110}
111
112GLint PACKSPU_APIENTRY packspu_WindowCreate( const char *dpyName, GLint visBits )
113{
114 GET_THREAD(thread);
115 static int num_calls = 0;
116 int writeback = pack_spu.thread[0].netServer.conn->actual_network;
117 GLint return_val = (GLint) 0;
118
119 if (!thread) {
120 thread = packspuNewThread( crThreadID() );
121 }
122 CRASSERT(thread);
123 CRASSERT(thread->packer);
124
125 crPackSetContext(thread->packer);
126
127 if (pack_spu.swap)
128 {
129 crPackWindowCreateSWAP( dpyName, visBits, &return_val, &writeback );
130 }
131 else
132 {
133 crPackWindowCreate( dpyName, visBits, &return_val, &writeback );
134 }
135 packspuFlush(thread);
136 if (!(thread->netServer.conn->actual_network))
137 {
138 return num_calls++;
139 }
140 else
141 {
142 while (writeback)
143 crNetRecv();
144 if (pack_spu.swap)
145 {
146 return_val = (GLint) SWAP32(return_val);
147 }
148 return return_val;
149 }
150}
151
152
153
154GLboolean PACKSPU_APIENTRY
155packspu_AreTexturesResident( GLsizei n, const GLuint * textures,
156 GLboolean * residences )
157{
158 GET_THREAD(thread);
159 int writeback = 1;
160 GLboolean return_val = GL_TRUE;
161 GLsizei i;
162
163 if (!(pack_spu.thread[0].netServer.conn->actual_network))
164 {
165 crError( "packspu_AreTexturesResident doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
166 }
167
168 if (pack_spu.swap)
169 {
170 crPackAreTexturesResidentSWAP( n, textures, residences, &return_val, &writeback );
171 }
172 else
173 {
174 crPackAreTexturesResident( n, textures, residences, &return_val, &writeback );
175 }
176 packspuFlush( (void *) thread );
177
178 while (writeback)
179 crNetRecv();
180
181 /* Since the Chromium packer/unpacker can't return both 'residences'
182 * and the function's return value, compute the return value here.
183 */
184 for (i = 0; i < n; i++) {
185 if (!residences[i]) {
186 return_val = GL_FALSE;
187 break;
188 }
189 }
190
191 return return_val;
192}
193
194
195GLboolean PACKSPU_APIENTRY
196packspu_AreProgramsResidentNV( GLsizei n, const GLuint * ids,
197 GLboolean * residences )
198{
199 GET_THREAD(thread);
200 int writeback = 1;
201 GLboolean return_val = GL_TRUE;
202 GLsizei i;
203
204 if (!(pack_spu.thread[0].netServer.conn->actual_network))
205 {
206 crError( "packspu_AreProgramsResidentNV doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
207 }
208 if (pack_spu.swap)
209 {
210 crPackAreProgramsResidentNVSWAP( n, ids, residences, &return_val, &writeback );
211 }
212 else
213 {
214 crPackAreProgramsResidentNV( n, ids, residences, &return_val, &writeback );
215 }
216 packspuFlush( (void *) thread );
217
218 while (writeback)
219 crNetRecv();
220
221 /* Since the Chromium packer/unpacker can't return both 'residences'
222 * and the function's return value, compute the return value here.
223 */
224 for (i = 0; i < n; i++) {
225 if (!residences[i]) {
226 return_val = GL_FALSE;
227 break;
228 }
229 }
230
231 return return_val;
232}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette