Exemplo 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

}
Exemplo n.º 2
0
static int
tilesortSPUCleanup(void)
{
    crFreeHashtable(tilesort_spu.windowTable, freeWindowCallback);
    tilesort_spu.windowTable = NULL;
    crFreeHashtable(tilesort_spu.contextTable, freeContextCallback);
    tilesort_spu.contextTable = NULL;
    crFreeHashtable(tilesort_spu.listTable, freeListCallback);
    tilesort_spu.listTable = NULL;

    return 1;
}
Exemplo n.º 3
0
Arquivo: load.c Projeto: OSLL/vboxhsm
/**
 * 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));

}
Exemplo n.º 4
0
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();
}
Exemplo n.º 5
0
crStateFreeShared(CRSharedState *s)
{
    s->refCount--;
    if (s->refCount <= 0) {
        if (s==gSharedState)
        {
            gSharedState = NULL;
        }
        crFreeHashtable(s->textureTable, DeleteTextureCallback);
        crFreeHashtable(s->dlistTable, crFree); /* call crFree for each entry */
        crFreeHashtable(s->buffersTable, crStateFreeBufferObject);
        crFreeHashtable(s->fbTable, crStateFreeFBO);
        crFreeHashtable(s->rbTable, crStateFreeRBO);
        crFree(s);
    }
}
static int
expandoSPUCleanup(void)
{
    crFreeHashtable(expando_spu.contextTable, expando_free_context_state);
    crStateDestroy();
    return 1;
}
static void
stubDestroyContextLocked( ContextInfo *context )
{
    unsigned long contextId = context->id;
    if (context->type == NATIVE) {
#ifdef WINDOWS
        stub.wsInterface.wglDeleteContext( context->hglrc );
#elif defined(Darwin)
        stub.wsInterface.CGLDestroyContext( context->cglc );
#elif defined(GLX)
        stub.wsInterface.glXDestroyContext( context->dpy, context->glxContext );
#endif
    }
    else if (context->type == CHROMIUM) {
        /* Have pack SPU or tilesort SPU, etc. destroy the context */
        CRASSERT(context->spuContext >= 0);
        stub.spu->dispatch_table.DestroyContext( context->spuContext );
        crHashtableWalk(stub.windowTable, stubWindowCheckOwnerCB, context);
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
        if (context->spuConnection)
        {
            stub.spu->dispatch_table.VBoxConDestroy(context->spuConnection);
            context->spuConnection = 0;
        }
#endif
    }

#ifdef GLX
    crFreeHashtable(context->pGLXPixmapsHash, crFree);
#endif

    crHashtableDelete(stub.contextTable, contextId, NULL);
}
Exemplo n.º 8
0
static void crStateFreeGLSLProgram(void *data)
{
    CRGLSLProgram* pProgram = (CRGLSLProgram *) data;

    crFreeHashtable(pProgram->currentState.attachedShaders, crStateShaderDecRefCount);

    if (pProgram->activeState.attachedShaders)
    {
        CRContext *g = GetCurrentContext();
        crHashtableWalk(pProgram->activeState.attachedShaders, crStateFakeDecRefCountCB, g);
        crFreeHashtable(pProgram->activeState.attachedShaders, crStateFreeGLSLShader);
    }

    crStateFreeProgramAttribs(pProgram);

    crStateFreeProgramUniforms(pProgram);

    crFree(pProgram);
}
Exemplo n.º 9
0
DECLEXPORT(void) STATE_APIENTRY crStateLinkProgram(GLuint program)
{
    CRGLSLProgram *pProgram = crStateGetProgramObj(program);
    GLuint i;

    if (!pProgram)
    {
        crWarning("Unknown program %d", program);
        return;
    }

    pProgram->linked = GL_TRUE;

    /*Free program's active state*/
    if (pProgram->activeState.attachedShaders)
    {
        crHashtableWalk(pProgram->activeState.attachedShaders, crStateFakeDecRefCountCB, NULL);
        crFreeHashtable(pProgram->activeState.attachedShaders, crStateFreeGLSLShader);
        pProgram->activeState.attachedShaders = NULL;
    }
    for (i=0; i<pProgram->activeState.cAttribs; ++i)
    {
        crFree(pProgram->activeState.pAttribs[i].name);
    }
    if (pProgram->activeState.pAttribs) crFree(pProgram->activeState.pAttribs);

    /*copy current state to active state*/
    crMemcpy(&pProgram->activeState, &pProgram->currentState, sizeof(CRGLSLProgramState));

    pProgram->activeState.attachedShaders = crAllocHashtable();
    if (!pProgram->activeState.attachedShaders)
    {
        crWarning("crStateLinkProgram: Out of memory!");
        return;
    }
    crHashtableWalk(pProgram->currentState.attachedShaders, crStateCopyShaderCB, pProgram);

    /*that's not a bug, note the memcpy above*/
    if (pProgram->activeState.pAttribs)
    {
        pProgram->activeState.pAttribs = (CRGLSLAttrib *) crAlloc(pProgram->activeState.cAttribs * sizeof(CRGLSLAttrib));
    }

    for (i=0; i<pProgram->activeState.cAttribs; ++i)
    {
        crMemcpy(&pProgram->activeState.pAttribs[i], &pProgram->currentState.pAttribs[i], sizeof(CRGLSLAttrib));
        pProgram->activeState.pAttribs[i].name = crStrdup(pProgram->currentState.pAttribs[i].name);
    }

    crStateFreeProgramUniforms(pProgram);
}
/* This utility routine frees a DLMListInfo structure and all
 * of its components.  It is used directly, when deleting a
 * single list; it is also used as a callback function for
 * hash tree operations (Free and Replace).
 *
 * The parameter is listed as a (void *) instead of a (DLMListInfo *)
 * in order that the function can be used as a callback routine for
 * the hash table functions.  The (void *) designation causes no
 * other harm, save disabling type-checking on the pointer argument
 * of the function.
 */
