void DLM_APIENTRY crDLMFreeContext(CRDLMContextState *state, SPUDispatchTable *dispatchTable) { CRDLMContextState *listState = CURRENT_STATE(); /* If we're currently using this context, release it first */ if (listState == state) crDLMSetCurrentState(NULL); /* Try to free the DLM. This will either decrement the use count, * or will actually free the DLM, if we were the last user. */ crDLMFreeDLM(state->dlm, dispatchTable); state->dlm = NULL; /* If any buffers still remain (e.g. because there was an open * display list), remove those as well. */ if (state->currentListInfo) { crdlmFreeDisplayListResourcesCb((void *)state->currentListInfo, (void *)dispatchTable); state->currentListInfo = NULL; } state->currentListIdentifier = 0; /* Free the state record itself */ crFree(state); }
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); } } }