Changeset 39507 in vbox
- Timestamp:
- Dec 2, 2011 7:44:16 AM (13 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/crOpenGL/array/arrayspu_init.c
r16074 r39507 85 85 return 1; 86 86 } 87 88 #ifdef RT_OS_WINDOWS 89 #define WIN32_LEAN_AND_MEAN 90 #include <windows.h> 91 BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved) 92 { 93 (void) lpvReserved; 94 95 switch (fdwReason) 96 { 97 case DLL_THREAD_ATTACH: 98 { 99 crStateOnThreadAttachDetach(GL_TRUE); 100 break; 101 } 102 103 case DLL_THREAD_DETACH: 104 { 105 crStateOnThreadAttachDetach(GL_FALSE); 106 break; 107 } 108 109 case DLL_PROCESS_ATTACH: 110 case DLL_PROCESS_DETACH: 111 default: 112 break; 113 } 114 115 return TRUE; 116 } 117 #endif -
trunk/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu_init.c
r19099 r39507 29 29 unsigned int num_contexts ) 30 30 { 31 CRContext *ctx;32 31 (void) context_id; 33 32 (void) num_contexts; … … 86 85 return 1; 87 86 } 87 88 #ifdef RT_OS_WINDOWS 89 #define WIN32_LEAN_AND_MEAN 90 #include <windows.h> 91 BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved) 92 { 93 (void) lpvReserved; 94 95 switch (fdwReason) 96 { 97 case DLL_THREAD_ATTACH: 98 { 99 crStateOnThreadAttachDetach(GL_TRUE); 100 break; 101 } 102 103 case DLL_THREAD_DETACH: 104 { 105 crStateOnThreadAttachDetach(GL_FALSE); 106 break; 107 } 108 109 case DLL_PROCESS_ATTACH: 110 case DLL_PROCESS_DETACH: 111 default: 112 break; 113 } 114 115 return TRUE; 116 } 117 #endif -
trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c
r38374 r39507 585 585 { 586 586 packspu_VBoxPackAttachThread(); 587 crStateOnThreadAttachDetach(GL_TRUE); 587 588 break; 588 589 } … … 591 592 { 592 593 packspu_VBoxPackDetachThread(); 594 crStateOnThreadAttachDetach(GL_FALSE); 593 595 break; 594 596 } -
trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h
r37613 r39507 118 118 struct CRContext { 119 119 int id; 120 121 #ifdef CHROMIUM_THREADSAFE 122 /* we keep reference counting of context's makeCurrent for different threads 123 * this is primarily needed to avoid having an invalid memory reference in the TLS 124 * when the context is assigned to more than one threads and then destroyed from 125 * one of those, i.e. 126 * 1. Thread1 -> MakeCurrent(ctx1); 127 * 2. Thread2 -> MakeCurrent(ctx1); 128 * 3. Thread1 -> Destroy(ctx1); 129 * => Thread2 still refers to destroyed ctx1 130 * */ 131 /* number of threads that have context set as current */ 132 volatile int cRefs; 133 #endif 134 120 135 CRbitvalue bitid[CR_MAX_BITARRAY]; 121 136 CRbitvalue neg_bitid[CR_MAX_BITARRAY]; … … 181 196 DECLEXPORT(void) crStateInit(void); 182 197 DECLEXPORT(void) crStateDestroy(void); 198 DECLEXPORT(void) crStateOnThreadAttachDetach(GLboolean attach); 183 199 DECLEXPORT(CRContext *) crStateCreateContext(const CRLimitsState *limits, GLint visBits, CRContext *share); 184 200 DECLEXPORT(CRContext *) crStateCreateContextEx(const CRLimitsState *limits, GLint visBits, CRContext *share, GLint presetID); -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state.h
r31808 r39507 11 11 #ifdef CHROMIUM_THREADSAFE 12 12 #include "cr_threads.h" 13 #include <iprt/asm.h> 13 14 #endif 14 15 … … 25 26 extern CRtsd __contextTSD; 26 27 #define GetCurrentContext() (CRContext *) crGetTSD(&__contextTSD) 28 29 /* NOTE: below ref & SetCurrentContext stuff is supposed to be used only internally!! 30 * it is placed here only to simplify things since some code besides state_init.c 31 * (i.e. state_glsl.c) is using it */ 32 void crStateFreeContext(CRContext *ctx); 33 #define CRCONTEXT_ADDREF(_ctx) do { \ 34 int cRefs = ASMAtomicIncS32(&((CRContext*)(_ctx))->cRefs); \ 35 CRASSERT(cRefs > 1); \ 36 } while (0) 37 #define CRCONTEXT_RELEASE(_ctx) do { \ 38 int cRefs = ASMAtomicDecS32(&((CRContext*)(_ctx))->cRefs); \ 39 CRASSERT(cRefs >= 0); \ 40 if (!cRefs) { \ 41 crStateFreeContext((_ctx)); \ 42 } \ 43 } while (0) 44 #define SetCurrentContext(_ctx) do { \ 45 CRContext * oldCur = GetCurrentContext(); \ 46 if (oldCur != (_ctx)) { \ 47 if (oldCur) { \ 48 CRCONTEXT_RELEASE(oldCur); \ 49 } \ 50 if ((_ctx)) { \ 51 CRCONTEXT_ADDREF(_ctx); \ 52 } \ 53 crSetTSD(&__contextTSD, _ctx); \ 54 } \ 55 } while (0) 27 56 #else 28 57 extern CRContext *__currentContext; -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_glsl.c
r37773 r39507 174 174 as the current context isn't the one being destroyed*/ 175 175 #ifdef CHROMIUM_THREADSAFE 176 crSetTSD(&__contextTSD, ctx); 176 CRASSERT(g != ctx); 177 CRASSERT(!ctx->cRefs); 178 ++ctx->cRefs; /* <- this is a hack to avoid subsequent SetCurrentContext(g) do recursive Destroy for ctx */ 179 if (g) 180 CRCONTEXT_ADDREF(g); /* <- ensure the g is not destroyed by the following SetCurrentContext call */ 181 SetCurrentContext(ctx); 177 182 #else 178 183 __currentContext = ctx; … … 183 188 184 189 #ifdef CHROMIUM_THREADSAFE 185 crSetTSD(&__contextTSD, g); 190 SetCurrentContext(g); 191 if (g) 192 CRCONTEXT_RELEASE(g); 193 --ctx->cRefs; /* <- restore back the cRefs (see above) */ 186 194 #else 187 195 __currentContext = g; -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c
r37613 r39507 158 158 159 159 ctx->id = i; 160 #ifdef CHROMIUM_THREADSAFE 161 ctx->cRefs = 1; 162 #endif 160 163 ctx->flush_func = NULL; 161 164 for (j=0;j<CR_MAX_BITARRAY;j++){ … … 258 261 259 262 /*@todo crStateAttribDestroy*/ 260 staticvoid263 void 261 264 crStateFreeContext(CRContext *ctx) 262 265 { … … 307 310 /* Free the default/NULL context. 308 311 * Ensures context bits are reset */ 312 #ifdef CHROMIUM_THREADSAFE 313 SetCurrentContext(NULL); 314 CRCONTEXT_RELEASE(defaultContext); 315 #else 309 316 crStateFreeContext(defaultContext); 310 #ifdef CHROMIUM_THREADSAFE311 crSetTSD(&__contextTSD, NULL);312 #else313 317 __currentContext = NULL; 314 318 #endif … … 324 328 325 329 #ifdef CHROMIUM_THREADSAFE 326 crSetTSD(&__contextTSD,defaultContext);330 SetCurrentContext(defaultContext); 327 331 #else 328 332 __currentContext = defaultContext; … … 434 438 crStateSwitchContext(current, defaultContext); 435 439 #ifdef CHROMIUM_THREADSAFE 436 crSetTSD(&__contextTSD,defaultContext);440 SetCurrentContext(defaultContext); 437 441 #else 438 442 __currentContext = defaultContext; … … 443 447 g_availableContexts[ctx->id] = 0; 444 448 449 #ifdef CHROMIUM_THREADSAFE 450 CRCONTEXT_RELEASE(ctx); 451 #else 445 452 crStateFreeContext(ctx); 453 #endif 446 454 } 447 455 … … 467 475 468 476 #ifdef CHROMIUM_THREADSAFE 469 crSetTSD(&__contextTSD,ctx);477 SetCurrentContext(ctx); 470 478 #else 471 479 __currentContext = ctx; … … 493 501 494 502 #ifdef CHROMIUM_THREADSAFE 495 crSetTSD(&__contextTSD,ctx);503 SetCurrentContext(ctx); 496 504 #else 497 505 __currentContext = ctx; … … 549 557 } 550 558 559 void crStateOnThreadAttachDetach(GLboolean attach) 560 { 561 if (attach) 562 return; 563 564 /* release the context ref so that it can be freed */ 565 SetCurrentContext(NULL); 566 } -
trunk/src/VBox/HostServices/SharedOpenGL/crserver/crservice.cpp
r39288 r39507 1245 1245 } 1246 1246 1247 #ifdef RT_OS_WINDOWS 1248 #define WIN32_LEAN_AND_MEAN 1249 #include <windows.h> 1250 BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved) 1251 { 1252 (void) lpvReserved; 1253 1254 switch (fdwReason) 1255 { 1256 case DLL_THREAD_ATTACH: 1257 { 1258 crStateOnThreadAttachDetach(GL_TRUE); 1259 break; 1260 } 1261 1262 case DLL_THREAD_DETACH: 1263 { 1264 crStateOnThreadAttachDetach(GL_FALSE); 1265 break; 1266 } 1267 1268 case DLL_PROCESS_ATTACH: 1269 case DLL_PROCESS_DETACH: 1270 default: 1271 break; 1272 } 1273 1274 return TRUE; 1275 } 1276 #endif -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c
r39415 r39507 843 843 GLboolean renderspu_SystemVBoxCreateWindow( VisualInfo *visual, GLboolean showIt, WindowInfo *window ) 844 844 { 845 #if 0 845 846 HDESK desktop; 847 #endif 846 848 HINSTANCE hinstance; 847 849 WNDCLASS wc; … … 1412 1414 void renderspu_SystemReparentWindow(WindowInfo *window) 1413 1415 { 1414 SetParent(window->hWnd, render_spu_parent_window_id);1415 } 1416 SetParent(window->hWnd, (HWND)render_spu_parent_window_id); 1417 }
Note:
See TracChangeset
for help on using the changeset viewer.