/** * This is called when we exit. * We call all the SPU's cleanup functions. */ static void stubSPUTearDownLocked(void) { crDebug("stubSPUTearDownLocked"); #ifdef WINDOWS # ifndef CR_NEWWINTRACK stubUninstallWindowMessageHook(); # endif #endif #ifdef CR_NEWWINTRACK ASMAtomicWriteBool(&stub.bShutdownSyncThread, true); #endif //delete all created contexts stubMakeCurrent( NULL, NULL); /* the lock order is windowTable->contextTable (see wglMakeCurrent_prox, glXMakeCurrent) * this is why we need to take a windowTable lock since we will later do stub.windowTable access & locking */ crHashtableLock(stub.windowTable); crHashtableWalk(stub.contextTable, hsWalkStubDestroyContexts, NULL); crHashtableUnlock(stub.windowTable); /* shutdown, now trap any calls to a NULL dispatcher */ crSPUCopyDispatchTable(&glim, &stubNULLDispatch); crSPUUnloadChain(stub.spu); stub.spu = NULL; #ifndef Linux crUnloadOpenGL(); #endif #ifndef WINDOWS crNetTearDown(); #endif #ifdef GLX if (stub.xshmSI.shmid>=0) { shmctl(stub.xshmSI.shmid, IPC_RMID, 0); shmdt(stub.xshmSI.shmaddr); } crFreeHashtable(stub.pGLXPixmapsHash, crFree); #endif crFreeHashtable(stub.windowTable, crFree); crFreeHashtable(stub.contextTable, NULL); crMemset(&stub, 0, sizeof(stub)); }
static int vboxCheck3DAccelerationSupported() { LogRel(("Testing 3D Support:\n")); void *spu = crSPULoad(NULL, 0, (char*)"render", NULL, NULL); if (spu) { crSPUUnloadChain(spu); LogRel(("Testing 3D Succeeded!\n")); return 0; } LogRel(("Testing 3D Failed\n")); return 1; }
static void crServerTearDown( void ) { GLint i; /* avoid a race condition */ if (tearingdown) return; tearingdown = 1; crStateSetCurrent( NULL ); cr_server.curClient = NULL; cr_server.run_queue = NULL; crFree( cr_server.overlap_intens ); cr_server.overlap_intens = NULL; /* Deallocate all semaphores */ crFreeHashtable(cr_server.semaphores, crFree); cr_server.semaphores = NULL; /* Deallocate all barriers */ crFreeHashtable(cr_server.barriers, DeleteBarrierCallback); cr_server.barriers = NULL; /* Free all context info */ crFreeHashtable(cr_server.contextTable, deleteContextCallback); /* Free vertex programs */ crFreeHashtable(cr_server.programTable, crFree); for (i = 0; i < cr_server.numClients; i++) { if (cr_server.clients[i]) { CRConnection *conn = cr_server.clients[i]->conn; crNetFreeConnection(conn); crFree(cr_server.clients[i]); } } cr_server.numClients = 0; #if 1 /* disable these two lines if trying to get stack traces with valgrind */ crSPUUnloadChain(cr_server.head_spu); cr_server.head_spu = NULL; #endif crUnloadOpenGL(); }
SPU * crSPULoad( SPU *child, int id, char *name, char *dir, void *server ) { SPU *the_spu; char *path; CRASSERT( name != NULL ); the_spu = (SPU*)crAlloc( sizeof( *the_spu ) ); the_spu->id = id; the_spu->privatePtr = NULL; path = __findDLL( name, dir ); the_spu->dll = crDLLOpen( path, 0/*resolveGlobal*/ ); the_spu->entry_point = (SPULoadFunction) crDLLGetNoError( the_spu->dll, SPU_ENTRY_POINT_NAME ); if (!the_spu->entry_point) { crError( "Couldn't load the SPU entry point \"%s\" from SPU \"%s\"!", SPU_ENTRY_POINT_NAME, name ); crSPUUnloadChain(the_spu); return NULL; } /* This basically calls the SPU's SPULoad() function */ if (!the_spu->entry_point( &(the_spu->name), &(the_spu->super_name), &(the_spu->init), &(the_spu->self), &(the_spu->cleanup), &(the_spu->options), &(the_spu->spu_flags)) ) { crError( "I found the SPU \"%s\", but loading it failed!", name ); crSPUUnloadChain(the_spu); return NULL; } #ifdef IN_GUEST if (crStrcmp(the_spu->name,"error")) { /* the default super/base class for an SPU is the error SPU */ if (the_spu->super_name == NULL) { the_spu->super_name = "error"; } the_spu->superSPU = crSPULoad( child, id, the_spu->super_name, dir, server ); } #else if (crStrcmp(the_spu->name,"hosterror")) { /* the default super/base class for an SPU is the error SPU */ if (the_spu->super_name == NULL) { the_spu->super_name = "hosterror"; } the_spu->superSPU = crSPULoad( child, id, the_spu->super_name, dir, server ); } #endif else { the_spu->superSPU = NULL; } crDebug("Initializing %s SPU", name); the_spu->function_table = the_spu->init( id, child, the_spu, 0, 1 ); if (!the_spu->function_table) { crDebug("Failed to init %s SPU", name); crSPUUnloadChain(the_spu); return NULL; } __buildDispatch( the_spu ); /*crDebug( "initializing dispatch table %p (for SPU %s)", (void*)&(the_spu->dispatch_table), name );*/ crSPUInitDispatchTable( &(the_spu->dispatch_table) ); /*crDebug( "Done initializing the dispatch table for SPU %s, calling the self function", name );*/ the_spu->dispatch_table.server = server; the_spu->self( &(the_spu->dispatch_table) ); /*crDebug( "Done with the self function" );*/ return the_spu; }
static void crServerTearDown( void ) { GLint i; CRClientNode *pNode, *pNext; /* avoid a race condition */ if (tearingdown) return; tearingdown = 1; crStateSetCurrent( NULL ); cr_server.curClient = NULL; cr_server.run_queue = NULL; crFree( cr_server.overlap_intens ); cr_server.overlap_intens = NULL; /* Deallocate all semaphores */ crFreeHashtable(cr_server.semaphores, crFree); cr_server.semaphores = NULL; /* Deallocate all barriers */ crFreeHashtable(cr_server.barriers, DeleteBarrierCallback); cr_server.barriers = NULL; /* Free all context info */ crFreeHashtable(cr_server.contextTable, deleteContextCallback); /* Free context/window creation info */ crFreeHashtable(cr_server.pContextCreateInfoTable, crServerCreateInfoDeleteCB); crFreeHashtable(cr_server.pWindowCreateInfoTable, crServerCreateInfoDeleteCB); /* Free vertex programs */ crFreeHashtable(cr_server.programTable, crFree); for (i = 0; i < cr_server.numClients; i++) { if (cr_server.clients[i]) { CRConnection *conn = cr_server.clients[i]->conn; crNetFreeConnection(conn); crFree(cr_server.clients[i]); } } cr_server.numClients = 0; pNode = cr_server.pCleanupClient; while (pNode) { pNext=pNode->next; crFree(pNode->pClient); crFree(pNode); pNode=pNext; } cr_server.pCleanupClient = NULL; #if 1 /* disable these two lines if trying to get stack traces with valgrind */ crSPUUnloadChain(cr_server.head_spu); cr_server.head_spu = NULL; #endif crStateDestroy(); crNetTearDown(); }