/** * Windowtracker spu init function * \param id * \param child * \param self * \param context_id * \param num_contexts */ static SPUFunctions * windowtrackerSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { (void) self; (void) context_id; (void) num_contexts; windowtracker_spu.id = id; windowtracker_spu.has_child = 0; windowtracker_spu.server = NULL; if (child) { crSPUInitDispatchTable( &(windowtracker_spu.child) ); crSPUCopyDispatchTable( &(windowtracker_spu.child), &(child->dispatch_table) ); windowtracker_spu.has_child = 1; } crSPUInitDispatchTable( &(windowtracker_spu.super) ); crSPUCopyDispatchTable( &(windowtracker_spu.super), &(self->superSPU->dispatch_table) ); windowtrackerspuGatherConfiguration(); return &windowtracker_functions; }
static SPUFunctions * expandoSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { (void) self; (void) context_id; (void) num_contexts; expando_spu.id = id; expando_spu.has_child = 0; expando_spu.server = NULL; if (child) { crSPUInitDispatchTable( &(expando_spu.child) ); crSPUCopyDispatchTable( &(expando_spu.child), &(child->dispatch_table) ); expando_spu.has_child = 1; } crSPUInitDispatchTable( &(expando_spu.super) ); crSPUCopyDispatchTable( &(expando_spu.super), &(self->superSPU->dispatch_table) ); expandospuGatherConfiguration(); /* Expando-specific initialization */ expando_spu.contextTable = crAllocHashtable(); /* We'll be using the state tracker for each context */ crStateInit(); return &expando_functions; }
static SPUFunctions *injectorSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { (void) self; (void) context_id; (void) num_contexts; injector_spu.id = id; injector_spu.has_child = 0; injector_spu.server = NULL; if (child) { crSPUInitDispatchTable( &(injector_spu.child) ); crSPUCopyDispatchTable( &(injector_spu.child), &(child->dispatch_table) ); injector_spu.has_child = 1; } crSPUInitDispatchTable( &(injector_spu.super) ); crSPUCopyDispatchTable( &(injector_spu.super), &(self->superSPU->dispatch_table) ); injectorspuGatherConfiguration( &injector_spu ); /* Don't want oob stream to pass swapbuffers */ crSPUCopyDispatchTable( &(injector_spu.oob_dispatch), &(injector_spu.child) ); injector_spu.oob_dispatch.SwapBuffers = (SwapBuffersFunc_t) injectorspuOOBSwapBuffers; injector_spu.oob_dispatch.ChromiumParameteriCR = (ChromiumParameteriCRFunc_t) injectorspuChromiumParameteri; injectorspuConnect() ; return &injector_functions; }
/** * Matte spu init function * \param id * \param child * \param self * \param context_id * \param num_contexts */ static SPUFunctions * matteSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { (void) self; (void) context_id; (void) num_contexts; #ifdef CHROMIUM_THREADSAFE crInitTSD(&matteTSD); #endif matte_spu.id = id; matte_spu.has_child = 0; matte_spu.server = NULL; if (child) { crSPUInitDispatchTable( &(matte_spu.child) ); crSPUCopyDispatchTable( &(matte_spu.child), &(child->dispatch_table) ); matte_spu.has_child = 1; } crSPUInitDispatchTable( &(matte_spu.super) ); crSPUCopyDispatchTable( &(matte_spu.super), &(self->superSPU->dispatch_table) ); mattespuGatherConfiguration(); matte_spu.contextTable = crAllocHashtable(); return &matte_functions; }
static SPUFunctions *feedbackSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { (void) context_id; (void) num_contexts; #ifdef CHROMIUM_THREADSAFE crInitMutex(&feedback_spu.mutex); #endif feedback_spu.id = id; feedback_spu.has_child = 0; if (child) { crSPUInitDispatchTable( &(feedback_spu.child) ); crSPUCopyDispatchTable( &(feedback_spu.child), &(child->dispatch_table) ); feedback_spu.has_child = 1; } crSPUInitDispatchTable( &(feedback_spu.super) ); crSPUCopyDispatchTable( &(feedback_spu.super), &(self->superSPU->dispatch_table) ); feedbackspuGatherConfiguration(); /* create/init default state tracker */ crStateInit(); feedback_spu.defaultctx = crStateCreateContext(NULL, 0, NULL); crStateSetCurrent(feedback_spu.defaultctx); feedback_spu.numContexts = 0; crMemZero(feedback_spu.context, CR_MAX_CONTEXTS * sizeof(ContextInfo)); return &feedback_functions; }
static SPUFunctions * zpixSPUInit(int id, SPU * child, SPU * self, unsigned int context_id, unsigned int num_contexts) { int i = 0; (void) self; (void) context_id; (void) num_contexts; self->privatePtr = (void *) &zpix_spu; crMemZero(&zpix_spu, sizeof(zpix_spu)); zpix_spu.id = id; zpix_spu.has_child = 0; zpix_spu.server = NULL; if (child) { crSPUInitDispatchTable(&(zpix_spu.child)); crSPUCopyDispatchTable(&(zpix_spu.child), &(child->dispatch_table)); zpix_spu.has_child = 1; } crSPUInitDispatchTable(&(zpix_spu.super)); crSPUCopyDispatchTable(&(zpix_spu.super), &(self->superSPU->dispatch_table)); zpixspuGatherConfiguration(&zpix_spu); /* non-zero instance initialization values */ crDebug("Zpix SPU - verbose = %d", zpix_spu.verbose); zpix_spu.rXold = -1; zpix_spu.rYold = -1; /* set up shadow buffers */ for (i = 0; i < FBNUM; i++) { zpix_spu.b.fbWidth[i] = -1; zpix_spu.b.fbHeight[i] = -1; zpix_spu.b.fbLen[i] = 0; zpix_spu.b.fBuf[i] = NULL; zpix_spu.b.dBuf[i] = NULL; zpix_spu.zBuf[i] = NULL; } /* allocate some initial server shadows */ /*XXX this is just a convenience since storage amount is trivial */ #define DEFAULT_NUMBER_SERVER_SHADOWS 8 zpix_spu.n_sb = DEFAULT_NUMBER_SERVER_SHADOWS - 1; zpix_spu.sb = (SBUFS *) crAlloc((zpix_spu.n_sb + 1) * sizeof(SBUFS)); /* set highest valid index */ for (i = 0; i < zpix_spu.n_sb; i++) { zpix_spu.sb[i] = zpix_spu.b; } return &zpix_functions; }
static SPUFunctions *arraySPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { (void) context_id; (void) num_contexts; array_spu.id = id; array_spu.has_child = 0; if (child) { crSPUInitDispatchTable( &(array_spu.child) ); crSPUCopyDispatchTable( &(array_spu.child), &(child->dispatch_table) ); array_spu.has_child = 1; } crSPUInitDispatchTable( &(array_spu.super) ); crSPUCopyDispatchTable( &(array_spu.super), &(self->superSPU->dispatch_table) ); arrayspuGatherConfiguration(); crStateInit(); array_spu.ctx = crStateCreateContext( NULL, 0, NULL ); #ifdef CR_ARB_vertex_buffer_object array_spu.ctx->bufferobject.retainBufferData = GL_TRUE; #endif /* we call SetCurrent instead of MakeCurrent as the differencer * isn't setup yet anyway */ crStateSetCurrent( array_spu.ctx ); return &array_functions; }
static SPUFunctions *feedbackSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { CRContext *ctx; (void) context_id; (void) num_contexts; feedback_spu.id = id; feedback_spu.has_child = 0; if (child) { crSPUInitDispatchTable( &(feedback_spu.child) ); crSPUCopyDispatchTable( &(feedback_spu.child), &(child->dispatch_table) ); feedback_spu.has_child = 1; } crSPUInitDispatchTable( &(feedback_spu.super) ); crSPUCopyDispatchTable( &(feedback_spu.super), &(self->superSPU->dispatch_table) ); feedbackspuGatherConfiguration(); /* create/init default state tracker */ crStateInit(); ctx = crStateGetCurrent(); CRASSERT(ctx); crStateSetCurrentPointers(ctx, &feedback_spu.current); return &feedback_functions; }
static SPUFunctions * readbackSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { WindowInfo *window; (void) context_id; (void) num_contexts; #ifdef CHROMIUM_THREADSAFE crDebug("Readback SPU: thread-safe"); #endif crMemZero(&readback_spu, sizeof(readback_spu)); readback_spu.id = id; readback_spu.has_child = 0; if (child) { crSPUInitDispatchTable( &(readback_spu.child) ); crSPUCopyDispatchTable( &(readback_spu.child), &(child->dispatch_table) ); readback_spu.has_child = 1; } else { /* don't override any API functions - use the Render SPU functions */ static SPUNamedFunctionTable empty_table[] = { { NULL, NULL } }; readback_functions.table = empty_table; } crSPUInitDispatchTable( &(readback_spu.super) ); crSPUCopyDispatchTable( &(readback_spu.super), &(self->superSPU->dispatch_table) ); readbackspuGatherConfiguration( &readback_spu ); readback_spu.contextTable = crAllocHashtable(); readback_spu.windowTable = crAllocHashtable(); /* create my default window (window number 0) */ window = (WindowInfo *) crCalloc(sizeof(WindowInfo)); CRASSERT(window); window->index = 0; window->renderWindow = 0; /* default render SPU window */ window->childWindow = 0; /* default child SPU window */ readbackspuTweakVisBits(readback_spu.default_visual, &window->childVisBits, &window->superVisBits); crHashtableAdd(readback_spu.windowTable, 0, window); readback_spu.gather_conn = NULL; return &readback_functions; }
static void injectorSPUSelfDispatch(SPUDispatchTable *self) { crSPUInitDispatchTable( &(injector_spu.self) ); crSPUCopyDispatchTable( &(injector_spu.self), self ); injector_spu.server = (CRServer *)(self->server); }
/** * Install the given dispatch table as the table used for all gl* calls. */ static void stubSetDispatch( SPUDispatchTable *table ) { CRASSERT(table); #ifdef CHROMIUM_THREADSAFE /* always set the per-thread dispatch pointer */ crSetTSD(&stub.dispatchTSD, (void *) table); if (stub.threadSafe) { /* Do nothing - the thread-safe dispatch functions will call GetTSD() * to get a pointer to the dispatch table, and jump through it. */ } else #endif { /* Single thread mode - just install the caller's dispatch table */ /* This conditional is an optimization to try to avoid unnecessary * copying. It seems to work with atlantis, multiwin, etc. but * _could_ be a problem. (Brian) */ if (glim.copy_of != table->copy_of) crSPUCopyDispatchTable(&glim, table); } }
static void readbackSPUSelfDispatch(SPUDispatchTable *self) { crSPUInitDispatchTable( &(readback_spu.self) ); crSPUCopyDispatchTable( &(readback_spu.self), self ); readback_spu.server = (CRServer *)(self->server); }
static void expandoSPUSelfDispatch(SPUDispatchTable *self) { crSPUInitDispatchTable( &(expando_spu.self) ); crSPUCopyDispatchTable( &(expando_spu.self), self ); expando_spu.server = (CRServer *)(self->server); }
static void windowtrackerSPUSelfDispatch(SPUDispatchTable *self) { crSPUInitDispatchTable( &(windowtracker_spu.self) ); crSPUCopyDispatchTable( &(windowtracker_spu.self), self ); windowtracker_spu.server = (CRServer *)(self->server); }
static void matteSPUSelfDispatch(SPUDispatchTable *self) { crSPUInitDispatchTable( &(matte_spu.self) ); crSPUCopyDispatchTable( &(matte_spu.self), self ); matte_spu.server = (CRServer *)(self->server); }
static void zpixSPUSelfDispatch(SPUDispatchTable * self) { crSPUInitDispatchTable(&(zpix_spu.self)); crSPUCopyDispatchTable(&(zpix_spu.self), self); zpix_spu.server = (CRServer *) (self->server); }
/** * Use the GL function pointers in <spu> to initialize the static glim * dispatch table. */ static void stubInitSPUDispatch(SPU *spu) { crSPUInitDispatchTable( &stub.spuDispatch ); crSPUCopyDispatchTable( &stub.spuDispatch, &(spu->dispatch_table) ); if (stub.trackWindowSize || stub.trackWindowPos || stub.trackWindowVisibleRgn) { /* patch-in special glClear/Viewport function to track window sizing */ origClear = stub.spuDispatch.Clear; origViewport = stub.spuDispatch.Viewport; origSwapBuffers = stub.spuDispatch.SwapBuffers; origDrawBuffer = stub.spuDispatch.DrawBuffer; origScissor = stub.spuDispatch.Scissor; stub.spuDispatch.Clear = trapClear; stub.spuDispatch.Viewport = trapViewport; /*stub.spuDispatch.SwapBuffers = trapSwapBuffers; stub.spuDispatch.DrawBuffer = trapDrawBuffer;*/ } crSPUCopyDispatchTable( &glim, &stub.spuDispatch ); }
/** * 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 void renderSPUSelfDispatch(SPUDispatchTable *self) { crSPUInitDispatchTable( &(render_spu.self) ); crSPUCopyDispatchTable( &(render_spu.self), self ); crSPUInitDispatchTable( &(render_spu.blitterDispatch) ); crSPUCopyDispatchTable( &(render_spu.blitterDispatch), self ); render_spu.server = (CRServer *)(self->server); { GLfloat version; version = crStrToFloat((const char *) render_spu.ws.glGetString(GL_VERSION)); if (version>=2.f || crStrstr((const char*)render_spu.ws.glGetString(GL_EXTENSIONS), "GL_ARB_vertex_shader")) { GLint mu=0; render_spu.self.GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &mu); crInfo("Render SPU: GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB=%i", mu); } } }
static SPUFunctions *arraySPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { (void) context_id; (void) num_contexts; #ifdef CHROMIUM_THREADSAFE crInitMutex(&_ArrayMutex); #endif array_spu.id = id; array_spu.has_child = 0; if (child) { crSPUInitDispatchTable( &(array_spu.child) ); crSPUCopyDispatchTable( &(array_spu.child), &(child->dispatch_table) ); array_spu.has_child = 1; } crSPUInitDispatchTable( &(array_spu.super) ); crSPUCopyDispatchTable( &(array_spu.super), &(self->superSPU->dispatch_table) ); arrayspuSetVBoxConfiguration(); crStateInit(); /*@todo seems default context ain't needed at all*/ array_spu.defaultctx = crStateCreateContext( NULL, 0, NULL ); #ifdef CR_ARB_vertex_buffer_object array_spu.defaultctx->bufferobject.retainBufferData = GL_TRUE; #endif /* we call SetCurrent instead of MakeCurrent as the differencer * isn't setup yet anyway */ crStateSetCurrent( array_spu.defaultctx ); array_spu.numContexts = 0; crMemZero(array_spu.context, CR_MAX_CONTEXTS * sizeof(ContextInfo)); return &array_functions; }
static SPUFunctions *hiddenlineSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { (void) context_id; (void) num_contexts; #ifdef CHROMIUM_THREADSAFE crDebug("Hiddenline SPU: thread-safe"); #endif hiddenline_spu.id = id; hiddenline_spu.has_child = 0; if (child) { crSPUInitDispatchTable( &(hiddenline_spu.child) ); crSPUCopyDispatchTable( &(hiddenline_spu.child), &(child->dispatch_table) ); hiddenline_spu.has_child = 1; } crSPUInitDispatchTable( &(hiddenline_spu.super) ); crSPUCopyDispatchTable( &(hiddenline_spu.super), &(self->superSPU->dispatch_table) ); hiddenlinespuGatherConfiguration( child ); /* We need to track state so that the packer can deal with pixel data */ crStateInit(); hiddenlinespuCreateFunctions(); hiddenline_spu.contextTable = crAllocHashtable(); #ifdef CHROMIUM_THREADSAFE crInitTSD(&_HiddenlineTSD); #else hiddenline_spu.currentContext = NULL; #endif crInitMutex(&(hiddenline_spu.mutex)); return &hiddenline_functions; }
/** * Vnc spu init function * \param id * \param child * \param self * \param context_id * \param num_contexts */ static SPUFunctions * vncSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { (void) self; (void) context_id; (void) num_contexts; vnc_spu.id = id; vnc_spu.has_child = 0; vnc_spu.server = NULL; /* We should always have a child (next) SPU since we're derived from * the Passthrough SPU which requires a child/next SPU. */ if (child) { crSPUInitDispatchTable( &(vnc_spu.child) ); crSPUCopyDispatchTable( &(vnc_spu.child), &(child->dispatch_table) ); vnc_spu.has_child = 1; } crSPUInitDispatchTable( &(vnc_spu.super) ); crSPUCopyDispatchTable( &(vnc_spu.super), &(self->superSPU->dispatch_table) ); vncspuGatherConfiguration(); vnc_spu.windowTable = crAllocHashtable(); vncspuNetLoggerInit(); vncspuInitialize(); vncspuStartServerThread(); return &vnc_functions; }
static void stubCheckMultithread( void ) { static unsigned long knownID; static GLboolean firstCall = GL_TRUE; if (stub.threadSafe) return; /* nothing new, nothing to do */ if (firstCall) { knownID = crThreadID(); firstCall = GL_FALSE; } else if (knownID != crThreadID()) { /* going thread-safe now! */ stub.threadSafe = GL_TRUE; crSPUCopyDispatchTable(&glim, &stubThreadsafeDispatch); } }
static SPUFunctions * printSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { (void) context_id; (void) num_contexts; (void) child; print_spu.id = id; printspuGatherConfiguration( child ); crSPUInitDispatchTable( &(print_spu.passthrough) ); crSPUCopyDispatchTable( &(print_spu.passthrough), &(self->superSPU->dispatch_table) ); #ifndef WINDOWS /* If we were given a marker signal, install our signal handler. */ if (print_spu.marker_signal) { print_spu.old_signal_handler = signal(print_spu.marker_signal, printspu_signal_handler); } #endif return &print_functions; }
static void hiddenlineSPUSelfDispatch(SPUDispatchTable *self) { crSPUInitDispatchTable( &(hiddenline_spu.self) ); crSPUCopyDispatchTable( &(hiddenline_spu.self), self ); }
static void tilesortSPUSelfDispatch(SPUDispatchTable *self) { crSPUInitDispatchTable( &(tilesort_spu.self) ); crSPUCopyDispatchTable( &(tilesort_spu.self), self ); }
static void arraySPUSelfDispatch(SPUDispatchTable *self) { crSPUInitDispatchTable( &(array_spu.self) ); crSPUCopyDispatchTable( &(array_spu.self), self ); }
static void packSPUSelfDispatch(SPUDispatchTable *self) { crSPUInitDispatchTable( &(pack_spu.self) ); crSPUCopyDispatchTable( &(pack_spu.self), self ); }