summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/tdfx
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/tdfx
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/tdfx')
-rw-r--r--src/mesa/drivers/dri/tdfx/Makefile.solo1
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_context.c21
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_dd.c45
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_dd.h3
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_render.c14
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_render.h2
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_state.c34
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_tex.c169
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_tex.h57
9 files changed, 134 insertions, 212 deletions
diff --git a/src/mesa/drivers/dri/tdfx/Makefile.solo b/src/mesa/drivers/dri/tdfx/Makefile.solo
index 99a1b88209..6b3a4cd78d 100644
--- a/src/mesa/drivers/dri/tdfx/Makefile.solo
+++ b/src/mesa/drivers/dri/tdfx/Makefile.solo
@@ -24,6 +24,7 @@ DEFINES += \
# MINIGLX_SOURCES = server/tdfx_dri.c
DRIVER_SOURCES = tdfx_context.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_context.c b/src/mesa/drivers/dri/tdfx/tdfx_context.c
index ae79c55b39..973aa6cff2 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_context.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_context.c
@@ -40,13 +40,13 @@
#include "tdfx_dd.h"
#include "tdfx_state.h"
#include "tdfx_vb.h"
+#include "tdfx_tex.h"
#include "tdfx_tris.h"
#include "tdfx_render.h"
#include "tdfx_span.h"
#include "tdfx_texman.h"
#include "extensions.h"
-
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "array_cache/acache.h"
@@ -54,6 +54,8 @@
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
const char __driConfigOptions[] = { 0 };
const GLuint __driNConfigOptions = 0;
@@ -115,19 +117,29 @@ GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis,
tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private;
TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) ((char *) sPriv->pSAREA +
sizeof(XF86DRISAREARec));
+ struct dd_function_table functions;
/* Allocate tdfx context */
fxMesa = (tdfxContextPtr) CALLOC( sizeof(tdfxContextRec) );
if (!fxMesa)
return GL_FALSE;
+ /* Init default driver functions then plug in our tdfx-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions(&functions);
+ tdfxDDInitDriverFuncs(mesaVis, &functions);
+ tdfxInitTextureFuncs(&functions);
+ tdfxInitRenderFuncs(&functions);
+
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((tdfxContextPtr) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- fxMesa->glCtx = _mesa_create_context(mesaVis, shareCtx, (void *) fxMesa, GL_TRUE);
+ fxMesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+ &functions, (void *) fxMesa);
if (!fxMesa->glCtx) {
FREE(fxMesa);
return GL_FALSE;
@@ -246,10 +258,9 @@ GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis,
_swrast_allow_vertex_fog( ctx, GL_FALSE );
tdfxDDInitExtensions( ctx );
- tdfxDDInitDriverFuncs( ctx );
- tdfxDDInitStateFuncs( ctx );
- tdfxDDInitRenderFuncs( ctx );
+ /* XXX these should really go right after _mesa_init_driver_functions() */
tdfxDDInitSpanFuncs( ctx );
+ tdfxDDInitStateFuncs( ctx );
tdfxDDInitTriFuncs( ctx );
tdfxInitVB( ctx );
tdfxInitState( fxMesa );
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_dd.c b/src/mesa/drivers/dri/tdfx/tdfx_dd.c
index 79fc6d9e26..367b0d241e 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_dd.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_dd.c
@@ -243,47 +243,38 @@ static GLboolean tdfxDDGetIntegerv( GLcontext *ctx, GLenum pname,
#define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \
- ((vis.redBits == r) && \
- (vis.greenBits == g) && \
- (vis.blueBits == b) && \
- (vis.alphaBits == a))
+ ((vis->redBits == r) && \
+ (vis->greenBits == g) && \
+ (vis->blueBits == b) && \
+ (vis->alphaBits == a))
-void tdfxDDInitDriverFuncs( GLcontext *ctx )
+void tdfxDDInitDriverFuncs( const __GLcontextModes *visual,
+ struct dd_function_table *functions )
{
if ( MESA_VERBOSE & VERBOSE_DRIVER ) {
fprintf( stderr, "tdfx: %s()\n", __FUNCTION__ );
}
- ctx->Driver.GetString = tdfxDDGetString;
- ctx->Driver.GetBufferSize = tdfxDDGetBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.Error = NULL;
-
- /* Pixel path fallbacks.
- */
- ctx->Driver.Accum = _swrast_Accum;
- ctx->Driver.Bitmap = _swrast_Bitmap;
- ctx->Driver.CopyPixels = _swrast_CopyPixels;
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ functions->GetString = tdfxDDGetString;
+ functions->GetBufferSize = tdfxDDGetBufferSize;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
/* Accelerated paths
*/
- if ( VISUAL_EQUALS_RGBA(ctx->Visual, 8, 8, 8, 8) )
+ if ( VISUAL_EQUALS_RGBA(visual, 8, 8, 8, 8) )
{
- ctx->Driver.DrawPixels = tdfx_drawpixels_R8G8B8A8;
- ctx->Driver.ReadPixels = tdfx_readpixels_R8G8B8A8;
+ functions->DrawPixels = tdfx_drawpixels_R8G8B8A8;
+ functions->ReadPixels = tdfx_readpixels_R8G8B8A8;
}
- else if ( VISUAL_EQUALS_RGBA(ctx->Visual, 5, 6, 5, 0) )
+ else if ( VISUAL_EQUALS_RGBA(visual, 5, 6, 5, 0) )
{
- ctx->Driver.ReadPixels = tdfx_readpixels_R5G6B5;
+ functions->ReadPixels = tdfx_readpixels_R5G6B5;
}
- ctx->Driver.GetBooleanv = tdfxDDGetBooleanv;
- ctx->Driver.GetDoublev = tdfxDDGetDoublev;
- ctx->Driver.GetFloatv = tdfxDDGetFloatv;
- ctx->Driver.GetIntegerv = tdfxDDGetIntegerv;
- ctx->Driver.GetPointerv = NULL;
+ functions->GetBooleanv = tdfxDDGetBooleanv;
+ functions->GetDoublev = tdfxDDGetDoublev;
+ functions->GetFloatv = tdfxDDGetFloatv;
+ functions->GetIntegerv = tdfxDDGetIntegerv;
}
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_dd.h b/src/mesa/drivers/dri/tdfx/tdfx_dd.h
index dbb585e3b2..e49d8e2a33 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_dd.h
+++ b/src/mesa/drivers/dri/tdfx/tdfx_dd.h
@@ -41,7 +41,8 @@
#include "context.h"
-extern void tdfxDDInitDriverFuncs( GLcontext *ctx );
+extern void tdfxDDInitDriverFuncs( const __GLcontextModes *visual,
+ struct dd_function_table *functions );
#endif
#endif
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_render.c b/src/mesa/drivers/dri/tdfx/tdfx_render.c
index 1cb3eeddbc..84d919591b 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_render.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_render.c
@@ -43,7 +43,7 @@
/* Clear the color and/or depth buffers.
*/
-static void tdfxDDClear( GLcontext *ctx,
+static void tdfxClear( GLcontext *ctx,
GLbitfield mask, GLboolean all,
GLint x, GLint y, GLint width, GLint height )
{
@@ -315,7 +315,7 @@ static void tdfxDDClear( GLcontext *ctx,
-static void tdfxDDFinish( GLcontext *ctx )
+static void tdfxFinish( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
@@ -326,7 +326,7 @@ static void tdfxDDFinish( GLcontext *ctx )
UNLOCK_HARDWARE( fxMesa );
}
-static void tdfxDDFlush( GLcontext *ctx )
+static void tdfxFlush( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
@@ -794,9 +794,9 @@ void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa )
-void tdfxDDInitRenderFuncs( GLcontext *ctx )
+void tdfxInitRenderFuncs( struct dd_function_table *functions )
{
- ctx->Driver.Clear = tdfxDDClear;
- ctx->Driver.Finish = tdfxDDFinish;
- ctx->Driver.Flush = tdfxDDFlush;
+ functions->Clear = tdfxClear;
+ functions->Finish = tdfxFinish;
+ functions->Flush = tdfxFlush;
}
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_render.h b/src/mesa/drivers/dri/tdfx/tdfx_render.h
index 146120bc05..395e09f7e9 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_render.h
+++ b/src/mesa/drivers/dri/tdfx/tdfx_render.h
@@ -41,7 +41,7 @@
#include "tdfx_context.h"
-extern void tdfxDDInitRenderFuncs( GLcontext *ctx );
+extern void tdfxInitRenderFuncs( struct dd_function_table *functions );
extern void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa );
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_state.c b/src/mesa/drivers/dri/tdfx/tdfx_state.c
index 5372558cdf..53e331f69b 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_state.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_state.c
@@ -1388,12 +1388,10 @@ void tdfxDDInitStateFuncs( GLcontext *ctx )
/* State notification callbacks:
*/
- ctx->Driver.ClearIndex = NULL;
ctx->Driver.ClearColor = tdfxDDClearColor;
ctx->Driver.DrawBuffer = tdfxDDDrawBuffer;
ctx->Driver.ReadBuffer = tdfxDDReadBuffer;
- ctx->Driver.IndexMask = NULL;
ctx->Driver.ColorMask = tdfxDDColorMask;
ctx->Driver.AlphaFunc = tdfxDDAlphaFunc;
@@ -1401,7 +1399,6 @@ void tdfxDDInitStateFuncs( GLcontext *ctx )
ctx->Driver.BlendFunc = tdfxDDBlendFunc;
ctx->Driver.BlendFuncSeparate = tdfxDDBlendFuncSeparate;
ctx->Driver.ClearDepth = tdfxDDClearDepth;
- ctx->Driver.ClearStencil = NULL;
ctx->Driver.CullFace = tdfxDDCullFace;
ctx->Driver.FrontFace = tdfxDDFrontFace;
ctx->Driver.DepthFunc = tdfxDDDepthFunc;
@@ -1409,39 +1406,13 @@ void tdfxDDInitStateFuncs( GLcontext *ctx )
ctx->Driver.DepthRange = tdfxDDDepthRange;
ctx->Driver.Enable = tdfxDDEnable;
ctx->Driver.Fogfv = tdfxDDFogfv;
- ctx->Driver.Hint = NULL;
- ctx->Driver.Lightfv = NULL;
ctx->Driver.LightModelfv = tdfxDDLightModelfv;
- ctx->Driver.LineStipple = NULL;
ctx->Driver.LineWidth = tdfxDDLineWidth;
ctx->Driver.PolygonStipple = tdfxDDPolygonStipple;
ctx->Driver.RenderMode = tdfxDDRenderMode;
ctx->Driver.Scissor = tdfxDDScissor;
ctx->Driver.ShadeModel = tdfxDDShadeModel;
- ctx->Driver.BindTexture = tdfxDDBindTexture;
- ctx->Driver.DeleteTexture = tdfxDDDeleteTexture;
- ctx->Driver.TexEnv = tdfxDDTexEnv;
- ctx->Driver.TexParameter = tdfxDDTexParameter;
- ctx->Driver.ChooseTextureFormat = tdfxDDChooseTextureFormat;
- ctx->Driver.TexImage2D = tdfxDDTexImage2D;
- ctx->Driver.TexSubImage2D = tdfxDDTexSubImage2D;
- /*
- ctx->Driver.TexImage2D = _mesa_store_teximage2d;
- ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
- */
-
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- 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.GetTexImage = tdfxDDGetTexImage; */
ctx->Driver.UpdateTexturePalette = tdfxDDTexturePalette;
@@ -1449,15 +1420,10 @@ void tdfxDDInitStateFuncs( GLcontext *ctx )
ctx->Driver.StencilFunc = tdfxDDStencilFunc;
ctx->Driver.StencilMask = tdfxDDStencilMask;
ctx->Driver.StencilOp = tdfxDDStencilOp;
- } else {
- ctx->Driver.StencilFunc = NULL;
- ctx->Driver.StencilMask = NULL;
- ctx->Driver.StencilOp = NULL;
}
ctx->Driver.Viewport = tdfxDDViewport;
-
/* Swrast hooks for imaging extensions:
*/
ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tex.c b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
index d18812faaa..d25a03da9c 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_tex.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
@@ -200,42 +200,11 @@ static void RevalidateTexture(GLcontext *ctx, struct gl_texture_object *tObj)
}
-static tdfxTexInfo *
-fxAllocTexObjData(tdfxContextPtr fxMesa)
-{
- tdfxTexInfo *ti;
-
- if (!(ti = CALLOC(sizeof(tdfxTexInfo)))) {
- _mesa_problem(NULL, "tdfx driver: out of memory");
- return NULL;
- }
-
- ti->isInTM = GL_FALSE;
-
- ti->whichTMU = TDFX_TMU_NONE;
-
- ti->tm[TDFX_TMU0] = NULL;
- ti->tm[TDFX_TMU1] = NULL;
-
- ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
- ti->magFilt = GR_TEXTUREFILTER_BILINEAR;
-
- ti->sClamp = GR_TEXTURECLAMP_WRAP;
- ti->tClamp = GR_TEXTURECLAMP_WRAP;
-
- ti->mmMode = GR_MIPMAP_NEAREST;
- ti->LODblend = FXFALSE;
-
- return ti;
-}
-
-
/*
* Called via glBindTexture.
*/
-
-void
-tdfxDDBindTexture(GLcontext * ctx, GLenum target,
+static void
+tdfxBindTexture(GLcontext * ctx, GLenum target,
struct gl_texture_object *tObj)
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
@@ -249,11 +218,8 @@ tdfxDDBindTexture(GLcontext * ctx, GLenum target,
if (target != GL_TEXTURE_2D)
return;
- if (!tObj->DriverData) {
- tObj->DriverData = fxAllocTexObjData(fxMesa);
- }
-
ti = TDFX_TEXTURE_DATA(tObj);
+ assert(ti);
ti->lastTimeUsed = fxMesa->texBindNumber++;
fxMesa->new_state |= TDFX_NEW_TEXTURE;
@@ -263,8 +229,8 @@ tdfxDDBindTexture(GLcontext * ctx, GLenum target,
/*
* Called via glTexEnv.
*/
-void
-tdfxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
+static void
+tdfxTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
const GLfloat * param)
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
@@ -289,8 +255,8 @@ tdfxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
/*
* Called via glTexParameter.
*/
-void
-tdfxDDTexParameter(GLcontext * ctx, GLenum target,
+static void
+tdfxTexParameter(GLcontext * ctx, GLenum target,
struct gl_texture_object *tObj,
GLenum pname, const GLfloat * params)
{
@@ -306,10 +272,8 @@ tdfxDDTexParameter(GLcontext * ctx, GLenum target,
if (target != GL_TEXTURE_2D)
return;
- if (!tObj->DriverData)
- tObj->DriverData = fxAllocTexObjData(fxMesa);
-
ti = TDFX_TEXTURE_DATA(tObj);
+ assert(ti);
switch (pname) {
case GL_TEXTURE_MIN_FILTER:
@@ -444,7 +408,7 @@ tdfxDDTexParameter(GLcontext * ctx, GLenum target,
* Here, we delete the Glide data associated with the texture.
*/
void
-tdfxDDDeleteTexture(GLcontext * ctx, struct gl_texture_object *tObj)
+tdfxDeleteTexture(GLcontext * ctx, struct gl_texture_object *tObj)
{
if (ctx && ctx->DriverCtx) {
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
@@ -460,7 +424,7 @@ tdfxDDDeleteTexture(GLcontext * ctx, struct gl_texture_object *tObj)
* Return true if texture is resident, false otherwise.
*/
GLboolean
-tdfxDDIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj)
+tdfxIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj)
{
tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
return (GLboolean) (ti && ti->isInTM);
@@ -538,7 +502,7 @@ convertPalette(FxU32 data[256], const struct gl_color_table *table)
void
-tdfxDDTexturePalette(GLcontext * ctx, struct gl_texture_object *tObj)
+tdfxTexturePalette(GLcontext * ctx, struct gl_texture_object *tObj)
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
@@ -550,9 +514,8 @@ tdfxDDTexturePalette(GLcontext * ctx, struct gl_texture_object *tObj)
if (!tObj->Palette.Table)
return;
- if (!tObj->DriverData)
- tObj->DriverData = fxAllocTexObjData(fxMesa);
ti = TDFX_TEXTURE_DATA(tObj);
+ assert(ti);
convertPalette(ti->palette.data, &tObj->Palette);
/*tdfxTexInvalidate(ctx, tObj);*/
}
@@ -587,8 +550,8 @@ fxTexusError(const char *string, FxBool fatal)
#endif
-const struct gl_texture_format *
-tdfxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+static const struct gl_texture_format *
+tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
GLenum srcFormat, GLenum srcType )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
@@ -658,7 +621,7 @@ tdfxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_COLOR_INDEX16_EXT:
return &_mesa_texformat_ci8;
default:
- _mesa_problem(ctx, "unexpected format in tdfxDDChooseTextureFormat");
+ _mesa_problem(ctx, "unexpected format in tdfxChooseTextureFormat");
return NULL;
}
}
@@ -897,8 +860,8 @@ fxFetchFunction(GLint mesaFormat)
}
-void
-tdfxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
+static void
+tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
GLint internalFormat, GLint width, GLint height, GLint border,
GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *packing,
@@ -917,14 +880,7 @@ tdfxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
*/
ti = TDFX_TEXTURE_DATA(texObj);
- if (!ti) {
- texObj->DriverData = fxAllocTexObjData(fxMesa);
- if (!texObj->DriverData) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
- return;
- }
- ti = TDFX_TEXTURE_DATA(texObj);
- }
+ assert(ti);
mml = TDFX_TEXIMAGE_DATA(texImage);
if (!mml) {
@@ -1015,8 +971,8 @@ tdfxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
}
-void
-tdfxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
+static void
+tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
@@ -1030,11 +986,6 @@ tdfxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
tdfxMipMapLevel *mml;
GLint texelBytes;
- if (!texObj->DriverData) {
- _mesa_problem(ctx, "problem in fxDDTexSubImage2D");
- return;
- }
-
ti = TDFX_TEXTURE_DATA(texObj);
assert(ti);
mml = TDFX_TEXIMAGE_DATA(texImage);
@@ -1112,7 +1063,7 @@ tdfxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
#if 0000
GLboolean
-tdfxDDCompressedTexImage2D( GLcontext *ctx, GLenum target,
+tdfxCompressedTexImage2D( GLcontext *ctx, GLenum target,
GLint level, GLsizei imageSize,
const GLvoid *data,
struct gl_texture_object *texObj,
@@ -1132,10 +1083,8 @@ tdfxDDCompressedTexImage2D( GLcontext *ctx, GLenum target,
if (target != GL_TEXTURE_2D || texImage->Border > 0)
return GL_FALSE;
- if (!texObj->DriverData)
- texObj->DriverData = fxAllocTexObjData(fxMesa);
-
ti = TDFX_TEXTURE_DATA(texObj);
+ assert(ti);
mml = &ti->mipmapLevel[level];
isCompressedFormat = tdfxDDIsCompressedGlideFormatMacro(texImage->IntFormat);
@@ -1207,7 +1156,7 @@ tdfxDDCompressedTexImage2D( GLcontext *ctx, GLenum target,
}
GLboolean
-tdfxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
+tdfxCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
GLint level, GLint xoffset,
GLint yoffset, GLsizei width,
GLint height, GLenum format,
@@ -1265,7 +1214,7 @@ PrintTexture(int w, int h, int c, const GLubyte * data)
GLboolean
-tdfxDDTestProxyTexImage(GLcontext *ctx, GLenum target,
+tdfxTestProxyTexImage(GLcontext *ctx, GLenum target,
GLint level, GLint internalFormat,
GLenum format, GLenum type,
GLint width, GLint height,
@@ -1285,9 +1234,8 @@ tdfxDDTestProxyTexImage(GLcontext *ctx, GLenum target,
int memNeeded;
tObj = ctx->Texture.Proxy2D;
- if (!tObj->DriverData)
- tObj->DriverData = fxAllocTexObjData(fxMesa);
ti = TDFX_TEXTURE_DATA(tObj);
+ assert(ti);
/* assign the parameters to test against */
tObj->Image[level]->Width = width;
@@ -1349,7 +1297,7 @@ tdfxDDTestProxyTexImage(GLcontext *ctx, GLenum target,
* copy out the compressed data.
*/
void
-tdfxDDGetCompressedTexImage( GLcontext *ctx, GLenum target,
+tdfxGetCompressedTexImage( GLcontext *ctx, GLenum target,
GLint lod, void *image,
const struct gl_texture_object *texObj,
struct gl_texture_image *texImage )
@@ -1360,10 +1308,8 @@ tdfxDDGetCompressedTexImage( GLcontext *ctx, GLenum target,
if (target != GL_TEXTURE_2D)
return;
- if (!texObj->DriverData)
- return;
-
ti = TDFX_TEXTURE_DATA(texObj);
+ assert(ti);
mml = &ti->mipmapLevel[lod];
if (mml->data) {
MEMCPY(image, mml->data, mml->dataSize);
@@ -1376,7 +1322,7 @@ tdfxDDGetCompressedTexImage( GLcontext *ctx, GLenum target,
* texture format.
*/
GLint
-tdfxDDSpecificCompressedTexFormat(GLcontext *ctx,
+tdfxSpecificCompressedTexFormat(GLcontext *ctx,
GLint internalFormat,
GLint numDimensions)
{
@@ -1410,7 +1356,7 @@ tdfxDDSpecificCompressedTexFormat(GLcontext *ctx,
* texture format.
*/
GLint
-tdfxDDBaseCompressedTexFormat(GLcontext *ctx,
+tdfxBaseCompressedTexFormat(GLcontext *ctx,
GLint internalFormat)
{
switch (internalFormat) {
@@ -1474,3 +1420,60 @@ tdfxDDCompressedImageSize(GLcontext *ctx,
}
return 0;
}
+
+
+
+/**
+ * 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 *
+tdfxNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ tdfxTexInfo *ti;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ if (!obj)
+ return NULL;
+
+ if (!(ti = CALLOC(sizeof(tdfxTexInfo)))) {
+ _mesa_delete_texture_object(ctx, obj);
+ return NULL;
+ }
+
+ ti->isInTM = GL_FALSE;
+
+ ti->whichTMU = TDFX_TMU_NONE;
+
+ ti->tm[TDFX_TMU0] = NULL;
+ ti->tm[TDFX_TMU1] = NULL;
+
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->magFilt = GR_TEXTUREFILTER_BILINEAR;
+
+ ti->sClamp = GR_TEXTURECLAMP_WRAP;
+ ti->tClamp = GR_TEXTURECLAMP_WRAP;
+
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXFALSE;
+
+ obj->DriverData = ti;
+
+ return obj;
+}
+
+
+void tdfxInitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->BindTexture = tdfxBindTexture;
+ functions->NewTextureObject = tdfxNewTextureObject;
+ functions->DeleteTexture = tdfxDeleteTexture;
+ functions->TexEnv = tdfxTexEnv;
+ functions->TexParameter = tdfxTexParameter;
+ functions->ChooseTextureFormat = tdfxChooseTextureFormat;
+ functions->TexImage2D = tdfxTexImage2D;
+ functions->TexSubImage2D = tdfxTexSubImage2D;
+}
+
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tex.h b/src/mesa/drivers/dri/tdfx/tdfx_tex.h
index 5fc7c740bf..29872e7647 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_tex.h
+++ b/src/mesa/drivers/dri/tdfx/tdfx_tex.h
@@ -53,9 +53,6 @@
extern void
tdfxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj);
-extern void
-tdfxDDBindTexture(GLcontext * ctx, GLenum target,
- struct gl_texture_object *tObj);
extern void
tdfxDDDeleteTexture(GLcontext * ctx, struct gl_texture_object *tObj);
@@ -71,57 +68,6 @@ extern void
fxDDTexUseGlobalPalette(GLcontext * ctx, GLboolean state);
#endif
-extern void
-tdfxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
- const GLfloat * param);
-
-extern void
-tdfxDDTexParameter(GLcontext * ctx, GLenum target,
- struct gl_texture_object *tObj,
- GLenum pname, const GLfloat * params);
-
-extern const struct gl_texture_format *
-tdfxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
- GLenum srcFormat, GLenum srcType );
-
-extern void
-tdfxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
- GLint internalFormat, GLint width, GLint height,
- GLint border,
- GLenum format, GLenum type, const GLvoid * pixels,
- const struct gl_pixelstore_attrib * packing,
- struct gl_texture_object * texObj,
- struct gl_texture_image * texImage);
-
-extern void
-tdfxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
-
-#if 000
-extern GLboolean
-tdfxDDCompressedTexImage2D( GLcontext *ctx, GLenum target,
- GLint level, GLsizei imageSize,
- const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage,
- GLboolean *retainInternalCopy);
-
-extern GLboolean
-tdfxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
- GLint level, GLint xoffset,
- GLint yoffset, GLsizei width,
- GLint height, GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
-#endif
-
extern GLboolean
tdfxDDTestProxyTexImage(GLcontext *ctx, GLenum target,
GLint level, GLint internalFormat,
@@ -162,4 +108,7 @@ tdfxDDCompressedImageSize(GLcontext *ctx,
GLuint depth);
+extern void
+tdfxInitTextureFuncs( struct dd_function_table *functions );
+
#endif