aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/r128
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/r128
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/r128')
-rw-r--r--src/mesa/drivers/dri/r128/Makefile.solo1
-rw-r--r--src/mesa/drivers/dri/r128/r128_context.c21
-rw-r--r--src/mesa/drivers/dri/r128/r128_dd.c23
-rw-r--r--src/mesa/drivers/dri/r128/r128_dd.h2
-rw-r--r--src/mesa/drivers/dri/r128/r128_ioctl.c6
-rw-r--r--src/mesa/drivers/dri/r128/r128_ioctl.h2
-rw-r--r--src/mesa/drivers/dri/r128/r128_tex.c77
-rw-r--r--src/mesa/drivers/dri/r128/r128_tex.h2
8 files changed, 79 insertions, 55 deletions
diff --git a/src/mesa/drivers/dri/r128/Makefile.solo b/src/mesa/drivers/dri/r128/Makefile.solo
index 39b14c90262..cb40c7692e7 100644
--- a/src/mesa/drivers/dri/r128/Makefile.solo
+++ b/src/mesa/drivers/dri/r128/Makefile.solo
@@ -35,6 +35,7 @@ DRIVER_SOURCES = \
r128_span.c \
r128_texmem.c \
r128_vb.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c
index d1417c853b5..7bb324473f7 100644
--- a/src/mesa/drivers/dri/r128/r128_context.c
+++ b/src/mesa/drivers/dri/r128/r128_context.c
@@ -47,6 +47,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
#include "r128_context.h"
#include "r128_ioctl.h"
#include "r128_dd.h"
@@ -97,6 +99,7 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
{
GLcontext *ctx, *shareCtx;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ struct dd_function_table functions;
r128ContextPtr rmesa;
r128ScreenPtr r128scrn;
int i;
@@ -106,12 +109,21 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
if ( !rmesa )
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 );
+ r128InitDriverFuncs( &functions );
+ r128InitIoctlFuncs( &functions );
+ r128InitTextureFuncs( &functions );
+
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((r128ContextPtr) 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;
@@ -229,13 +241,14 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
r128InitVB( ctx );
r128InitTriFuncs( ctx );
- r128DDInitDriverFuncs( ctx );
- r128DDInitIoctlFuncs( ctx );
r128DDInitStateFuncs( ctx );
r128DDInitSpanFuncs( ctx );
- r128DDInitTextureFuncs( ctx );
r128DDInitState( rmesa );
+ driInitTextureObjects( ctx, & rmesa->swapped,
+ DRI_TEXMGR_DO_TEXTURE_1D
+ | DRI_TEXMGR_DO_TEXTURE_2D );
+
rmesa->vblank_flags = (rmesa->r128Screen->irq != 0)
? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
diff --git a/src/mesa/drivers/dri/r128/r128_dd.c b/src/mesa/drivers/dri/r128/r128_dd.c
index b64c26b4bdd..ce2e7f7d702 100644
--- a/src/mesa/drivers/dri/r128/r128_dd.c
+++ b/src/mesa/drivers/dri/r128/r128_dd.c
@@ -48,7 +48,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Return the width and height of the current color buffer.
*/
-static void r128DDGetBufferSize( GLframebuffer *buffer,
+static void r128GetBufferSize( GLframebuffer *buffer,
GLuint *width, GLuint *height )
{
GET_CURRENT_CONTEXT(ctx);
@@ -62,7 +62,7 @@ static void r128DDGetBufferSize( GLframebuffer *buffer,
/* Return various strings for glGetString().
*/
-static const GLubyte *r128DDGetString( GLcontext *ctx, GLenum name )
+static const GLubyte *r128GetString( GLcontext *ctx, GLenum name )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
static char buffer[128];
@@ -100,7 +100,7 @@ static const GLubyte *r128DDGetString( GLcontext *ctx, GLenum name )
* hardware. All commands that are normally sent to the ring are
* already considered `flushed'.
*/
-static void r128DDFlush( GLcontext *ctx )
+static void r128Flush( GLcontext *ctx )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
@@ -121,7 +121,7 @@ static void r128DDFlush( GLcontext *ctx )
/* Make sure all commands have been sent to the hardware and have
* completed processing.
*/
-static void r128DDFinish( GLcontext *ctx )
+static void r128Finish( GLcontext *ctx )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
@@ -130,19 +130,18 @@ static void r128DDFinish( GLcontext *ctx )
rmesa->c_drawWaits++;
#endif
- r128DDFlush( ctx );
+ r128Flush( ctx );
r128WaitForIdle( rmesa );
}
/* Initialize the driver's misc functions.
*/
-void r128DDInitDriverFuncs( GLcontext *ctx )
+void r128InitDriverFuncs( struct dd_function_table *functions )
{
- ctx->Driver.GetBufferSize = r128DDGetBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetString = r128DDGetString;
- ctx->Driver.Finish = r128DDFinish;
- ctx->Driver.Flush = r128DDFlush;
- ctx->Driver.Error = NULL;
+ functions->GetBufferSize = r128GetBufferSize;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->GetString = r128GetString;
+ functions->Finish = r128Finish;
+ functions->Flush = r128Flush;
}
diff --git a/src/mesa/drivers/dri/r128/r128_dd.h b/src/mesa/drivers/dri/r128/r128_dd.h
index b8fc7ad9bfd..1c8a5030500 100644
--- a/src/mesa/drivers/dri/r128/r128_dd.h
+++ b/src/mesa/drivers/dri/r128/r128_dd.h
@@ -38,7 +38,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef GLX_DIRECT_RENDERING
-extern void r128DDInitDriverFuncs( GLcontext *ctx );
+extern void r128InitDriverFuncs( struct dd_function_table *functions );
#endif
#endif
diff --git a/src/mesa/drivers/dri/r128/r128_ioctl.c b/src/mesa/drivers/dri/r128/r128_ioctl.c
index 7f9f7a923ea..6b2785eebe0 100644
--- a/src/mesa/drivers/dri/r128/r128_ioctl.c
+++ b/src/mesa/drivers/dri/r128/r128_ioctl.c
@@ -405,7 +405,7 @@ void r128PageFlip( const __DRIdrawablePrivate *dPriv )
* Buffer clear
*/
-static void r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+static void r128Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
GLint cx, GLint cy, GLint cw, GLint ch )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
@@ -810,7 +810,7 @@ void r128WaitForIdleLocked( r128ContextPtr rmesa )
}
}
-void r128DDInitIoctlFuncs( GLcontext *ctx )
+void r128InitIoctlFuncs( struct dd_function_table *functions )
{
- ctx->Driver.Clear = r128DDClear;
+ functions->Clear = r128Clear;
}
diff --git a/src/mesa/drivers/dri/r128/r128_ioctl.h b/src/mesa/drivers/dri/r128/r128_ioctl.h
index b0f6b363a5f..d10758feff7 100644
--- a/src/mesa/drivers/dri/r128/r128_ioctl.h
+++ b/src/mesa/drivers/dri/r128/r128_ioctl.h
@@ -94,7 +94,7 @@ void r128WaitForVBlank( r128ContextPtr rmesa );
extern void r128WaitForIdleLocked( r128ContextPtr rmesa );
-extern void r128DDInitIoctlFuncs( GLcontext *ctx );
+extern void r128InitIoctlFuncs( struct dd_function_table *functions );
/* ================================================================
diff --git a/src/mesa/drivers/dri/r128/r128_tex.c b/src/mesa/drivers/dri/r128/r128_tex.c
index b9874bd73f3..20e18dafeed 100644
--- a/src/mesa/drivers/dri/r128/r128_tex.c
+++ b/src/mesa/drivers/dri/r128/r128_tex.c
@@ -299,6 +299,7 @@ static void r128TexImage1D( GLcontext *ctx, GLenum target, GLint level,
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ assert(t);
if ( t ) {
driSwapOutTextureObject( t );
}
@@ -362,6 +363,7 @@ static void r128TexImage2D( GLcontext *ctx, GLenum target, GLint level,
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ assert(t);
if ( t ) {
driSwapOutTextureObject( (driTextureObject *) t );
}
@@ -414,7 +416,7 @@ static void r128TexSubImage2D( GLcontext *ctx,
}
-static void r128DDTexEnv( GLcontext *ctx, GLenum target,
+static void r128TexEnv( GLcontext *ctx, GLenum target,
GLenum pname, const GLfloat *param )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
@@ -502,9 +504,9 @@ static void r128DDTexEnv( GLcontext *ctx, GLenum target,
}
-static void r128DDTexParameter( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj,
- GLenum pname, const GLfloat *params )
+static void r128TexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData;
@@ -553,7 +555,9 @@ static void r128DDTexParameter( GLcontext *ctx, GLenum target,
}
}
-static void r128DDBindTexture( GLcontext *ctx, GLenum target,
+#if 00
+/* note needed */
+static void r128BindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
@@ -567,13 +571,15 @@ static void r128DDBindTexture( GLcontext *ctx, GLenum target,
}
}
}
+#endif
-static void r128DDDeleteTexture( GLcontext *ctx,
+static void r128DeleteTexture( GLcontext *ctx,
struct gl_texture_object *tObj )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
driTextureObject * t = (driTextureObject *) tObj->DriverData;
+ assert(t);
if ( t ) {
if ( t->bound && rmesa ) {
FLUSH_BATCH( rmesa );
@@ -585,34 +591,39 @@ static void r128DDDeleteTexture( GLcontext *ctx,
_mesa_delete_texture_object(ctx, tObj);
}
-void r128DDInitTextureFuncs( GLcontext *ctx )
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ */
+static struct gl_texture_object *
+r128NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ struct gl_texture_object *obj;
+ driTextureObject *t;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ if (!obj)
+ return NULL;
+ t = (driTextureObject *) r128AllocTexObj(obj);
+ if (!t) {
+ _mesa_delete_texture_object(ctx, obj);
+ return NULL;
+ }
+ return obj;
+}
-
- ctx->Driver.TexEnv = r128DDTexEnv;
- ctx->Driver.ChooseTextureFormat = r128ChooseTextureFormat;
- ctx->Driver.TexImage1D = r128TexImage1D;
- ctx->Driver.TexSubImage1D = r128TexSubImage1D;
- ctx->Driver.TexImage2D = r128TexImage2D;
- ctx->Driver.TexSubImage2D = r128TexSubImage2D;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- 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.TexParameter = r128DDTexParameter;
- ctx->Driver.BindTexture = r128DDBindTexture;
- ctx->Driver.DeleteTexture = r128DDDeleteTexture;
- ctx->Driver.UpdateTexturePalette = NULL;
- ctx->Driver.ActiveTexture = NULL;
- ctx->Driver.IsTextureResident = driIsTextureResident;
- ctx->Driver.PrioritizeTexture = NULL;
-
- driInitTextureObjects( ctx, & rmesa->swapped,
- DRI_TEXMGR_DO_TEXTURE_1D
- | DRI_TEXMGR_DO_TEXTURE_2D );
+void r128InitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->TexEnv = r128TexEnv;
+ functions->ChooseTextureFormat = r128ChooseTextureFormat;
+ functions->TexImage1D = r128TexImage1D;
+ functions->TexSubImage1D = r128TexSubImage1D;
+ functions->TexImage2D = r128TexImage2D;
+ functions->TexSubImage2D = r128TexSubImage2D;
+ functions->TexParameter = r128TexParameter;
+ /*functions->BindTexture = r128BindTexture;*/
+ functions->NewTextureObject = r128NewTextureObject;
+ functions->DeleteTexture = r128DeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
}
+
diff --git a/src/mesa/drivers/dri/r128/r128_tex.h b/src/mesa/drivers/dri/r128/r128_tex.h
index 2e3d954fbb8..00012c51045 100644
--- a/src/mesa/drivers/dri/r128/r128_tex.h
+++ b/src/mesa/drivers/dri/r128/r128_tex.h
@@ -44,7 +44,7 @@ extern void r128UploadTexImages( r128ContextPtr rmesa, r128TexObjPtr t );
extern void r128DestroyTexObj( r128ContextPtr rmesa, r128TexObjPtr t );
-extern void r128DDInitTextureFuncs( GLcontext *ctx );
+extern void r128InitTextureFuncs( struct dd_function_table *functions );
/* ================================================================