Changeset 40692 in vbox
- Timestamp:
- Mar 28, 2012 3:50:46 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 77148
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.c
r39815 r40692 25 25 GLint retVal = -1; 26 26 CRContext *newCtx; 27 CRCreateInfo_t *pCreateInfo; 27 CRContextInfo *pContextInfo; 28 GLboolean fFirst = GL_FALSE; 28 29 29 30 if (shareCtx > 0) { … … 31 32 shareCtx = 0; 32 33 } 34 35 pContextInfo = (CRContextInfo *) crAlloc(sizeof (CRContextInfo)); 36 if (!pContextInfo) 37 { 38 crWarning("failed to alloc context info!"); 39 return -1; 40 } 41 42 pContextInfo->CreateInfo.visualBits = visualBits; 33 43 34 44 /* Since the Cr server serialized all incoming clients/contexts into … … 37 47 */ 38 48 if (cr_server.firstCallCreateContext) { 39 cr_server. SpuContextVisBits = visualBits;40 cr_server. SpuContext = cr_server.head_spu->dispatch_table.41 CreateContext(dpyName, cr_server. SpuContextVisBits, shareCtx);42 if (cr_server. SpuContext < 0) {49 cr_server.MainContextInfo.CreateInfo.visualBits = visualBits; 50 cr_server.MainContextInfo.SpuContext = cr_server.head_spu->dispatch_table. 51 CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.visualBits, shareCtx); 52 if (cr_server.MainContextInfo.SpuContext < 0) { 43 53 crWarning("crServerDispatchCreateContext() failed."); 54 crFree(pContextInfo); 44 55 return -1; 45 56 } 46 57 cr_server.firstCallCreateContext = GL_FALSE; 58 fFirst = GL_TRUE; 47 59 } 48 60 else { 49 61 /* second or third or ... context */ 50 if ( (visualBits & cr_server.SpuContextVisBits) != visualBits) {62 if (!cr_server.bUseMultipleContexts && ((visualBits & cr_server.MainContextInfo.CreateInfo.visualBits) != visualBits)) { 51 63 int oldSpuContext; 52 64 53 65 /* the new context needs new visual attributes */ 54 cr_server. SpuContextVisBits |= visualBits;66 cr_server.MainContextInfo.CreateInfo.visualBits |= visualBits; 55 67 crDebug("crServerDispatchCreateContext requires new visual (0x%x).", 56 cr_server. SpuContextVisBits);68 cr_server.MainContextInfo.CreateInfo.visualBits); 57 69 58 70 /* Here, we used to just destroy the old rendering context. … … 67 79 68 80 /* create new rendering context with suitable visual */ 69 oldSpuContext = cr_server. SpuContext;70 cr_server. SpuContext = cr_server.head_spu->dispatch_table.71 CreateContext(dpyName, cr_server. SpuContextVisBits, cr_server.SpuContext);81 oldSpuContext = cr_server.MainContextInfo.SpuContext; 82 cr_server.MainContextInfo.SpuContext = cr_server.head_spu->dispatch_table. 83 CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.visualBits, cr_server.MainContextInfo.SpuContext); 72 84 /* destroy old rendering context */ 73 85 cr_server.head_spu->dispatch_table.DestroyContext(oldSpuContext); 74 if (cr_server. SpuContext < 0) {86 if (cr_server.MainContextInfo.SpuContext < 0) { 75 87 crWarning("crServerDispatchCreateContext() failed."); 88 crFree(pContextInfo); 76 89 return -1; 77 90 } 78 91 } 92 } 93 94 if (cr_server.bUseMultipleContexts) { 95 pContextInfo->SpuContext = cr_server.head_spu->dispatch_table. 96 CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.visualBits, cr_server.MainContextInfo.SpuContext); 97 if (pContextInfo->SpuContext < 0) { 98 crWarning("crServerDispatchCreateContext() failed."); 99 crStateEnableDiffOnMakeCurrent(GL_TRUE); 100 cr_server.bUseMultipleContexts = GL_FALSE; 101 if (!fFirst) 102 crError("creating shared context failed, while it is expected to work!"); 103 } 104 else if (fFirst) 105 { 106 crStateEnableDiffOnMakeCurrent(GL_FALSE); 107 } 108 } 109 else 110 { 111 pContextInfo->SpuContext = -1; 79 112 } 80 113 … … 87 120 crStateResetCurrentPointers(&(cr_server.current)); 88 121 retVal = preloadCtxID<0 ? crServerGenerateID(&cr_server.idsPool.freeContextID) : preloadCtxID; 89 crHashtableAdd(cr_server.contextTable, retVal, newCtx); 90 91 pCreateInfo = (CRCreateInfo_t *) crAlloc(sizeof(CRCreateInfo_t)); 92 pCreateInfo->pszDpyName = dpyName ? crStrdup(dpyName) : NULL; 93 pCreateInfo->visualBits = visualBits; 94 pCreateInfo->internalID = newCtx->id; 95 crHashtableAdd(cr_server.pContextCreateInfoTable, retVal, pCreateInfo); 122 123 pContextInfo->pContext = newCtx; 124 pContextInfo->CreateInfo.visualBits = visualBits; 125 pContextInfo->CreateInfo.internalID = newCtx->id; 126 pContextInfo->CreateInfo.pszDpyName = dpyName ? crStrdup(dpyName) : NULL; 127 crHashtableAdd(cr_server.contextTable, retVal, pContextInfo); 96 128 } 97 129 … … 149 181 crServerDispatchDestroyContext( GLint ctx ) 150 182 { 183 CRContextInfo *crCtxInfo; 151 184 CRContext *crCtx; 152 185 int32_t client; … … 154 187 int found=false; 155 188 156 crCtx = (CRContext*) crHashtableSearch(cr_server.contextTable, ctx);157 if (!crCtx ) {189 crCtxInfo = (CRContextInfo *) crHashtableSearch(cr_server.contextTable, ctx); 190 if (!crCtxInfo) { 158 191 crWarning("CRServer: DestroyContext invalid context %d", ctx); 159 192 return; 160 193 } 194 crCtx = crCtxInfo->pContext; 195 CRASSERT(crCtx); 161 196 162 197 crDebug("CRServer: DestroyContext context %d", ctx); … … 164 199 crHashtableDelete(cr_server.contextTable, ctx, NULL); 165 200 crStateDestroyContext( crCtx ); 166 crHashtableDelete(cr_server.pContextCreateInfoTable, ctx, crServerCreateInfoDeleteCB); 201 202 if (crCtxInfo->CreateInfo.pszDpyName) 203 crFree(crCtxInfo->CreateInfo.pszDpyName); 204 205 if (crCtxInfo->SpuContext >= 0) 206 cr_server.head_spu->dispatch_table.DestroyContext(crCtxInfo->SpuContext); 207 208 crFree(crCtxInfo); 167 209 168 210 if (cr_server.curClient) 169 211 { 170 212 /* If we delete our current context, default back to the null context */ 171 if (cr_server.curClient->currentCtx == crCtx) {213 if (cr_server.curClient->currentCtxInfo == crCtxInfo) { 172 214 cr_server.curClient->currentContextNumber = -1; 173 cr_server.curClient->currentCtx = cr_server.DummyContext;215 cr_server.curClient->currentCtxInfo = &cr_server.MainContextInfo; 174 216 } 175 217 … … 207 249 for (client=0; client<cr_server.numClients; ++client) 208 250 { 209 if (cr_server.clients[client]->currentCtx == crCtx)251 if (cr_server.clients[client]->currentCtxInfo == crCtxInfo) 210 252 { 211 253 cr_server.clients[client]->currentContextNumber = -1; 212 cr_server.clients[client]->currentCtx = cr_server.DummyContext;254 cr_server.clients[client]->currentCtxInfo = &cr_server.MainContextInfo; 213 255 } 214 256 } … … 217 259 while (pNode) 218 260 { 219 if (pNode->pClient->currentCtx == crCtx)261 if (pNode->pClient->currentCtxInfo == crCtxInfo) 220 262 { 221 263 pNode->pClient->currentContextNumber = -1; 222 pNode->pClient->currentCtx = cr_server.DummyContext;264 pNode->pClient->currentCtxInfo = &cr_server.MainContextInfo; 223 265 } 224 266 pNode = pNode->next; … … 231 273 { 232 274 CRMuralInfo *mural, *oldMural; 275 CRContextInfo *ctxInfo = NULL; 233 276 CRContext *ctx, *oldCtx; 234 277 … … 242 285 243 286 /* Update the state tracker's current context */ 244 ctx = (CRContext*) crHashtableSearch(cr_server.contextTable, context);245 if (!ctx ) {287 ctxInfo = (CRContextInfo *) crHashtableSearch(cr_server.contextTable, context); 288 if (!ctxInfo) { 246 289 crWarning("CRserver: NULL context in MakeCurrent %d", context); 247 290 return; … … 262 305 } 263 306 264 ctx = cr_server.DummyContext;307 ctxInfo = &cr_server.MainContextInfo; 265 308 window = -1; 266 309 mural = NULL; 267 310 return; 268 311 } 312 313 ctx = ctxInfo->pContext; 314 CRASSERT(ctx); 269 315 270 316 /* Ubuntu 11.04 hosts misbehave if context window switch is … … 273 319 * crStateSwichPrepare restores the FBO state to its default values before the context window switch, 274 320 * while crStateSwichPostprocess restores it back to the original values */ 275 oldCtx = crStateSwichPrepare(ctx); 321 if (!cr_server.bUseMultipleContexts) 322 oldCtx = crStateSwichPrepare(ctx); 276 323 277 324 /* … … 280 327 */ 281 328 cr_server.curClient->currentContextNumber = context; 282 cr_server.curClient->currentCtx = ctx;329 cr_server.curClient->currentCtxInfo = ctxInfo; 283 330 cr_server.curClient->currentMural = mural; 284 331 cr_server.curClient->currentWindow = window; 285 332 286 CRASSERT(cr_server.curClient->currentCtx); 333 CRASSERT(cr_server.curClient->currentCtxInfo); 334 CRASSERT(cr_server.curClient->currentCtxInfo->pContext); 287 335 288 336 /* This is a hack to force updating the 'current' attribs */ … … 324 372 cr_server.head_spu->dispatch_table.MakeCurrent( mural->spuWindow, 325 373 nativeWindow, 326 cr_server.SpuContext ); 374 ctxInfo->SpuContext >= 0 375 ? ctxInfo->SpuContext 376 : cr_server.MainContextInfo.SpuContext); 327 377 cr_server.firstCallMakeCurrent = GL_FALSE; 378 cr_server.currentCtxInfo = ctxInfo; 328 379 cr_server.currentWindow = window; 329 380 cr_server.currentNativeWindow = nativeWindow; … … 333 384 crStateMakeCurrent( ctx ); 334 385 335 crStateSwichPostprocess(oldCtx); 386 387 if (!cr_server.bUseMultipleContexts) 388 crStateSwichPostprocess(oldCtx); 336 389 337 390 if (oldMural != mural && crServerSupportRedirMuralFBO())
Note:
See TracChangeset
for help on using the changeset viewer.