Esempio n. 1
0
void PACKSPU_APIENTRY packspu_DestroyContext( GLint ctx )
{
    const int slot = ctx - MAGIC_OFFSET;
    ContextInfo *context;
    GET_THREAD(thread);

    CRASSERT(slot >= 0);
    CRASSERT(slot < pack_spu.numContexts);
    CRASSERT(thread);

    context = &(pack_spu.context[slot]);

    if (pack_spu.swap)
        crPackDestroyContextSWAP( context->serverCtx );
    else
        crPackDestroyContext( context->serverCtx );

    crStateDestroyContext( context->clientState );

    context->clientState = NULL;
    context->serverCtx = 0;

    if (thread->currentContext == context) {
        thread->currentContext = NULL;
        crStateMakeCurrent( NULL );
    }
}
Esempio n. 2
0
void REPLICATESPU_APIENTRY
replicatespu_DestroyContext( GLint ctx )
{
	unsigned int i;
	ContextInfo *context = (ContextInfo *) crHashtableSearch(replicate_spu.contextTable, ctx);
	GET_THREAD(thread);

	if (!context) {
		crWarning("Replicate SPU: DestroyContext, bad context %d", ctx);
		return;
	}
	CRASSERT(thread);

	replicatespuFlushAll( (void *)thread );

	for (i = 0; i < CR_MAX_REPLICANTS; i++) {
		if (!IS_CONNECTED(replicate_spu.rserver[i].conn))
			continue;

		if (replicate_spu.swap)
			crPackDestroyContextSWAP( context->rserverCtx[i] );
		else
			crPackDestroyContext( context->rserverCtx[i] );

		replicatespuFlushOne(thread, i);
	}

	crStateDestroyContext( context->State );

	/* Although we only allocate a display list manager once,
	 * we free it every time; this is okay since the DLM itself
	 * will track its uses and will only release the resources
	 * when the last user has relinquished it.
	 */
	crDLMFreeDLM(context->displayListManager);
	crDLMFreeContext(context->dlmState);

	if (thread->currentContext == context) {
		thread->currentContext = NULL;
		crStateMakeCurrent( NULL );
		crDLMSetCurrentState(NULL);
	}

	/* zero, just to be safe */
	crMemZero(context, sizeof(ContextInfo));

	/* Delete from both the context table, and the context list. */
	crHashtableDelete(replicate_spu.contextTable, ctx, crFree);
	{
	    CRListIterator *foundElement = crListFind(replicate_spu.contextList, (void *)ctx, CompareIntegers);
	    if (foundElement != NULL) {
		crListErase(replicate_spu.contextList, foundElement);
	    }
	}
}