void crdlm_free_list(void *parm)
{
	DLMListInfo *listInfo = (DLMListInfo *) parm;

	free_instance_list(listInfo->first);
	listInfo->first = listInfo->last = NULL;

	/* The references list has no allocated information; it's
	 * just a set of entries.  So we don't need to free any
	 * information as each entry is deleted.
	 */
	crFreeHashtable(listInfo->references, NULL);

	crFree(listInfo);
}
Exemplo n.º 11
0
static int hiddenlineSPUCleanup(void)
{
	crFreeHashtable(hiddenline_spu.contextTable, crFree);
	return 1;
}
Exemplo n.º 12
0
static int
matteSPUCleanup(void)
{
	crFreeHashtable(matte_spu.contextTable, matteFreeContextInfo);
	return 1;
}
Exemplo n.º 13
0
static int renderSPUCleanup(void)
{
    renderspuVBoxCompositorClearAll();

    if (render_spu.blitterTable)
    {
        crFreeHashtable(render_spu.blitterTable, DeleteBlitterCallback);
        render_spu.blitterTable = NULL;
    }
    else
    {
        crHashtableWalk(render_spu.windowTable, renderspuBlitterCleanupCB, NULL);

        crHashtableWalk(render_spu.dummyWindowTable, renderspuBlitterCleanupCB, NULL);
    }

    renderspuSetDefaultSharedContext(NULL);

    crFreeHashtable(render_spu.contextTable, DeleteContextCallback);
    render_spu.contextTable = NULL;
    crFreeHashtable(render_spu.windowTable, DeleteWindowCallback);
    render_spu.windowTable = NULL;
    crFreeHashtable(render_spu.dummyWindowTable, DeleteWindowCallback);
    render_spu.dummyWindowTable = NULL;
    crFreeHashtable(render_spu.barrierHash, crFree);
    render_spu.barrierHash = NULL;

#ifdef RT_OS_DARWIN
# ifndef VBOX_WITH_COCOA_QT
    render_spu.fInit = false;
    DisposeEventHandlerUPP(render_spu.hParentEventHandler);
    ReleaseWindowGroup(render_spu.pMasterGroup);
    ReleaseWindowGroup(render_spu.pParentGroup);
    if (render_spu.hRootVisibleRegion)
    {
        DisposeRgn(render_spu.hRootVisibleRegion);
        render_spu.hRootVisibleRegion = 0;
    }
    render_spu.currentBufferName = 1;
    render_spu.uiDockUpdateTS = 0;
    RTSemFastMutexDestroy(render_spu.syncMutex);
# else /* VBOX_WITH_COCOA_QT */
# endif /* VBOX_WITH_COCOA_QT */
#endif /* RT_OS_DARWIN */

#ifdef RT_OS_WINDOWS
    if (render_spu.dwWinThreadId)
    {
        HANDLE hNative;

        hNative = OpenThread(SYNCHRONIZE|THREAD_QUERY_INFORMATION|THREAD_TERMINATE,
                             false, render_spu.dwWinThreadId);
        if (!hNative)
        {
            crWarning("Failed to get handle for window thread(%#x)", GetLastError());
        }

        if (PostThreadMessage(render_spu.dwWinThreadId, WM_QUIT, 0, 0))
        {
            WaitForSingleObject(render_spu.hWinThreadReadyEvent, INFINITE);

            /*wait for os thread to actually finish*/
            if (hNative && WaitForSingleObject(hNative, 3000)==WAIT_TIMEOUT)
            {
                crDebug("Wait failed, terminating");
                if (!TerminateThread(hNative, 1))
                {
                    crWarning("TerminateThread failed");
                }
            }
        }

        if (hNative)
        {
            CloseHandle(hNative);
        }
    }
    CloseHandle(render_spu.hWinThreadReadyEvent);
    render_spu.hWinThreadReadyEvent = NULL;
#endif

    crUnloadOpenGL();

#ifdef CHROMIUM_THREADSAFE
    crFreeTSD(&_RenderTSD);
#endif

    return 1;
}
Exemplo n.º 14
0
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();
}
Exemplo n.º 15
0
void CrDemTerm(PCR_DISPLAY_ENTRY_MAP pMap)
{
    crFreeHashtable(pMap->pTextureMap, crFree);
}
Exemplo n.º 16
0
void
crStateOcclusionDestroy(CRContext *ctx)
{
	CROcclusionState *o = &(ctx->occlusion);
	crFreeHashtable(o->objects, crFree);
}