Esempio n. 1
0
DECLEXPORT(void) STATE_APIENTRY crStateGLSLDestroy(CRContext *ctx)
{
    CRContext *g = GetCurrentContext();

    /*@todo: hack to allow crStateFreeGLSLProgram to work correctly, 
      as the current context isn't the one being destroyed*/
#ifdef CHROMIUM_THREADSAFE
    CRASSERT(g != ctx);
    VBoxTlsRefAddRef(ctx); /* <- this is a hack to avoid subsequent SetCurrentContext(g) do recursive Destroy for ctx */
    if (g)
        VBoxTlsRefAddRef(g); /* <- ensure the g is not destroyed by the following SetCurrentContext call */
    SetCurrentContext(ctx);
#else
    __currentContext = ctx;
#endif

    crFreeHashtable(ctx->glsl.programs, crStateFreeGLSLProgram);
    crFreeHashtable(ctx->glsl.shaders, crStateFreeGLSLShader);

#ifdef CHROMIUM_THREADSAFE
    SetCurrentContext(g);
    if (g)
        VBoxTlsRefRelease(g);
    VBoxTlsRefRelease(ctx); /* <- restore back the cRefs (see above) */
#else
    __currentContext = g;
#endif

}
Esempio n. 2
0
void crStateDestroyContext( CRContext *ctx )
{
    CRContext *current = GetCurrentContext();

    if (current == ctx) {
        /* destroying the current context - have to be careful here */
        CRASSERT(defaultContext);
        /* Check to see if the differencer exists first,
           we may not have one, aka the packspu */
        if (diff_api.AlphaFunc)
            crStateSwitchContext(current, defaultContext);
#ifdef CHROMIUM_THREADSAFE
        SetCurrentContext(defaultContext);
#else
        __currentContext = defaultContext;
#endif
        /* ensure matrix state is also current */
        crStateMatrixMode(defaultContext->transform.matrixMode);
    }
    g_availableContexts[ctx->id] = 0;

#ifdef CHROMIUM_THREADSAFE
    VBoxTlsRefRelease(ctx);
#else
    crStateFreeContext(ctx);
#endif
}
Esempio n. 3
0
/*
 * Allocate the state (dirty) bits data structures.
 * This should be called before we create any contexts.
 * We'll also create the default/NULL context at this time and make
 * it the current context by default.  This means that if someone
 * tries to set GL state before calling MakeCurrent() they'll be
 * modifying the default state object, and not segfaulting on a NULL
 * pointer somewhere.
 */
void crStateInit(void)
{
    unsigned int i;

    /* Purely initialize the context bits */
    if (!__currentBits) {
        __currentBits = (CRStateBits *) crCalloc( sizeof(CRStateBits) );
        crStateClientInitBits( &(__currentBits->client) );
        crStateLightingInitBits( &(__currentBits->lighting) );
    } else
        crWarning("State tracker is being re-initialized..\n");

    for (i=0;i<CR_MAX_CONTEXTS;i++)
        g_availableContexts[i] = 0;

#ifdef CHROMIUM_THREADSAFE
    if (!__isContextTLSInited)
    {
# ifndef RT_OS_WINDOWS
        /* tls destructor is implemented for all platforms except windows*/
        crInitTSDF(&__contextTSD, crStateThreadTlsDtor);
# else
        /* windows should do cleanup via DllMain THREAD_DETACH notification */
        crInitTSD(&__contextTSD);
# endif
        __isContextTLSInited = 1;
    }
#endif

    if (defaultContext) {
        /* Free the default/NULL context.
         * Ensures context bits are reset */
#ifdef CHROMIUM_THREADSAFE
        SetCurrentContext(NULL);
        VBoxTlsRefRelease(defaultContext);
#else
        crStateFreeContext(defaultContext);
        __currentContext = NULL;
#endif
    }

    /* Reset diff_api */
    crMemZero(&diff_api, sizeof(SPUDispatchTable));

    /* Allocate the default/NULL context */
    defaultContext = crStateCreateContextId(0, NULL, CR_RGB_BIT, NULL);
    CRASSERT(g_availableContexts[0] == 0);
    g_availableContexts[0] = 1; /* in use forever */

#ifdef CHROMIUM_THREADSAFE
    SetCurrentContext(defaultContext);
#else
    __currentContext = defaultContext;
#endif
}
void
stubDestroyContext( unsigned long contextId )
{
    ContextInfo *context;

    if (!stub.contextTable) {
        return;
    }

    /* 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);
    crHashtableLock(stub.contextTable);

    context = (ContextInfo *) crHashtableSearch(stub.contextTable, contextId);
    if (context)
        stubDestroyContextLocked(context);
    else
        crError("No context.");

#ifdef CHROMIUM_THREADSAFE
    if (stubGetCurrentContext() == context) {
        stubSetCurrentContext(NULL);
    }

    VBoxTlsRefMarkDestroy(context);
    VBoxTlsRefRelease(context);
#else
    if (stubGetCurrentContext() == context) {
        stubSetCurrentContext(NULL);
    }
    stubContextFree(context);
#endif
    crHashtableUnlock(stub.contextTable);
    crHashtableUnlock(stub.windowTable);
}
Esempio n. 5
0
File: load.c Progetto: OSLL/vboxhsm
static DECLCALLBACK(void) stubThreadTlsDtor(void *pvValue)
{
    ContextInfo *pCtx = (ContextInfo*)pvValue;
    VBoxTlsRefRelease(pCtx);
}
Esempio n. 6
0
static DECLCALLBACK(void) crStateThreadTlsDtor(void *pvValue)
{
    CRContext *pCtx = (CRContext*)pvValue;
    VBoxTlsRefRelease(pCtx);
}
Esempio n. 7
0
static void stubThreadTlsDtor(void *pvValue)
{
    ContextInfo *pCtx = (ContextInfo*)pvValue;
    VBoxTlsRefRelease(pCtx);
}