summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/mga/mgatex.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2004-01-20 02:49:27 +0000
committerBrian Paul <[email protected]>2004-01-20 02:49:27 +0000
commitd3fd7ba8af15bead2f770d68a893449adeb11397 (patch)
tree2c92f7cb35f2776d6c461378f93b556fc1ca080d /src/mesa/drivers/dri/mga/mgatex.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/mga/mgatex.c')
-rw-r--r--src/mesa/drivers/dri/mga/mgatex.c91
1 files changed, 48 insertions, 43 deletions
diff --git a/src/mesa/drivers/dri/mga/mgatex.c b/src/mesa/drivers/dri/mga/mgatex.c
index 8b8d472c525..b64335f3034 100644
--- a/src/mesa/drivers/dri/mga/mgatex.c
+++ b/src/mesa/drivers/dri/mga/mgatex.c
@@ -43,6 +43,7 @@
#include "texformat.h"
#include "texstore.h"
#include "teximage.h"
+#include "texobj.h"
#include "swrast/swrast.h"
@@ -336,7 +337,7 @@ mgaAllocTexObj( struct gl_texture_object *tObj )
}
-static void mgaDDTexEnv( GLcontext *ctx, GLenum target,
+static void mgaTexEnv( GLcontext *ctx, GLenum target,
GLenum pname, const GLfloat *param )
{
GLuint unit = ctx->Texture.CurrentUnit;
@@ -365,7 +366,7 @@ static void mgaTexImage2D( GLcontext *ctx, GLenum target, GLint level,
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
-
+ assert(t);
if ( t != NULL ) {
driSwapOutTextureObject( t );
}
@@ -398,8 +399,7 @@ static void mgaTexSubImage2D( GLcontext *ctx,
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
-
- assert( t != NULL ); /* this _should_ be true */
+ assert( t ); /* this _should_ be true */
if ( t != NULL ) {
driSwapOutTextureObject( t );
}
@@ -426,20 +426,18 @@ static void mgaTexSubImage2D( GLcontext *ctx,
*/
static void
-mgaDDTexParameter( GLcontext *ctx, GLenum target,
+mgaTexParameter( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj,
GLenum pname, const GLfloat *params )
{
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- mgaTextureObjectPtr t;
-
- t = (mgaTextureObjectPtr) tObj->DriverData;
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData;
/* If we don't have a hardware texture, it will be automatically
* created with current state before it is used, so we don't have
* to do anything now
*/
-
+ assert(t);
if ( (t == NULL) ||
(target != GL_TEXTURE_2D &&
target != GL_TEXTURE_RECTANGLE_NV) ) {
@@ -484,8 +482,10 @@ mgaDDTexParameter( GLcontext *ctx, GLenum target,
}
+#if 0
+/* no longer needed */
static void
-mgaDDBindTexture( GLcontext *ctx, GLenum target,
+mgaBindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
if ( target == GL_TEXTURE_2D ||
@@ -495,14 +495,16 @@ mgaDDBindTexture( GLcontext *ctx, GLenum target,
}
}
}
+#endif
static void
-mgaDDDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
driTextureObject * t = (driTextureObject *) tObj->DriverData;
+ assert(t);
if ( t ) {
if ( mmesa ) {
FLUSH_BATCH( mmesa );
@@ -513,38 +515,41 @@ mgaDDDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
}
-void
-mgaDDInitTextureFuncs( 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.
+ * Fixup MaxAnisotropy according to user preference.
+ */
+static struct gl_texture_object *
+mgaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ mgaContextPtr rmesa = MGA_CONTEXT(ctx);
+ struct gl_texture_object *obj;
+ driTextureObject *t;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ if (!obj)
+ return NULL;
+ t = (driTextureObject *) mgaAllocTexObj( obj );
+ if (!t) {
+ _mesa_delete_texture_object(ctx, obj);
+ return NULL;
+ }
+ return obj;
+}
- ctx->Driver.ChooseTextureFormat = mgaChooseTextureFormat;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = mgaTexImage2D;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = mgaTexSubImage2D;
- 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.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- ctx->Driver.BindTexture = mgaDDBindTexture;
- ctx->Driver.CreateTexture = NULL; /* FIXME: Is this used??? */
- ctx->Driver.DeleteTexture = mgaDDDeleteTexture;
- ctx->Driver.IsTextureResident = driIsTextureResident;
- ctx->Driver.PrioritizeTexture = NULL;
- ctx->Driver.ActiveTexture = NULL;
- ctx->Driver.UpdateTexturePalette = NULL;
-
- ctx->Driver.TexEnv = mgaDDTexEnv;
- ctx->Driver.TexParameter = mgaDDTexParameter;
-
- driInitTextureObjects( ctx, & mmesa->swapped,
- (DRI_TEXMGR_DO_TEXTURE_2D |
- DRI_TEXMGR_DO_TEXTURE_RECT) );
+void
+mgaInitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->ChooseTextureFormat = mgaChooseTextureFormat;
+ functions->TexImage2D = mgaTexImage2D;
+ functions->TexSubImage2D = mgaTexSubImage2D;
+ /*ctx->Driver.BindTexture = mgaBindTexture;*/
+ functions->NewTextureObject = mgaNewTextureObject;
+ functions->DeleteTexture = mgaDeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
+ functions->TexEnv = mgaTexEnv;
+ functions->TexParameter = mgaTexParameter;
}