VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.cpp@ 78190

Last change on this file since 78190 was 78190, checked in by vboxsync, 6 years ago

Merge first stage of the Chromium cleanup from the branch:

  • r129818 (Remove VBOX_WITH_CR_DISPLAY_LISTS and accompanying code as it was disabled since r108676 and was never brought back (see ​bugref:3456 and ​bugref:8485))
  • r129819 (HostServices/SharedOpenGL: Remove unused main entry point from upstream server process based implementation)
  • r129820 (HostServices/SharedOpenGL: Started eliminating all backends other than HGCM. They are not used and probably wouldn't work anymore anyway)
  • r129821 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crTimer* API as it is not used anywhere)
  • r129822 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill most from cr_process.h apart from two used methods)
  • r129823 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crList* API as it is unused)
  • r129824 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crHullInteriorBox API as it is unused)
  • r129825 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crWarpPoint API as it is unused)
  • r129826 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill CrSa* API as it is unused and not even compiled in)
  • r129827 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill cr_bbox.h as it is unused)
  • r129828 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove a few crParseUrl() two uses)
  • r129829 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove last crParseURL() use)
  • r129830 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove crParseURL())
  • r129831 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove VBOX_WITH_COCOA_QT and related code when not set as it is the default for years now and we don't support anything else anymore)
  • r129832 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_logo.h)
  • r129833 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused crut_api.h and crut_clientapi.h)
  • r129834 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_dmx.h)
  • r129835 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_perf.h)
  • r129836 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove cr_rand.h and friends as it is not actively used anywhere)
  • r129837 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of all the swapped versions in the packer SPU, we never change endianess from guest to host and don't need it)
  • r129838 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129839 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129840 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused pack_pica.c)
  • r129841 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129842 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_endianess.h and friends)
  • r129843 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused lowercase.py)
  • r129844 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_calllists.h and friends)
  • r129845 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of completely unused idpool.c, not even compiled in)
  • r129846 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_debugopcodes.h and friends)
  • r129847 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the cr_mem.h API inline and get rid of the implementation in the util library)
  • r129848 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of SPUOptions and related code as it is of no use for us)
  • r129849 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_environment.h and friends and convert usage to RTEnv* APIs)
  • r129850 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused renderspu_agl.c)
  • r129851 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused code in cr_htable.h)
  • r129853 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Introduce a state paremeter for the unpacker workers instead of reyling on global variables, work in progress)
  • r129854 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Let the caller of crUnpack set up the initial state. This allows to get rid of the global return_ptr and writeback_ptr as they get supplied in the unpacker state by the server)
  • r129855 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the cr_lastDispatch and cr_unpackDispatch as they are of no use now)
  • r129856 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the global cr_unpackData and cr_unpackDataEnd symbols by indtroducing another hack to make it possible for certail server dispatch callbacks to access the data buffer)
  • r129857 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: build fix for release builds)
  • r129858 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the pointer to the unpacker state non const (is required for the access verification))
  • r129859 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: First iteration of the buffer size validation to prevent out of bound read access + added todos for places where additional checks are needed)
  • r129860 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129861 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129871 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129872 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Stop as soon as the unpacker encountered an error)
  • r129876 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129880 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129882 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Fixed some offsets in unpack_texture.c, 3DMark03 renders correctly again)
  • r130013 (HostServices/SharedOpenGL: Convert files to C++ so we can use C99 featuers on Windows with cl.exe)
  • r130014 (HostServices/SharedOpenGL,GuestHost/OpenGL: WIndows build fixes)
  • r130015 (HostServices/SharedOpenGL,GuestHost/OpenGL: More Windows build fixes)
  • r130036 (Config.kmk: Fix linker error on Windows by temporarily disabling the use of VBoxGuestR3DllMinW2K)
  • r130094 (src/VBox/GuestHost/OpenGL: Revert inlining the allocation/free functions in R3 completely as it doesn't work on Windows if memory is allocated and freed across different DLLs which don't share a common CRT, causes crashes in RtlValidtaeHeap())
  • r130095 (src/VBox/GuestHost/OpenGL,src/VBox/Additions/common/crOpenGL/pack: Don't use floating point specifiers in packspu_GetString() to avoid R6002 errors (couldn't fully understand why they occur suddenly after the rework but this gets rid of it))
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 16.6 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 */
6
7#include "cr_spu.h"
8#include "chromium.h"
9#include "cr_error.h"
10#include "cr_net.h"
11#include "server_dispatch.h"
12#include "server.h"
13#include "cr_mem.h"
14#include "cr_string.h"
15
16GLint SERVER_DISPATCH_APIENTRY
17crServerDispatchCreateContext(const char *dpyName, GLint visualBits, GLint shareCtx)
18{
19 return crServerDispatchCreateContextEx(dpyName, visualBits, shareCtx, -1, -1);
20}
21
22GLint crServerDispatchCreateContextEx(const char *dpyName, GLint visualBits, GLint shareCtx, GLint preloadCtxID, int32_t internalID)
23{
24 GLint retVal = -1;
25 CRContext *newCtx;
26 CRContextInfo *pContextInfo;
27 GLboolean fFirst = GL_FALSE;
28
29 dpyName = "";
30
31 if (shareCtx > 0) {
32 crWarning("CRServer: context sharing not implemented.");
33 shareCtx = 0;
34 }
35
36 pContextInfo = (CRContextInfo *) crAlloc(sizeof (CRContextInfo));
37 if (!pContextInfo)
38 {
39 crWarning("failed to alloc context info!");
40 return -1;
41 }
42
43 pContextInfo->currentMural = NULL;
44
45 pContextInfo->CreateInfo.requestedVisualBits = visualBits;
46
47 if (cr_server.fVisualBitsDefault)
48 visualBits = cr_server.fVisualBitsDefault;
49
50 pContextInfo->CreateInfo.realVisualBits = visualBits;
51
52 /* Since the Cr server serialized all incoming clients/contexts into
53 * one outgoing GL stream, we only need to create one context for the
54 * head SPU. We'll only have to make it current once too, below.
55 */
56 if (cr_server.firstCallCreateContext) {
57 cr_server.MainContextInfo.CreateInfo.realVisualBits = visualBits;
58 cr_server.MainContextInfo.SpuContext = cr_server.head_spu->dispatch_table.
59 CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.realVisualBits, shareCtx);
60 if (cr_server.MainContextInfo.SpuContext < 0) {
61 crWarning("crServerDispatchCreateContext() failed.");
62 crFree(pContextInfo);
63 return -1;
64 }
65 cr_server.MainContextInfo.pContext = crStateCreateContext(&cr_server.limits, visualBits, NULL);
66 CRASSERT(cr_server.MainContextInfo.pContext);
67 cr_server.firstCallCreateContext = GL_FALSE;
68 fFirst = GL_TRUE;
69
70 cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_SET_DEFAULT_SHARED_CTX, cr_server.MainContextInfo.SpuContext);
71 }
72 else {
73 /* second or third or ... context */
74 if (!cr_server.bUseMultipleContexts && ((visualBits & cr_server.MainContextInfo.CreateInfo.realVisualBits) != visualBits)) {
75 int oldSpuContext;
76 /* should never be here */
77 CRASSERT(0);
78 /* the new context needs new visual attributes */
79 cr_server.MainContextInfo.CreateInfo.realVisualBits |= visualBits;
80 crWarning("crServerDispatchCreateContext requires new visual (0x%x).",
81 cr_server.MainContextInfo.CreateInfo.realVisualBits);
82
83 /* Here, we used to just destroy the old rendering context.
84 * Unfortunately, this had the side effect of destroying
85 * all display lists and textures that had been loaded on
86 * the old context as well.
87 *
88 * Now, first try to create a new context, with a suitable
89 * visual, sharing display lists and textures with the
90 * old context. Then destroy the old context.
91 */
92
93 /* create new rendering context with suitable visual */
94 oldSpuContext = cr_server.MainContextInfo.SpuContext;
95 cr_server.MainContextInfo.SpuContext = cr_server.head_spu->dispatch_table.
96 CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.realVisualBits, cr_server.MainContextInfo.SpuContext);
97 /* destroy old rendering context */
98 cr_server.head_spu->dispatch_table.DestroyContext(oldSpuContext);
99 if (cr_server.MainContextInfo.SpuContext < 0) {
100 crWarning("crServerDispatchCreateContext() failed.");
101 crFree(pContextInfo);
102 return -1;
103 }
104
105 /* we do not need to clean up the old default context explicitly, since the above cr_server.head_spu->dispatch_table.DestroyContext call
106 * will do that for us */
107 cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_SET_DEFAULT_SHARED_CTX, cr_server.MainContextInfo.SpuContext);
108 }
109 }
110
111 if (cr_server.bUseMultipleContexts) {
112 pContextInfo->SpuContext = cr_server.head_spu->dispatch_table.
113 CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.realVisualBits, cr_server.MainContextInfo.SpuContext);
114 if (pContextInfo->SpuContext < 0) {
115 crWarning("crServerDispatchCreateContext() failed.");
116 crStateEnableDiffOnMakeCurrent(GL_TRUE);
117 cr_server.bUseMultipleContexts = GL_FALSE;
118 if (!fFirst)
119 crError("creating shared context failed, while it is expected to work!");
120 }
121 else if (fFirst)
122 {
123 crStateEnableDiffOnMakeCurrent(GL_FALSE);
124 }
125 }
126 else
127 {
128 pContextInfo->SpuContext = -1;
129 }
130
131 /* Now create a new state-tracker context and initialize the
132 * dispatch function pointers.
133 */
134 newCtx = crStateCreateContextEx(&cr_server.limits, visualBits, NULL, internalID);
135 if (newCtx) {
136 crStateSetCurrentPointers( newCtx, &(cr_server.current) );
137 crStateResetCurrentPointers(&(cr_server.current));
138 retVal = preloadCtxID<0 ? (GLint)crHashtableAllocKeys( cr_server.contextTable, 1 ) : preloadCtxID;
139
140 pContextInfo->pContext = newCtx;
141 Assert(pContextInfo->CreateInfo.realVisualBits == visualBits);
142 pContextInfo->CreateInfo.externalID = retVal;
143 pContextInfo->CreateInfo.pszDpyName = dpyName ? crStrdup(dpyName) : NULL;
144 crHashtableAdd(cr_server.contextTable, retVal, pContextInfo);
145 }
146
147 if (retVal != -1 && !cr_server.bIsInLoadingState) {
148 int pos;
149 for (pos = 0; pos < CR_MAX_CONTEXTS; pos++) {
150 if (cr_server.curClient->contextList[pos] == 0) {
151 cr_server.curClient->contextList[pos] = retVal;
152 break;
153 }
154 }
155 }
156
157 crServerReturnValue( &retVal, sizeof(retVal) );
158
159 return retVal;
160}
161
162static int crServerRemoveClientContext(CRClient *pClient, GLint ctx)
163{
164 int pos;
165
166 for (pos = 0; pos < CR_MAX_CONTEXTS; ++pos)
167 {
168 if (pClient->contextList[pos] == ctx)
169 {
170 pClient->contextList[pos] = 0;
171 return true;
172 }
173 }
174
175 return false;
176}
177
178static void crServerCleanupMuralCtxUsageCB(unsigned long key, void *data1, void *data2)
179{
180 CRMuralInfo *mural = (CRMuralInfo *) data1;
181 CRContext *ctx = (CRContext *) data2;
182
183 CR_STATE_SHAREDOBJ_USAGE_CLEAR(mural, ctx);
184}
185
186void SERVER_DISPATCH_APIENTRY
187crServerDispatchDestroyContext( GLint ctx )
188{
189 CRContextInfo *crCtxInfo;
190 CRContext *crCtx;
191 int32_t client;
192 CRClientNode *pNode;
193 int found=false;
194
195 crCtxInfo = (CRContextInfo *) crHashtableSearch(cr_server.contextTable, ctx);
196 if (!crCtxInfo) {
197 crWarning("CRServer: DestroyContext invalid context %d", ctx);
198 return;
199 }
200 crCtx = crCtxInfo->pContext;
201 CRASSERT(crCtx);
202
203 crDebug("CRServer: DestroyContext context %d", ctx);
204
205 if (cr_server.currentCtxInfo == crCtxInfo)
206 {
207 CRMuralInfo *dummyMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
208 crServerPerformMakeCurrent(dummyMural, &cr_server.MainContextInfo);
209 CRASSERT(cr_server.currentCtxInfo == &cr_server.MainContextInfo);
210 }
211
212 crHashtableWalk(cr_server.muralTable, crServerCleanupMuralCtxUsageCB, crCtx);
213 crCtxInfo->currentMural = NULL;
214 crHashtableDelete(cr_server.contextTable, ctx, NULL);
215 crStateDestroyContext( crCtx );
216
217 if (crCtxInfo->CreateInfo.pszDpyName)
218 crFree(crCtxInfo->CreateInfo.pszDpyName);
219
220 if (crCtxInfo->SpuContext >= 0)
221 cr_server.head_spu->dispatch_table.DestroyContext(crCtxInfo->SpuContext);
222
223 crFree(crCtxInfo);
224
225 if (cr_server.curClient)
226 {
227 /* If we delete our current context, default back to the null context */
228 if (cr_server.curClient->currentCtxInfo == crCtxInfo) {
229 cr_server.curClient->currentContextNumber = -1;
230 cr_server.curClient->currentCtxInfo = &cr_server.MainContextInfo;
231 }
232
233 found = crServerRemoveClientContext(cr_server.curClient, ctx);
234
235 /*Some application call destroy context not in a thread where it was created...have do deal with it.*/
236 if (!found)
237 {
238 for (client=0; client<cr_server.numClients; ++client)
239 {
240 if (cr_server.clients[client]==cr_server.curClient)
241 continue;
242
243 found = crServerRemoveClientContext(cr_server.clients[client], ctx);
244
245 if (found) break;
246 }
247 }
248
249 if (!found)
250 {
251 pNode=cr_server.pCleanupClient;
252
253 while (pNode && !found)
254 {
255 found = crServerRemoveClientContext(pNode->pClient, ctx);
256 pNode = pNode->next;
257 }
258 }
259
260 CRASSERT(found);
261 }
262
263 /*Make sure this context isn't active in other clients*/
264 for (client=0; client<cr_server.numClients; ++client)
265 {
266 if (cr_server.clients[client]->currentCtxInfo == crCtxInfo)
267 {
268 cr_server.clients[client]->currentContextNumber = -1;
269 cr_server.clients[client]->currentCtxInfo = &cr_server.MainContextInfo;
270 }
271 }
272
273 pNode=cr_server.pCleanupClient;
274 while (pNode)
275 {
276 if (pNode->pClient->currentCtxInfo == crCtxInfo)
277 {
278 pNode->pClient->currentContextNumber = -1;
279 pNode->pClient->currentCtxInfo = &cr_server.MainContextInfo;
280 }
281 pNode = pNode->next;
282 }
283
284 CRASSERT(cr_server.currentCtxInfo != crCtxInfo);
285}
286
287void crServerPerformMakeCurrent( CRMuralInfo *mural, CRContextInfo *ctxInfo )
288{
289 CRMuralInfo *oldMural;
290 CRContext *ctx, *oldCtx = NULL;
291 GLuint idDrawFBO, idReadFBO;
292 GLint context = ctxInfo->CreateInfo.externalID;
293 GLint window = mural->CreateInfo.externalID;
294
295 cr_server.bForceMakeCurrentOnClientSwitch = GL_FALSE;
296
297 ctx = ctxInfo->pContext;
298 CRASSERT(ctx);
299
300 oldMural = cr_server.currentMural;
301
302 /* Ubuntu 11.04 hosts misbehave if context window switch is
303 * done with non-default framebuffer object settings.
304 * crStateSwitchPrepare & crStateSwitchPostprocess are supposed to work around this problem
305 * crStateSwitchPrepare restores the FBO state to its default values before the context window switch,
306 * while crStateSwitchPostprocess restores it back to the original values */
307 oldCtx = crStateGetCurrent();
308 if (oldMural && oldMural->fRedirected && crServerSupportRedirMuralFBO())
309 {
310 idDrawFBO = CR_SERVER_FBO_FOR_IDX(oldMural, oldMural->iCurDrawBuffer);
311 idReadFBO = CR_SERVER_FBO_FOR_IDX(oldMural, oldMural->iCurReadBuffer);
312 }
313 else
314 {
315 idDrawFBO = 0;
316 idReadFBO = 0;
317 }
318 crStateSwitchPrepare(cr_server.bUseMultipleContexts ? NULL : ctx, oldCtx, idDrawFBO, idReadFBO);
319
320 if (cr_server.curClient)
321 {
322 /*
323 crDebug("**** %s client %d curCtx=%d curWin=%d", __func__,
324 cr_server.curClient->number, ctxPos, window);
325 */
326 cr_server.curClient->currentContextNumber = context;
327 cr_server.curClient->currentCtxInfo = ctxInfo;
328 cr_server.curClient->currentMural = mural;
329 cr_server.curClient->currentWindow = window;
330
331 CRASSERT(cr_server.curClient->currentCtxInfo);
332 CRASSERT(cr_server.curClient->currentCtxInfo->pContext);
333 }
334
335 /* This is a hack to force updating the 'current' attribs */
336 crStateUpdateColorBits();
337
338 if (ctx)
339 crStateSetCurrentPointers( ctx, &(cr_server.current) );
340
341 /* check if being made current for first time, update viewport */
342#if 0
343 if (ctx) {
344 /* initialize the viewport */
345 if (ctx->viewport.viewportW == 0) {
346 ctx->viewport.viewportW = mural->width;
347 ctx->viewport.viewportH = mural->height;
348 ctx->viewport.scissorW = mural->width;
349 ctx->viewport.scissorH = mural->height;
350 }
351 }
352#endif
353
354 /*
355 crDebug("**** %s currentWindow %d newWindow %d", __func__,
356 cr_server.currentWindow, window);
357 */
358
359 if (1/*cr_server.firstCallMakeCurrent ||
360 cr_server.currentWindow != window ||
361 cr_server.currentNativeWindow != nativeWindow*/) {
362 /* Since the cr server serialized all incoming contexts/clients into
363 * one output stream of GL commands, we only need to call the head
364 * SPU's MakeCurrent() function once.
365 * BUT, if we're rendering to multiple windows, we do have to issue
366 * MakeCurrent() calls sometimes. The same GL context will always be
367 * used though.
368 */
369 cr_server.head_spu->dispatch_table.MakeCurrent( mural->spuWindow,
370 0,
371 ctxInfo->SpuContext >= 0
372 ? ctxInfo->SpuContext
373 : cr_server.MainContextInfo.SpuContext);
374
375 CR_STATE_SHAREDOBJ_USAGE_SET(mural, ctx);
376 if (cr_server.currentCtxInfo)
377 cr_server.currentCtxInfo->currentMural = NULL;
378 ctxInfo->currentMural = mural;
379
380 cr_server.firstCallMakeCurrent = GL_FALSE;
381 cr_server.currentCtxInfo = ctxInfo;
382 cr_server.currentWindow = window;
383 cr_server.currentNativeWindow = 0;
384 cr_server.currentMural = mural;
385 }
386
387 /* This used to be earlier, after crStateUpdateColorBits() call */
388 crStateMakeCurrent( ctx );
389
390 if (mural && mural->fRedirected && crServerSupportRedirMuralFBO())
391 {
392 GLuint id = crServerMuralFBOIdxFromBufferName(mural, ctx->buffer.drawBuffer);
393 if (id != mural->iCurDrawBuffer)
394 {
395 crDebug("DBO draw buffer changed on make current");
396 mural->iCurDrawBuffer = id;
397 }
398
399 id = crServerMuralFBOIdxFromBufferName(mural, ctx->buffer.readBuffer);
400 if (id != mural->iCurReadBuffer)
401 {
402 crDebug("DBO read buffer changed on make current");
403 mural->iCurReadBuffer = id;
404 }
405
406 idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
407 idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
408 }
409 else
410 {
411 idDrawFBO = 0;
412 idReadFBO = 0;
413 }
414 crStateSwitchPostprocess(ctx, cr_server.bUseMultipleContexts ? NULL : oldCtx, idDrawFBO, idReadFBO);
415
416 if (!ctx->framebufferobject.drawFB
417 && (ctx->buffer.drawBuffer == GL_FRONT || ctx->buffer.drawBuffer == GL_FRONT_LEFT)
418 && cr_server.curClient)
419 cr_server.curClient->currentMural->bFbDraw = GL_TRUE;
420
421 if (!mural->fRedirected)
422 {
423 ctx->buffer.width = mural->width;
424 ctx->buffer.height = mural->height;
425 }
426 else
427 {
428 ctx->buffer.width = 0;
429 ctx->buffer.height = 0;
430 }
431}
432
433
434void SERVER_DISPATCH_APIENTRY
435crServerDispatchMakeCurrent( GLint window, GLint nativeWindow, GLint context )
436{
437 CRMuralInfo *mural;
438 CRContextInfo *ctxInfo = NULL;
439
440 if (context >= 0 && window >= 0) {
441 mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
442 if (!mural)
443 {
444 crWarning("CRServer: invalid window %d passed to crServerDispatchMakeCurrent()", window);
445 return;
446 }
447
448 /* Update the state tracker's current context */
449 ctxInfo = (CRContextInfo *) crHashtableSearch(cr_server.contextTable, context);
450 if (!ctxInfo) {
451 crWarning("CRserver: NULL context in MakeCurrent %d", context);
452 return;
453 }
454 }
455 else {
456#if 0
457 oldMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, cr_server.currentWindow);
458 if (oldMural && oldMural->bUseFBO && crServerSupportRedirMuralFBO())
459 {
460 if (!crStateGetCurrent()->framebufferobject.drawFB)
461 {
462 cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0);
463 }
464 if (!crStateGetCurrent()->framebufferobject.readFB)
465 {
466 cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, 0);
467 }
468 }
469
470 ctxInfo = &cr_server.MainContextInfo;
471 window = -1;
472 mural = NULL;
473#endif
474 cr_server.bForceMakeCurrentOnClientSwitch = GL_TRUE;
475 return;
476 }
477
478 crServerPerformMakeCurrent( mural, ctxInfo );
479}
480
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