summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i830/i830_tex.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-01-20 02:49:27 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-01-20 02:49:27 +0000
commitd3fd7ba8af15bead2f770d68a893449adeb11397 (patch)
tree2c92f7cb35f2776d6c461378f93b556fc1ca080d /src/mesa/drivers/dri/i830/i830_tex.c
parent988a8862c8379c0312d40353ee4b35537dff59a1 (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/i830/i830_tex.c')
-rw-r--r--src/mesa/drivers/dri/i830/i830_tex.c67
1 files changed, 39 insertions, 28 deletions
diff --git a/src/mesa/drivers/dri/i830/i830_tex.c b/src/mesa/drivers/dri/i830/i830_tex.c
index 937f2cf393..6524cef41a 100644
--- a/src/mesa/drivers/dri/i830/i830_tex.c
+++ b/src/mesa/drivers/dri/i830/i830_tex.c
@@ -276,8 +276,8 @@ static void i830TexParameter( GLcontext *ctx, GLenum target,
i830ContextPtr imesa = I830_CONTEXT(ctx);
i830TextureObjectPtr t = (i830TextureObjectPtr) tObj->DriverData;
GLuint unit = ctx->Texture.CurrentUnit;
- if (!t)
- return;
+
+ assert(t);
if ( target != GL_TEXTURE_2D )
return;
@@ -376,6 +376,7 @@ static void i830TexImage2D( GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage )
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ assert(t);
if (t) {
I830_FIREVERTICES( I830_CONTEXT(ctx) );
driSwapOutTextureObject( t );
@@ -405,6 +406,7 @@ static void i830TexSubImage2D( GLcontext *ctx,
struct gl_texture_image *texImage )
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ assert(t);
if (t) {
I830_FIREVERTICES( I830_CONTEXT(ctx) );
driSwapOutTextureObject( t );
@@ -416,6 +418,8 @@ static void i830TexSubImage2D( GLcontext *ctx,
}
+#if 0
+/* no longer needed */
static void i830BindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
@@ -423,12 +427,13 @@ static void i830BindTexture( GLcontext *ctx, GLenum target,
i830AllocTexObj( tObj );
}
}
+#endif
static void i830DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
{
driTextureObject * t = (driTextureObject *) tObj->DriverData;
-
+ assert(t);
if ( t != NULL ) {
i830ContextPtr imesa = I830_CONTEXT( ctx );
@@ -551,31 +556,37 @@ i830ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
return NULL; /* never get here */
}
-void i830DDInitTextureFuncs( 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 *
+i830NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
- i830ContextPtr imesa = I830_CONTEXT(ctx);
+ struct gl_texture_object *obj;
+ driTextureObject *t;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ if (!obj)
+ return NULL;
+ t = (driTextureObject *) i830AllocTexObj( obj );
+ if (!t) {
+ _mesa_delete_texture_object(ctx, obj);
+ return NULL;
+ }
+ return obj;
+}
- ctx->Driver.TexEnv = i830TexEnv;
- ctx->Driver.ChooseTextureFormat = i830ChooseTextureFormat;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = i830TexImage2D;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = i830TexSubImage2D;
- 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 = i830BindTexture;
- ctx->Driver.DeleteTexture = i830DeleteTexture;
- ctx->Driver.TexParameter = i830TexParameter;
- ctx->Driver.UpdateTexturePalette = NULL;
- ctx->Driver.IsTextureResident = driIsTextureResident;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- driInitTextureObjects( ctx, & imesa->swapped,
- DRI_TEXMGR_DO_TEXTURE_2D
- | DRI_TEXMGR_DO_TEXTURE_RECT );
+void i830InitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->NewTextureObject = i830NewTextureObject;
+ functions->DeleteTexture = i830DeleteTexture;
+ functions->ChooseTextureFormat = i830ChooseTextureFormat;
+ functions->TexImage2D = i830TexImage2D;
+ functions->TexSubImage2D = i830TexSubImage2D;
+ /*functions->BindTexture = i830BindTexture;*/
+ functions->TexParameter = i830TexParameter;
+ functions->TexEnv = i830TexEnv;
+ functions->IsTextureResident = driIsTextureResident;
}