From d3fd7ba8af15bead2f770d68a893449adeb11397 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 20 Jan 2004 02:49:27 +0000 Subject: Before calling _mesa_create_context(), initialize a dd_function_table struct by calling _mesa_init_driver_functions() and then plugging in the driver- specific functions. In particular, make sure ctx->Driver.NewTextureObject points to the appropriate driver function so that _all_ texture objects are augmented with the driver-specific data. Put in a bunch of assertions in the texture-related driver functions that texObj->DriverData is valid. Remove old dead code in near future. --- src/mesa/drivers/dri/r200/r200_context.c | 61 +++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 16 deletions(-) (limited to 'src/mesa/drivers/dri/r200/r200_context.c') diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index efa658717b..f8ab8d3697 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -49,6 +49,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tnl/tnl.h" #include "tnl/t_pipeline.h" +#include "drivers/common/driverfuncs.h" + #include "r200_context.h" #include "r200_ioctl.h" #include "r200_state.h" @@ -186,15 +188,15 @@ static const struct tnl_pipeline_stage *r200_pipeline[] = { /* Initialize the driver's misc functions. */ -static void r200InitDriverFuncs( GLcontext *ctx ) +static void r200InitDriverFuncs( struct dd_function_table *functions ) { - ctx->Driver.GetBufferSize = r200GetBufferSize; - ctx->Driver.ResizeBuffers = _swrast_alloc_buffers; - ctx->Driver.GetString = r200GetString; + functions->GetBufferSize = r200GetBufferSize; + functions->ResizeBuffers = _swrast_alloc_buffers; + functions->GetString = r200GetString; - ctx->Driver.Error = NULL; - ctx->Driver.DrawPixels = NULL; - ctx->Driver.Bitmap = NULL; + functions->Error = NULL; + functions->DrawPixels = NULL; + functions->Bitmap = NULL; } static const struct dri_debug_control debug_control[] = @@ -227,7 +229,7 @@ get_ust_nop( uint64_t * ust ) } -/* Create the device specific context. +/* Create the device specific rendering context. */ GLboolean r200CreateContext( const __GLcontextModes *glVisual, __DRIcontextPrivate *driContextPriv, @@ -235,6 +237,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, { __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; r200ScreenPtr screen = (r200ScreenPtr)(sPriv->private); + struct dd_function_table functions; r200ContextPtr rmesa; GLcontext *ctx, *shareCtx; int i; @@ -249,12 +252,31 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, if ( !rmesa ) return GL_FALSE; - /* Allocate the Mesa context */ + /* Parse configuration files. + * Do this here so that initialMaxAnisotropy is set before we create + * the default textures. + */ + driParseConfigFiles (&rmesa->optionCache, &screen->optionCache, + screen->driScreen->myNum, "r200"); + rmesa->initialMaxAnisotropy = driQueryOptionf(&rmesa->optionCache, + "def_max_anisotropy"); + + /* Init default driver functions then plug in our R200-specific functions + * (the texture functions are especially important) + */ + _mesa_init_driver_functions(&functions); + r200InitDriverFuncs(&functions); + r200InitIoctlFuncs(&functions); + r200InitStateFuncs(&functions); + r200InitTextureFuncs(&functions); + + /* Allocate and initialize the Mesa context */ if (sharedContextPrivate) shareCtx = ((r200ContextPtr) sharedContextPrivate)->glCtx; else shareCtx = NULL; - rmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) rmesa, GL_TRUE); + rmesa->glCtx = _mesa_create_context(glVisual, shareCtx, + &functions, (void *) rmesa); if (!rmesa->glCtx) { FREE(rmesa); return GL_FALSE; @@ -270,10 +292,6 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, rmesa->dri.fd = sPriv->fd; rmesa->dri.drmMinor = sPriv->drmMinor; - /* Parse configuration files */ - driParseConfigFiles (&rmesa->optionCache, &screen->optionCache, - screen->driScreen->myNum, "r200"); - rmesa->r200Screen = screen; rmesa->sarea = (RADEONSAREAPrivPtr)((GLubyte *)sPriv->pSAREA + screen->sarea_priv_offset); @@ -285,6 +303,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, make_empty_list( & rmesa->swapped ); rmesa->nr_heaps = 1 /* screen->numTexHeaps */ ; + assert(rmesa->nr_heaps < R200_NR_TEX_HEAPS); for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) { rmesa->texture_heaps[i] = driCreateTextureHeap( i, rmesa, screen->texSize[i], @@ -381,15 +400,25 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, if (rmesa->r200Screen->drmSupportsCubeMaps) _mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" ); +#if 0 r200InitDriverFuncs( ctx ); r200InitIoctlFuncs( ctx ); r200InitStateFuncs( ctx ); - r200InitSpanFuncs( ctx ); - r200InitPixelFuncs( ctx ); r200InitTextureFuncs( ctx ); +#endif + /* plug in a few more device driver functions */ + /* XXX these should really go right after _mesa_init_driver_functions() */ + r200InitPixelFuncs( ctx ); + r200InitSpanFuncs( ctx ); + r200InitTnlFuncs( ctx ); r200InitState( rmesa ); r200InitSwtcl( ctx ); + /* used to be in r200InitTextureFuncs() */ + driInitTextureObjects( ctx, & rmesa->swapped, + DRI_TEXMGR_DO_TEXTURE_1D + | DRI_TEXMGR_DO_TEXTURE_2D ); + fthrottle_mode = driQueryOptioni(&rmesa->optionCache, "fthrottle_mode"); rmesa->iw.irq_seq = -1; rmesa->irqsEmitted = 0; -- cgit v1.2.3