summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/gamma
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/gamma
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/gamma')
-rw-r--r--src/mesa/drivers/dri/gamma/Makefile.solo3
-rw-r--r--src/mesa/drivers/dri/gamma/gamma_context.c17
-rw-r--r--src/mesa/drivers/dri/gamma/gamma_context.h2
-rw-r--r--src/mesa/drivers/dri/gamma/gamma_tex.c110
4 files changed, 102 insertions, 30 deletions
diff --git a/src/mesa/drivers/dri/gamma/Makefile.solo b/src/mesa/drivers/dri/gamma/Makefile.solo
index 04b7b265644..70146e58cb1 100644
--- a/src/mesa/drivers/dri/gamma/Makefile.solo
+++ b/src/mesa/drivers/dri/gamma/Makefile.solo
@@ -1,4 +1,4 @@
-# $Id: Makefile.solo,v 1.1 2003/12/12 15:30:52 brianp Exp $
+# $Id: Makefile.solo,v 1.2 2004/01/20 02:49:27 brianp Exp $
# Mesa 3-D graphics library
# Version: 5.0
@@ -39,6 +39,7 @@ DRIVER_SOURCES = \
gamma_tris.c \
gamma_vb.c \
gamma_xmesa.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
diff --git a/src/mesa/drivers/dri/gamma/gamma_context.c b/src/mesa/drivers/dri/gamma/gamma_context.c
index df9bc5b54fc..ff3b3a47fe5 100644
--- a/src/mesa/drivers/dri/gamma/gamma_context.c
+++ b/src/mesa/drivers/dri/gamma/gamma_context.c
@@ -33,6 +33,8 @@
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
#include "context.h"
#include "simple_list.h"
#include "imports.h"
@@ -75,9 +77,17 @@ GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
gammaScreenPtr gammascrn;
GLINTSAREADRIPtr saPriv=(GLINTSAREADRIPtr)(((char*)sPriv->pSAREA)+
sizeof(XF86DRISAREARec));
+ struct dd_function_table functions;
gmesa = (gammaContextPtr) CALLOC( sizeof(*gmesa) );
- if ( !gmesa ) return GL_FALSE;
+ if (!gmesa)
+ return GL_FALSE;
+
+ /* Init default driver functions then plug in our gamma-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ gammaDDInitTextureFuncs( &functions );
/* Allocate the Mesa context */
if (sharedContextPrivate)
@@ -85,7 +95,8 @@ GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
else
shareCtx = NULL;
- gmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) gmesa, GL_TRUE);
+ gmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *) gmesa);
if (!gmesa->glCtx) {
FREE(gmesa);
return GL_FALSE;
@@ -152,10 +163,10 @@ GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
gammaInitVB( ctx );
gammaDDInitExtensions( ctx );
+ /* XXX these should really go right after _mesa_init_driver_functions() */
gammaDDInitDriverFuncs( ctx );
gammaDDInitStateFuncs( ctx );
gammaDDInitSpanFuncs( ctx );
- gammaDDInitTextureFuncs( ctx );
gammaDDInitTriFuncs( ctx );
gammaDDInitState( gmesa );
diff --git a/src/mesa/drivers/dri/gamma/gamma_context.h b/src/mesa/drivers/dri/gamma/gamma_context.h
index 5f183ff264c..e9699616441 100644
--- a/src/mesa/drivers/dri/gamma/gamma_context.h
+++ b/src/mesa/drivers/dri/gamma/gamma_context.h
@@ -191,7 +191,7 @@ void gammaDDInitSpanFuncs( GLcontext *ctx );
void gammaDDInitState( gammaContextPtr gmesa );
void gammaInitHW( gammaContextPtr gmesa );
void gammaDDInitStateFuncs( GLcontext *ctx );
-void gammaDDInitTextureFuncs( GLcontext *ctx );
+void gammaDDInitTextureFuncs( struct dd_function_table *table );
void gammaDDInitTriFuncs( GLcontext *ctx );
void gammaUpdateWindow( GLcontext *ctx );
diff --git a/src/mesa/drivers/dri/gamma/gamma_tex.c b/src/mesa/drivers/dri/gamma/gamma_tex.c
index e0bc301d9df..b2f1d996b97 100644
--- a/src/mesa/drivers/dri/gamma/gamma_tex.c
+++ b/src/mesa/drivers/dri/gamma/gamma_tex.c
@@ -299,7 +299,8 @@ static void gammaTexSubImage2D( GLcontext *ctx,
texImage);
}
-
+#if 0
+/* no longer needed */
static void gammaBindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
@@ -352,7 +353,7 @@ static void gammaBindTexture( GLcontext *ctx, GLenum target,
gammaSetTexBorderColor( gmesa, t, tObj->_BorderChan );
}
}
-
+#endif
static void gammaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
{
@@ -378,7 +379,79 @@ static GLboolean gammaIsTextureResident( GLcontext *ctx,
return t && t->MemBlock;
}
-static void gammaInitTextureObjects( 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 *
+gammaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+ struct gl_texture_object *obj;
+ gammaTextureObjectPtr t;
+
+ obj = _mesa_new_texture_object(ctx, name, target);
+ if (!obj)
+ return NULL;
+
+ t = CALLOC_STRUCT(gamma_texture_object_t);
+ if (!t) {
+ _mesa_delete_texture_object(ctx, obj);
+ return NULL;
+ }
+
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->globj = obj;
+ obj->DriverData = t;
+
+ t->TextureAddressMode = TextureAddressModeEnable | TAM_Operation_3D |
+ TAM_DY_Enable | TAM_LODEnable;
+ t->TextureReadMode = TextureReadModeEnable | TRM_PrimaryCacheEnable |
+ TRM_MipMapEnable | TRM_BorderClamp | TRM_Border;
+ t->TextureColorMode = TextureColorModeEnable;
+ t->TextureFilterMode = TextureFilterModeEnable;
+
+ if (target == GL_TEXTURE_2D) {
+ t->TextureAddressMode |= TAM_TexMapType_2D;
+ t->TextureReadMode |= TRM_TexMapType_2D;
+ }
+ else if (target == GL_TEXTURE_1D) {
+ t->TextureAddressMode |= TAM_TexMapType_1D;
+ t->TextureReadMode |= TRM_TexMapType_1D;
+ }
+
+ t->TextureColorMode = TextureColorModeEnable;
+
+ t->TextureFilterMode = TextureFilterModeEnable;
+
+#ifdef MESA_LITTLE_ENDIAN
+ t->TextureFormat = (TF_LittleEndian |
+#else
+ t->TextureFormat = (TF_BigEndian |
+#endif
+ TF_ColorOrder_RGB |
+ TF_OutputFmt_Texel);
+
+ t->dirty_images = ~0;
+
+ make_empty_list( t );
+
+ gammaSetTexWrapping( t, obj->WrapS, obj->WrapT );
+ gammaSetTexFilter( gmesa, t, obj->MinFilter, obj->MagFilter,
+ ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias);
+
+ gammaSetTexBorderColor( gmesa, t, obj->_BorderChan );
+
+ return obj;
+}
+
+
+#if 0
+/* no longer needed */
+void gammaInitTextureObjects( GLcontext *ctx )
{
struct gl_texture_object *texObj;
GLuint tmp = ctx->Texture.CurrentUnit;
@@ -403,29 +476,16 @@ static void gammaInitTextureObjects( GLcontext *ctx )
ctx->Texture.CurrentUnit = tmp;
}
+#endif
-void gammaDDInitTextureFuncs( GLcontext *ctx )
+void gammaDDInitTextureFuncs( struct dd_function_table *functions )
{
- ctx->Driver.TexEnv = gammaTexEnv;
- ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = gammaTexImage2D;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = gammaTexSubImage2D;
- 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 = gammaBindTexture;
- ctx->Driver.DeleteTexture = gammaDeleteTexture;
- ctx->Driver.TexParameter = gammaTexParameter;
- ctx->Driver.UpdateTexturePalette = 0;
- ctx->Driver.IsTextureResident = gammaIsTextureResident;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- gammaInitTextureObjects( ctx );
+ functions->TexEnv = gammaTexEnv;
+ functions->TexImage2D = gammaTexImage2D;
+ functions->TexSubImage2D = gammaTexSubImage2D;
+ /*functions->BindTexture = gammaBindTexture;*/
+ functions->DeleteTexture = gammaDeleteTexture;
+ functions->TexParameter = gammaTexParameter;
+ functions->IsTextureResident = gammaIsTextureResident;
}