summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/mga
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
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')
-rw-r--r--src/mesa/drivers/dri/mga/Makefile.solo1
-rw-r--r--src/mesa/drivers/dri/mga/mga_xmesa.c22
-rw-r--r--src/mesa/drivers/dri/mga/mgadd.c12
-rw-r--r--src/mesa/drivers/dri/mga/mgadd.h2
-rw-r--r--src/mesa/drivers/dri/mga/mgaioctl.c14
-rw-r--r--src/mesa/drivers/dri/mga/mgaioctl.h2
-rw-r--r--src/mesa/drivers/dri/mga/mgatex.c91
-rw-r--r--src/mesa/drivers/dri/mga/mgatex.h2
8 files changed, 83 insertions, 63 deletions
diff --git a/src/mesa/drivers/dri/mga/Makefile.solo b/src/mesa/drivers/dri/mga/Makefile.solo
index 326e64a8fe9..6d078e68688 100644
--- a/src/mesa/drivers/dri/mga/Makefile.solo
+++ b/src/mesa/drivers/dri/mga/Makefile.solo
@@ -27,6 +27,7 @@ DRIVER_SOURCES = mgadd.c \
mgarender.c \
mgastate.c \
mgatris.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c
index fa8057e732f..6c26489d3cc 100644
--- a/src/mesa/drivers/dri/mga/mga_xmesa.c
+++ b/src/mesa/drivers/dri/mga/mga_xmesa.c
@@ -40,6 +40,8 @@
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
#include "mgadd.h"
#include "mgastate.h"
#include "mgatex.h"
@@ -352,6 +354,7 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private;
MGASAREAPrivPtr saPriv=(MGASAREAPrivPtr)(((char*)sPriv->pSAREA)+
mgaScreen->sarea_priv_offset);
+ struct dd_function_table functions;
if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
fprintf(stderr, "mgaCreateContext\n");
@@ -362,12 +365,21 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
return GL_FALSE;
}
+ /* Init default driver functions then plug in our Radeon-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ mgaInitDriverFuncs( &functions );
+ mgaInitTextureFuncs( &functions );
+ mgaInitIoctlFuncs( &functions );
+
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((mgaContextPtr) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- mmesa->glCtx = _mesa_create_context(mesaVis, shareCtx, (void *) mmesa, GL_TRUE);
+ mmesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+ &functions, (void *) mmesa);
if (!mmesa->glCtx) {
FREE(mmesa);
return GL_FALSE;
@@ -509,14 +521,16 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
driInitExtensions( ctx, g400_extensions, GL_FALSE );
}
+ /* XXX these should really go right after _mesa_init_driver_functions() */
mgaDDInitStateFuncs( ctx );
- mgaDDInitTextureFuncs( ctx );
mgaDDInitSpanFuncs( ctx );
- mgaDDInitDriverFuncs( ctx );
- mgaDDInitIoctlFuncs( ctx );
mgaDDInitPixelFuncs( ctx );
mgaDDInitTriFuncs( ctx );
+ driInitTextureObjects( ctx, & mmesa->swapped,
+ (DRI_TEXMGR_DO_TEXTURE_2D |
+ DRI_TEXMGR_DO_TEXTURE_RECT) );
+
mgaInitVB( ctx );
mgaInitState( mmesa );
diff --git a/src/mesa/drivers/dri/mga/mgadd.c b/src/mesa/drivers/dri/mga/mgadd.c
index d2f11d8d457..e8436f23846 100644
--- a/src/mesa/drivers/dri/mga/mgadd.c
+++ b/src/mesa/drivers/dri/mga/mgadd.c
@@ -48,7 +48,7 @@
***************************************/
-static const GLubyte *mgaDDGetString( GLcontext *ctx, GLenum name )
+static const GLubyte *mgaGetString( GLcontext *ctx, GLenum name )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
static char buffer[128];
@@ -73,7 +73,6 @@ static const GLubyte *mgaDDGetString( GLcontext *ctx, GLenum name )
}
-
static void mgaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
{
GET_CURRENT_CONTEXT(ctx);
@@ -89,9 +88,10 @@ static void mgaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
UNLOCK_HARDWARE( mmesa );
}
-void mgaDDInitDriverFuncs( GLcontext *ctx )
+
+void mgaInitDriverFuncs( struct dd_function_table *functions )
{
- ctx->Driver.GetBufferSize = mgaBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetString = mgaDDGetString;
+ functions->GetBufferSize = mgaBufferSize;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->GetString = mgaGetString;
}
diff --git a/src/mesa/drivers/dri/mga/mgadd.h b/src/mesa/drivers/dri/mga/mgadd.h
index 919fd742d61..f98bfdc8781 100644
--- a/src/mesa/drivers/dri/mga/mgadd.h
+++ b/src/mesa/drivers/dri/mga/mgadd.h
@@ -31,6 +31,6 @@
#include "context.h"
-void mgaDDInitDriverFuncs( GLcontext *ctx );
+extern void mgaInitDriverFuncs( struct dd_function_table *functions );
#endif
diff --git a/src/mesa/drivers/dri/mga/mgaioctl.c b/src/mesa/drivers/dri/mga/mgaioctl.c
index 08e9705a176..37047344747 100644
--- a/src/mesa/drivers/dri/mga/mgaioctl.c
+++ b/src/mesa/drivers/dri/mga/mgaioctl.c
@@ -157,7 +157,7 @@ drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa )
static void
-mgaDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
GLint cx, GLint cy, GLint cw, GLint ch )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
@@ -390,7 +390,7 @@ void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv )
/* This is overkill
*/
-void mgaDDFinish( GLcontext *ctx )
+void mgaFinish( GLcontext *ctx )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
@@ -600,7 +600,7 @@ drmBufPtr mgaGetBufferLocked( mgaContextPtr mmesa )
-void mgaDDFlush( GLcontext *ctx )
+void mgaFlush( GLcontext *ctx )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
@@ -670,9 +670,9 @@ int mgaFlushDMA( int fd, drmLockFlags flags )
}
}
-void mgaDDInitIoctlFuncs( GLcontext *ctx )
+void mgaInitIoctlFuncs( struct dd_function_table *functions )
{
- ctx->Driver.Clear = mgaDDClear;
- ctx->Driver.Flush = mgaDDFlush;
- ctx->Driver.Finish = mgaDDFinish;
+ functions->Clear = mgaClear;
+ functions->Flush = mgaFlush;
+ functions->Finish = mgaFinish;
}
diff --git a/src/mesa/drivers/dri/mga/mgaioctl.h b/src/mesa/drivers/dri/mga/mgaioctl.h
index 9e57d48cea7..19785ea593a 100644
--- a/src/mesa/drivers/dri/mga/mgaioctl.h
+++ b/src/mesa/drivers/dri/mga/mgaioctl.h
@@ -57,7 +57,7 @@ int mgaFlushDMA( int fd, drmLockFlags flags );
void mgaDDFlush( GLcontext *ctx );
void mgaDDFinish( GLcontext *ctx );
-void mgaDDInitIoctlFuncs( GLcontext *ctx );
+void mgaInitIoctlFuncs( struct dd_function_table *functions );
#define FLUSH_BATCH(mmesa) do { \
if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) \
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;
}
diff --git a/src/mesa/drivers/dri/mga/mgatex.h b/src/mesa/drivers/dri/mga/mgatex.h
index 94547e38862..fb7ffcff167 100644
--- a/src/mesa/drivers/dri/mga/mgatex.h
+++ b/src/mesa/drivers/dri/mga/mgatex.h
@@ -44,7 +44,7 @@ int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t );
void mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t );
-void mgaDDInitTextureFuncs( GLcontext *ctx );
+void mgaInitTextureFuncs( struct dd_function_table *functions );
GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit );