diff options
author | Brian Paul <[email protected]> | 2004-01-20 02:49:27 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2004-01-20 02:49:27 +0000 |
commit | d3fd7ba8af15bead2f770d68a893449adeb11397 (patch) | |
tree | 2c92f7cb35f2776d6c461378f93b556fc1ca080d /src/mesa/drivers/dri/i810 | |
parent | 988a8862c8379c0312d40353ee4b35537dff59a1 (diff) |
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.
Diffstat (limited to 'src/mesa/drivers/dri/i810')
-rw-r--r-- | src/mesa/drivers/dri/i810/Makefile.solo | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i810/i810context.c | 18 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i810/i810ioctl.c | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i810/i810ioctl.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i810/i810tex.c | 83 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i810/i810tex.h | 2 |
6 files changed, 71 insertions, 43 deletions
diff --git a/src/mesa/drivers/dri/i810/Makefile.solo b/src/mesa/drivers/dri/i810/Makefile.solo index 19fca1864ce..2faa5f64f38 100644 --- a/src/mesa/drivers/dri/i810/Makefile.solo +++ b/src/mesa/drivers/dri/i810/Makefile.solo @@ -35,6 +35,7 @@ DRIVER_SOURCES = \ i810texstate.c \ i810tris.c \ i810vb.c \ + ../../common/driverfuncs.c \ ../common/mm.c \ ../common/utils.c \ ../common/texmem.c \ diff --git a/src/mesa/drivers/dri/i810/i810context.c b/src/mesa/drivers/dri/i810/i810context.c index d81431765fa..78698e861c2 100644 --- a/src/mesa/drivers/dri/i810/i810context.c +++ b/src/mesa/drivers/dri/i810/i810context.c @@ -47,6 +47,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tnl/t_pipeline.h" +#include "drivers/common/driverfuncs.h" + #include "i810screen.h" #include "i810_dri.h" @@ -152,6 +154,7 @@ i810CreateContext( const __GLcontextModes *mesaVis, i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private; I810SAREAPtr saPriv = (I810SAREAPtr) (((GLubyte *)sPriv->pSAREA) + i810Screen->sarea_priv_offset); + struct dd_function_table functions; /* Allocate i810 context */ imesa = (i810ContextPtr) CALLOC_STRUCT(i810_context_t); @@ -159,12 +162,20 @@ i810CreateContext( const __GLcontextModes *mesaVis, return GL_FALSE; } + /* Init default driver functions then plug in our I810-specific functions + * (the texture functions are especially important) + */ + _mesa_init_driver_functions( &functions ); + i810InitTextureFuncs( &functions ); + i810InitIoctlFuncs( &functions ); + /* Allocate the Mesa context */ if (sharedContextPrivate) shareCtx = ((i810ContextPtr) sharedContextPrivate)->glCtx; else shareCtx = NULL; - imesa->glCtx = _mesa_create_context(mesaVis, shareCtx, (void*) imesa, GL_TRUE); + imesa->glCtx = _mesa_create_context(mesaVis, shareCtx, + &functions, (void*) imesa); if (!imesa->glCtx) { FREE(imesa); return GL_FALSE; @@ -274,14 +285,15 @@ i810CreateContext( const __GLcontextModes *mesaVis, _math_matrix_ctr( &imesa->ViewportMatrix ); driInitExtensions( ctx, card_extensions, GL_TRUE ); + /* XXX these should really go right after _mesa_init_driver_functions() */ i810InitStateFuncs( ctx ); - i810InitTextureFuncs( ctx ); i810InitTriFuncs( ctx ); i810InitSpanFuncs( ctx ); - i810InitIoctlFuncs( ctx ); i810InitVB( ctx ); i810InitState( ctx ); + driInitTextureObjects( ctx, &imesa->swapped, DRI_TEXMGR_DO_TEXTURE_2D); + #if DO_DEBUG I810_DEBUG = driParseDebugString( getenv( "I810_DEBUG" ), debug_control ); diff --git a/src/mesa/drivers/dri/i810/i810ioctl.c b/src/mesa/drivers/dri/i810/i810ioctl.c index d769d58d566..88a048b396b 100644 --- a/src/mesa/drivers/dri/i810/i810ioctl.c +++ b/src/mesa/drivers/dri/i810/i810ioctl.c @@ -502,9 +502,9 @@ static void i810Finish( GLcontext *ctx ) i810DmaFinish( imesa ); } -void i810InitIoctlFuncs( GLcontext *ctx ) +void i810InitIoctlFuncs( struct dd_function_table *functions ) { - ctx->Driver.Flush = i810Flush; - ctx->Driver.Clear = i810Clear; - ctx->Driver.Finish = i810Finish; + functions->Flush = i810Flush; + functions->Clear = i810Clear; + functions->Finish = i810Finish; } diff --git a/src/mesa/drivers/dri/i810/i810ioctl.h b/src/mesa/drivers/dri/i810/i810ioctl.h index e287b57b19a..61399ee7b72 100644 --- a/src/mesa/drivers/dri/i810/i810ioctl.h +++ b/src/mesa/drivers/dri/i810/i810ioctl.h @@ -14,7 +14,7 @@ void i810WaitAgeLocked( i810ContextPtr imesa, int age ); void i810WaitAge( i810ContextPtr imesa, int age ); void i810DmaFinish( i810ContextPtr imesa ); void i810RegetLockQuiescent( i810ContextPtr imesa ); -void i810InitIoctlFuncs( GLcontext *ctx ); +void i810InitIoctlFuncs( struct dd_function_table *functions ); void i810CopyBuffer( const __DRIdrawablePrivate *dpriv ); void i810PageFlip( const __DRIdrawablePrivate *dpriv ); int i810_check_copy(int fd); diff --git a/src/mesa/drivers/dri/i810/i810tex.c b/src/mesa/drivers/dri/i810/i810tex.c index bab5865e829..bf404e36f0a 100644 --- a/src/mesa/drivers/dri/i810/i810tex.c +++ b/src/mesa/drivers/dri/i810/i810tex.c @@ -160,13 +160,16 @@ static void i810SetTexFilter(i810ContextPtr imesa, } -static void i810SetTexBorderColor(i810TextureObjectPtr t, - GLubyte color[4]) +static void +i810SetTexBorderColor( i810TextureObjectPtr t, GLubyte color[4] ) { /* Need a fallback. */ } -static i810TextureObjectPtr i810AllocTexObj( GLcontext *ctx, struct gl_texture_object *texObj ) + + +static i810TextureObjectPtr +i810AllocTexObj( GLcontext *ctx, struct gl_texture_object *texObj ) { i810TextureObjectPtr t; i810ContextPtr imesa = I810_CONTEXT(ctx); @@ -220,8 +223,8 @@ static void i810TexParameter( GLcontext *ctx, GLenum target, { i810ContextPtr imesa = I810_CONTEXT(ctx); i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData; - if (!t) - return; + + assert(t); if ( target != GL_TEXTURE_2D ) return; @@ -338,6 +341,7 @@ static void i810TexImage1D( GLcontext *ctx, GLenum target, GLint level, struct gl_texture_image *texImage ) { i810TextureObjectPtr t = (i810TextureObjectPtr) texObj->DriverData; + assert(t); if (t) { i810SwapOutTexObj( imesa, t ); } @@ -367,6 +371,7 @@ static void i810TexImage2D( GLcontext *ctx, GLenum target, GLint level, struct gl_texture_image *texImage ) { driTextureObject *t = (driTextureObject *) texObj->DriverData; + assert(t); if (t) { I810_FIREVERTICES( I810_CONTEXT(ctx) ); driSwapOutTextureObject( t ); @@ -381,7 +386,6 @@ static void i810TexImage2D( GLcontext *ctx, GLenum target, GLint level, _mesa_store_teximage2d( ctx, target, level, internalFormat, width, height, border, format, type, pixels, packing, texObj, texImage ); - } static void i810TexSubImage2D( GLcontext *ctx, @@ -396,7 +400,7 @@ static void i810TexSubImage2D( GLcontext *ctx, struct gl_texture_image *texImage ) { driTextureObject *t = (driTextureObject *)texObj->DriverData; - + assert(t); if (t) { I810_FIREVERTICES( I810_CONTEXT(ctx) ); driSwapOutTextureObject( t ); @@ -404,22 +408,26 @@ static void i810TexSubImage2D( GLcontext *ctx, _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, height, format, type, pixels, packing, texObj, texImage); - } +#if 0 +/* not needed anymore */ static void i810BindTexture( GLcontext *ctx, GLenum target, struct gl_texture_object *tObj ) { - if (!tObj->DriverData) { + assert(t); + if (!tObj->DriverData) { i810AllocTexObj( ctx, tObj ); } } +#endif static void i810DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) { - driTextureObject * t = (driTextureObject *) tObj->DriverData; + driTextureObject * t = (driTextureObject *) tObj->DriverData; + assert(t); if (t) { i810ContextPtr imesa = I810_CONTEXT( ctx ); if (imesa) @@ -517,30 +525,37 @@ i810ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, return NULL; /* never get here */ } -void i810InitTextureFuncs( GLcontext *ctx ) +/** + * Allocate a new texture object. + * Called via ctx->Driver.NewTextureObject. + * Note: this function will be called during context creation to + * allocate the default texture objects. + */ +static struct gl_texture_object * +i810NewTextureObject( GLcontext *ctx, GLuint name, GLenum target ) { - i810ContextPtr imesa = I810_CONTEXT(ctx); - - ctx->Driver.TexEnv = i810TexEnv; - ctx->Driver.ChooseTextureFormat = i810ChooseTextureFormat; - ctx->Driver.TexImage1D = _mesa_store_teximage1d; - ctx->Driver.TexImage2D = i810TexImage2D; - ctx->Driver.TexImage3D = _mesa_store_teximage3d; - ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d; - ctx->Driver.TexSubImage2D = i810TexSubImage2D; - ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d; - ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d; - ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d; - ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d; - ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d; - ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d; - ctx->Driver.BindTexture = i810BindTexture; - ctx->Driver.DeleteTexture = i810DeleteTexture; - ctx->Driver.TexParameter = i810TexParameter; - ctx->Driver.UpdateTexturePalette = 0; - ctx->Driver.IsTextureResident = driIsTextureResident; - ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage; - - driInitTextureObjects( ctx, &imesa->swapped, DRI_TEXMGR_DO_TEXTURE_2D); + struct gl_texture_object *obj; + driTextureObject *t; + obj = _mesa_new_texture_object(ctx, name, target); + if (!obj) + return NULL; + t = (driTextureObject *) i810AllocTexObj( ctx, obj ); + if (!t) { + _mesa_delete_texture_object(ctx, obj); + return NULL; + } + return obj; +} +void i810InitTextureFuncs( struct dd_function_table *functions ) +{ + functions->ChooseTextureFormat = i810ChooseTextureFormat; + functions->TexImage2D = i810TexImage2D; + functions->TexSubImage2D = i810TexSubImage2D; + /*functions->BindTexture = i810BindTexture;*/ + functions->NewTextureObject = i810NewTextureObject; + functions->DeleteTexture = i810DeleteTexture; + functions->TexParameter = i810TexParameter; + functions->TexEnv = i810TexEnv; + functions->IsTextureResident = driIsTextureResident; } diff --git a/src/mesa/drivers/dri/i810/i810tex.h b/src/mesa/drivers/dri/i810/i810tex.h index f0b4b88128f..c6ab4c8e6d1 100644 --- a/src/mesa/drivers/dri/i810/i810tex.h +++ b/src/mesa/drivers/dri/i810/i810tex.h @@ -70,7 +70,7 @@ struct i810_texture_object_t { }; void i810UpdateTextureState( GLcontext *ctx ); -void i810InitTextureFuncs( GLcontext *ctx ); +void i810InitTextureFuncs( struct dd_function_table *functions ); void i810DestroyTexObj( i810ContextPtr imesa, i810TextureObjectPtr t ); int i810UploadTexImagesLocked( i810ContextPtr imesa, i810TextureObjectPtr t ); |