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 * 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 *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 * packSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { ThreadInfo *thread; (void) context_id; (void) num_contexts; (void) child; (void) self; #if defined(CHROMIUM_THREADSAFE) && !defined(WINDOWS) crInitMutex(&_PackMutex); #endif pack_spu.id = id; packspuSetVBoxConfiguration( child ); /* This connects to the server, sets up the packer, etc. */ thread = packspuNewThread( crThreadID() ); if (!thread) { return NULL; } CRASSERT( thread == &(pack_spu.thread[0]) ); pack_spu.idxThreadInUse = 0; packspuCreateFunctions(); crStateInit(); return &pack_functions; }
static SPUFunctions * packSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { ThreadInfo *thread; (void) context_id; (void) num_contexts; (void) child; (void) self; #if defined(CHROMIUM_THREADSAFE) && !defined(WINDOWS) crInitMutex(&_PackMutex); #endif #ifdef CHROMIUM_THREADSAFE crInitTSD(&_PackerTSD); crInitTSD(&_PackTSD); #endif pack_spu.id = id; packspuSetVBoxConfiguration( child ); #if defined(WINDOWS) && defined(VBOX_WITH_WDDM) pack_spu.bIsWDDMCrHgsmi = isVBoxWDDMCrHgsmi(); #endif #ifdef VBOX_WITH_CRPACKSPU_DUMPER memset(&pack_spu.Dumper, 0, sizeof (pack_spu.Dumper)); #endif if (!CRPACKSPU_IS_WDDM_CRHGSMI()) { /* This connects to the server, sets up the packer, etc. */ thread = packspuNewThread( #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) NULL #endif ); if (!thread) { return NULL; } CRASSERT( thread == &(pack_spu.thread[0]) ); pack_spu.idxThreadInUse = 0; } packspuCreateFunctions(); crStateInit(); return &pack_functions; }
static SPUFunctions * packSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { ThreadInfo *thread; (void) context_id; (void) num_contexts; (void) child; (void) self; #if defined(CHROMIUM_THREADSAFE) && !defined(WINDOWS) crInitMutex(&_PackMutex); #endif pack_spu.id = id; packspuSetVBoxConfiguration( child ); #if defined(WINDOWS) && defined(VBOX_WITH_WDDM) pack_spu.bRunningUnderWDDM = !!GetModuleHandle(VBOX_MODNAME_DISPD3D); #endif if (!CRPACKSPU_IS_WDDM_CRHGSMI()) { /* This connects to the server, sets up the packer, etc. */ thread = packspuNewThread( #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) NULL #endif ); if (!thread) { return NULL; } CRASSERT( thread == &(pack_spu.thread[0]) ); pack_spu.idxThreadInUse = 0; } packspuCreateFunctions(); crStateInit(); return &pack_functions; }
static SPUFunctions *nopSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { (void) id; (void) context_id; (void) num_contexts; (void) child; (void) self; nopspuGatherConfiguration(); crStateInit(); nop_spu.ctx = crStateCreateContext( NULL, CR_RGB_BIT, NULL ); crStateSetCurrent( nop_spu.ctx ); return &nop_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; }
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; }
/** * Do CRServer initializations. After this, we can begin servicing clients. */ void crServerInit(int argc, char *argv[]) { int i; char *mothership = NULL; CRMuralInfo *defaultMural; for (i = 1 ; i < argc ; i++) { if (!crStrcmp( argv[i], "-mothership" )) { if (i == argc - 1) { crError( "-mothership requires an argument" ); } mothership = argv[i+1]; i++; } else if (!crStrcmp( argv[i], "-port" )) { /* This is the port on which we'll accept client connections */ if (i == argc - 1) { crError( "-port requires an argument" ); } cr_server.tcpip_port = crStrToInt(argv[i+1]); i++; } else if (!crStrcmp( argv[i], "-vncmode" )) { cr_server.vncMode = 1; } else if (!crStrcmp( argv[i], "-help" )) { crPrintHelp(); exit(0); } } signal( SIGTERM, crServerCleanup ); signal( SIGINT, crServerCleanup ); #ifndef WINDOWS signal( SIGPIPE, SIG_IGN ); #endif #if DEBUG_FP_EXCEPTIONS { fpu_control_t mask; _FPU_GETCW(mask); mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM | _FPU_MASK_OM | _FPU_MASK_UM); _FPU_SETCW(mask); } #endif cr_server.firstCallCreateContext = GL_TRUE; cr_server.firstCallMakeCurrent = GL_TRUE; /* * Create default mural info and hash table. */ cr_server.muralTable = crAllocHashtable(); defaultMural = (CRMuralInfo *) crCalloc(sizeof(CRMuralInfo)); crHashtableAdd(cr_server.muralTable, 0, defaultMural); cr_server.programTable = crAllocHashtable(); crNetInit(crServerRecv, crServerClose); crStateInit(); crServerGatherConfiguration(mothership); crStateLimitsInit( &(cr_server.limits) ); /* * Default context */ cr_server.contextTable = crAllocHashtable(); cr_server.DummyContext = crStateCreateContext( &cr_server.limits, CR_RGB_BIT | CR_DEPTH_BIT, NULL ); cr_server.curClient->currentCtx = cr_server.DummyContext; crServerInitDispatch(); crStateDiffAPI( &(cr_server.head_spu->dispatch_table) ); crUnpackSetReturnPointer( &(cr_server.return_ptr) ); crUnpackSetWritebackPointer( &(cr_server.writeback_ptr) ); cr_server.barriers = crAllocHashtable(); cr_server.semaphores = crAllocHashtable(); }
/** * Do CRServer initializations. After this, we can begin servicing clients. */ GLboolean crVBoxServerInit(void) { CRMuralInfo *defaultMural; #if DEBUG_FP_EXCEPTIONS { fpu_control_t mask; _FPU_GETCW(mask); mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM | _FPU_MASK_OM | _FPU_MASK_UM); _FPU_SETCW(mask); } #endif crNetInit(crServerRecv, crServerClose); cr_server.firstCallCreateContext = GL_TRUE; cr_server.firstCallMakeCurrent = GL_TRUE; cr_server.bIsInLoadingState = GL_FALSE; cr_server.bIsInSavingState = GL_FALSE; cr_server.pCleanupClient = NULL; /* * Create default mural info and hash table. */ cr_server.muralTable = crAllocHashtable(); defaultMural = (CRMuralInfo *) crCalloc(sizeof(CRMuralInfo)); crHashtableAdd(cr_server.muralTable, 0, defaultMural); cr_server.programTable = crAllocHashtable(); crStateInit(); crStateLimitsInit( &(cr_server.limits) ); cr_server.barriers = crAllocHashtable(); cr_server.semaphores = crAllocHashtable(); crUnpackSetReturnPointer( &(cr_server.return_ptr) ); crUnpackSetWritebackPointer( &(cr_server.writeback_ptr) ); /* * Default context */ cr_server.contextTable = crAllocHashtable(); cr_server.DummyContext = crStateCreateContext( &cr_server.limits, CR_RGB_BIT | CR_DEPTH_BIT, NULL ); cr_server.pContextCreateInfoTable = crAllocHashtable(); cr_server.pWindowCreateInfoTable = crAllocHashtable(); crServerSetVBoxConfigurationHGCM(); if (!cr_server.head_spu) return GL_FALSE; crServerInitDispatch(); crStateDiffAPI( &(cr_server.head_spu->dispatch_table) ); /*Check for PBO support*/ if (crStateGetCurrent()->extensions.ARB_pixel_buffer_object) { cr_server.bUsePBOForReadback=GL_TRUE; } return GL_TRUE; }
static SPUFunctions * tilesortSPUInit( int id, SPU *child, SPU *self, unsigned int context_id, unsigned int num_contexts ) { ThreadInfo *thread0 = &(tilesort_spu.thread[0]); (void) context_id; (void) num_contexts; (void) child; (void) self; #if DEBUG_FP_EXCEPTIONS { fpu_control_t mask; _FPU_GETCW(mask); mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM | _FPU_MASK_OM | _FPU_MASK_UM); _FPU_SETCW(mask); } #endif crRandSeed(id); crMemZero( &tilesort_spu, sizeof(TileSortSPU) ); #ifdef CHROMIUM_THREADSAFE crInitTSD(&_ThreadTSD); crSetTSD(&_ThreadTSD, thread0); crInitMutex(&_TileSortMutex); #endif thread0->state_server_index = -1; /* one-time init for thread */ tilesortspuInitEvaluators(); /* Init window, context hash tables */ tilesort_spu.windowTable = crAllocHashtable(); tilesort_spu.contextTable = crAllocHashtable(); tilesort_spu.listTable = crAllocHashtable(); tilesort_spu.id = id; tilesort_spu.glassesType = RED_BLUE; tilesortspuSetAnaglyphMask(&tilesort_spu); tilesortspuGatherConfiguration( child ); tilesortspuConnectToServers(); /* set up thread0's server connection */ tilesort_spu.geom_buffer_size = tilesort_spu.buffer_size; /* geom_buffer_mtu must fit in data's part of our buffers */ tilesort_spu.geom_buffer_mtu = crPackMaxData(tilesort_spu.buffer_size) /* 24 is the size of the bounds info packet * END_FLUFF is the size of data of the extra End opcode if needed * 4 since BoundsInfo opcode may take a whole 4 bytes * and 4 to let room for extra End's opcode, if needed */ - (24+END_FLUFF+4+4); /* the geometry must also fit in the mtu */ if (tilesort_spu.geom_buffer_mtu > tilesort_spu.MTU - sizeof(CRMessageOpcodes) - (24+END_FLUFF+4+4)) tilesort_spu.geom_buffer_mtu = tilesort_spu.MTU - sizeof(CRMessageOpcodes) - (24+END_FLUFF+4+4); tilesort_spu.swap = thread0->netServer[0].conn->swap; tilesortspuInitThreadPacking( thread0 ); tilesortspuCreateFunctions(); crStateInit(); tilesortspuCreateDiffAPI(); /* special dispatch tables for display lists */ if (tilesort_spu.listTrack || tilesort_spu.lazySendDLists) { crMemZero((void *)&tilesort_spu.packerDispatch, sizeof tilesort_spu.packerDispatch); crSPUInitDispatchTable(&tilesort_spu.packerDispatch); tilesortspuLoadPackTable(&tilesort_spu.packerDispatch); crSPUInitDispatchTable(&tilesort_spu.stateDispatch); tilesortspuLoadStateTable(&tilesort_spu.stateDispatch); } if (tilesort_spu.useDMX) { /* load OpenGL */ int n; crDebug("Tilesort SPU: Using DMX"); n = crLoadOpenGL( &tilesort_spu.ws, NULL); if (!n) { crWarning("Tilesort SPU: Unable to load OpenGL, disabling DMX"); tilesort_spu.useDMX = 0; } } else { crDebug("Tilesort SPU: Not using DMX"); } crDebug("Tilesort SPU: ---------- End of Init -------------"); return &tilesort_functions; }