/* Force the context `c' to be the current context and associate with it * buffer `b'. */ GLboolean r128MakeCurrent( __DRIcontextPrivate *driContextPriv, __DRIdrawablePrivate *driDrawPriv, __DRIdrawablePrivate *driReadPriv ) { if ( driContextPriv ) { GET_CURRENT_CONTEXT(ctx); r128ContextPtr oldR128Ctx = ctx ? R128_CONTEXT(ctx) : NULL; r128ContextPtr newR128Ctx = (r128ContextPtr) driContextPriv->driverPrivate; if ( newR128Ctx != oldR128Ctx ) { newR128Ctx->new_state |= R128_NEW_CONTEXT; newR128Ctx->dirty = R128_UPLOAD_ALL; } newR128Ctx->driDrawable = driDrawPriv; _mesa_make_current2( newR128Ctx->glCtx, (GLframebuffer *) driDrawPriv->driverPrivate, (GLframebuffer *) driReadPriv->driverPrivate ); newR128Ctx->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP; if ( !newR128Ctx->glCtx->Viewport.Width ) { _mesa_set_viewport(newR128Ctx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h); } } else { _mesa_make_current( 0, 0 ); } return GL_TRUE; }
GLboolean sisMakeCurrent( __DRIcontextPrivate *driContextPriv, __DRIdrawablePrivate *driDrawPriv, __DRIdrawablePrivate *driReadPriv ) { if ( driContextPriv ) { GET_CURRENT_CONTEXT(ctx); sisContextPtr oldSisCtx = ctx ? SIS_CONTEXT(ctx) : NULL; sisContextPtr newSisCtx = (sisContextPtr) driContextPriv->driverPrivate; if ( newSisCtx != oldSisCtx) { newSisCtx->GlobalFlag = GFLAG_ALL; } newSisCtx->driDrawable = driDrawPriv; _mesa_make_current2( newSisCtx->glCtx, (GLframebuffer *) driDrawPriv->driverPrivate, (GLframebuffer *) driReadPriv->driverPrivate ); sisUpdateBufferSize( newSisCtx ); sisUpdateClipping( newSisCtx->glCtx ); } else { _mesa_make_current( 0, 0 ); } return GL_TRUE; }
/* Force the context `c' to be the current context and associate with it * buffer `b'. */ GLboolean radeonMakeCurrent( __DRIcontextPrivate *driContextPriv, __DRIdrawablePrivate *driDrawPriv, __DRIdrawablePrivate *driReadPriv ) { if ( driContextPriv ) { radeonContextPtr newCtx = (radeonContextPtr) driContextPriv->driverPrivate; if (RADEON_DEBUG & DEBUG_DRI) fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *)newCtx->glCtx); if ( newCtx->dri.drawable != driDrawPriv ) { newCtx->dri.drawable = driDrawPriv; radeonUpdateWindow( newCtx->glCtx ); radeonUpdateViewportOffset( newCtx->glCtx ); } _mesa_make_current2( newCtx->glCtx, (GLframebuffer *) driDrawPriv->driverPrivate, (GLframebuffer *) driReadPriv->driverPrivate ); if ( !newCtx->glCtx->Viewport.Width ) { _mesa_set_viewport( newCtx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h ); } if (newCtx->vb.enabled) radeonVtxfmtMakeCurrent( newCtx->glCtx ); } else { if (RADEON_DEBUG & DEBUG_DRI) fprintf(stderr, "%s ctx is null\n", __FUNCTION__); _mesa_make_current( 0, 0 ); } if (RADEON_DEBUG & DEBUG_DRI) fprintf(stderr, "End %s\n", __FUNCTION__); return GL_TRUE; }
/* Destroy the Mesa and driver specific context data. */ void radeonDestroyContext( __DRIcontextPrivate *driContextPriv ) { GET_CURRENT_CONTEXT(ctx); radeonContextPtr rmesa = (radeonContextPtr) driContextPriv->driverPrivate; radeonContextPtr current = ctx ? RADEON_CONTEXT(ctx) : NULL; /* check if we're deleting the currently bound context */ if (rmesa == current) { RADEON_FIREVERTICES( rmesa ); _mesa_make_current2(NULL, NULL, NULL); } /* Free radeon context resources */ assert(rmesa); /* should never be null */ if ( rmesa ) { GLboolean release_texture_heaps; release_texture_heaps = (rmesa->glCtx->Shared->RefCount == 1); _swsetup_DestroyContext( rmesa->glCtx ); _tnl_DestroyContext( rmesa->glCtx ); _ac_DestroyContext( rmesa->glCtx ); _swrast_DestroyContext( rmesa->glCtx ); radeonDestroySwtcl( rmesa->glCtx ); radeonReleaseArrays( rmesa->glCtx, ~0 ); if (rmesa->dma.current.buf) { radeonReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ ); radeonFlushCmdBuf( rmesa, __FUNCTION__ ); } if (!rmesa->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE) if (!getenv("RADEON_NO_VTXFMT")) radeonVtxfmtDestroy( rmesa->glCtx ); /* free the Mesa context */ rmesa->glCtx->DriverCtx = NULL; _mesa_destroy_context( rmesa->glCtx ); if (rmesa->state.scissor.pClipRects) { FREE(rmesa->state.scissor.pClipRects); rmesa->state.scissor.pClipRects = 0; } if ( release_texture_heaps ) { /* This share group is about to go away, free our private * texture object data. */ int i; for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) { driDestroyTextureHeap( rmesa->texture_heaps[ i ] ); rmesa->texture_heaps[ i ] = NULL; } assert( is_empty_list( & rmesa->swapped ) ); } FREE( rmesa ); } }