static void stubCheckWindowsState(void) { ContextInfo *context = stubGetCurrentContext(); CRASSERT(stub.trackWindowSize || stub.trackWindowPos); if (!context) return; #if defined(WINDOWS) && defined(VBOX_WITH_WDDM) if (stub.bRunningUnderWDDM) return; #endif /* Try to keep a consistent locking order. */ crHashtableLock(stub.windowTable); #if defined(CR_NEWWINTRACK) && !defined(WINDOWS) crLockMutex(&stub.mutex); #endif stubCheckWindowState(context->currentDrawable, GL_TRUE); crHashtableWalkUnlocked(stub.windowTable, stubCheckWindowsCB, context); #if defined(CR_NEWWINTRACK) && !defined(WINDOWS) crUnlockMutex(&stub.mutex); #endif crHashtableUnlock(stub.windowTable); }
void renderspuVBoxCompositorClearAll() { /* we need to clear window compositor, which is not that trivial though, * since the lock order used in presentation thread is compositor lock() -> hash table lock (aquired for id->window resolution) * this is why, to prevent potential deadlocks, we use crHashtableWalkUnlocked that does not hold the table lock * we are can be sure noone will modify the table here since renderspuVBoxCompositorClearAll can be called in the command (hgcm) thread only, * and the table can be modified from that thread only as well */ crHashtableWalkUnlocked(render_spu.windowTable, renderspuVBoxCompositorClearAllCB, NULL); }
static DECLCALLBACK(int) stubSyncThreadProc(RTTHREAD ThreadSelf, void *pvUser) { #ifdef WINDOWS MSG msg; # ifdef VBOX_WITH_WDDM HMODULE hVBoxD3D = NULL; GLint spuConnection = 0; # endif #endif (void) pvUser; crDebug("Sync thread started"); #ifdef WINDOWS PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); # ifdef VBOX_WITH_WDDM hVBoxD3D = NULL; if (!GetModuleHandleEx(0, VBOX_MODNAME_DISPD3D, &hVBoxD3D)) { crDebug("GetModuleHandleEx failed err %d", GetLastError()); hVBoxD3D = NULL; } if (hVBoxD3D) { crDebug("running with " VBOX_MODNAME_DISPD3D); stub.trackWindowVisibleRgn = 0; stub.bRunningUnderWDDM = true; } # endif /* VBOX_WITH_WDDM */ #endif /* WINDOWS */ crLockMutex(&stub.mutex); #if defined(WINDOWS) && defined(VBOX_WITH_WDDM) spuConnection = #endif stub.spu->dispatch_table.VBoxPackSetInjectThread(NULL); #if defined(WINDOWS) && defined(VBOX_WITH_WDDM) if (stub.bRunningUnderWDDM && !spuConnection) { crError("VBoxPackSetInjectThread failed!"); } #endif crUnlockMutex(&stub.mutex); RTThreadUserSignal(ThreadSelf); while(!stub.bShutdownSyncThread) { #ifdef WINDOWS if (!PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { # ifdef VBOX_WITH_WDDM if (stub.bRunningUnderWDDM) { } else # endif { crHashtableWalk(stub.windowTable, stubSyncTrCheckWindowsCB, NULL); RTThreadSleep(50); } } else { if (WM_QUIT==msg.message) { crDebug("Sync thread got WM_QUIT"); break; } else { TranslateMessage(&msg); DispatchMessage(&msg); } } #else /* Try to keep a consistent locking order. */ crHashtableLock(stub.windowTable); crLockMutex(&stub.mutex); crHashtableWalkUnlocked(stub.windowTable, stubSyncTrCheckWindowsCB, NULL); crUnlockMutex(&stub.mutex); crHashtableUnlock(stub.windowTable); RTThreadSleep(50); #endif } #ifdef VBOX_WITH_WDDM if (spuConnection) { stub.spu->dispatch_table.VBoxConDestroy(spuConnection); } if (hVBoxD3D) { FreeLibrary(hVBoxD3D); } #endif crDebug("Sync thread stopped"); return 0; }