diff options
author | Brian Paul <[email protected]> | 2004-01-20 02:49:27 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2004-01-20 02:49:27 +0000 |
commit | d3fd7ba8af15bead2f770d68a893449adeb11397 (patch) | |
tree | 2c92f7cb35f2776d6c461378f93b556fc1ca080d /src/mesa/drivers/glide/fxddtex.c | |
parent | 988a8862c8379c0312d40353ee4b35537dff59a1 (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/glide/fxddtex.c')
-rw-r--r-- | src/mesa/drivers/glide/fxddtex.c | 128 |
1 files changed, 57 insertions, 71 deletions
diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c index eaca8401b8b..9081f470dd6 100644 --- a/src/mesa/drivers/glide/fxddtex.c +++ b/src/mesa/drivers/glide/fxddtex.c @@ -90,9 +90,8 @@ static void fxTexInvalidate(GLcontext * ctx, struct gl_texture_object *tObj) { fxMesaContext fxMesa = FX_CONTEXT(ctx); - tfxTexInfo *ti; - - ti = fxTMGetTexInfo(tObj); + tfxTexInfo *ti = fxTMGetTexInfo(tObj); + assert(ti); if (ti->isInTM) fxTMMoveOutTM(fxMesa, tObj); /* TO DO: SLOW but easy to write */ @@ -100,37 +99,6 @@ fxTexInvalidate(GLcontext * ctx, struct gl_texture_object *tObj) fxMesa->new_state |= FX_NEW_TEXTURING; } -static tfxTexInfo * -fxAllocTexObjData(fxMesaContext fxMesa) -{ - tfxTexInfo *ti; - - if (!(ti = CALLOC(sizeof(tfxTexInfo)))) { - fprintf(stderr, "fxAllocTexObjData: ERROR: out of memory !\n"); - fxCloseHardware(); - exit(-1); - } - - ti->validated = GL_FALSE; - ti->isInTM = GL_FALSE; - - ti->whichTMU = FX_TMU_NONE; - - ti->tm[FX_TMU0] = NULL; - ti->tm[FX_TMU1] = NULL; - - ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED; - ti->maxFilt = GR_TEXTUREFILTER_BILINEAR; - - ti->sClamp = GR_TEXTURECLAMP_WRAP; - ti->tClamp = GR_TEXTURECLAMP_WRAP; - - ti->mmMode = GR_MIPMAP_NEAREST; - ti->LODblend = FXFALSE; - - return ti; -} - void fxDDTexBind(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj) { @@ -144,11 +112,8 @@ fxDDTexBind(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj) if (target != GL_TEXTURE_2D) return; - if (!tObj->DriverData) { - tObj->DriverData = fxAllocTexObjData(fxMesa); - } - ti = fxTMGetTexInfo(tObj); + assert(ti); fxMesa->texBindNumber++; ti->lastTimeUsed = fxMesa->texBindNumber; @@ -200,13 +165,10 @@ fxDDTexParam(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj, if (target != GL_TEXTURE_2D) return; - if (!tObj->DriverData) - tObj->DriverData = fxAllocTexObjData(fxMesa); - ti = fxTMGetTexInfo(tObj); + assert(ti); switch (pname) { - case GL_TEXTURE_MIN_FILTER: switch (param) { case GL_NEAREST: @@ -359,8 +321,7 @@ fxDDTexDel(GLcontext * ctx, struct gl_texture_object *tObj) fprintf(stderr, "fxDDTexDel(%d, %p)\n", tObj->Name, (void *) ti); } - if (!ti) - return; + assert(ti); fxTMFreeTexture(fxMesa, tObj); @@ -371,14 +332,60 @@ fxDDTexDel(GLcontext * ctx, struct gl_texture_object *tObj) _mesa_delete_texture_object(ctx, tObj); } + +/** + * 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. + */ +struct gl_texture_object * +fxDDNewTextureObject( GLcontext *ctx, GLuint name, GLenum target ) +{ + struct gl_texture_object *obj; + fxTexInfo *ti; + + obj = _mesa_new_texture_object(ctx, name, target); + if (!obj) + return NULL; + + ti = CALLOC(sizeof(tfxTexInfo)); + if (!ti) { + _mesa_delete_texture_object(ctx, obj); + return NULL; + } + + ti->validated = GL_FALSE; + ti->isInTM = GL_FALSE; + + ti->whichTMU = FX_TMU_NONE; + + ti->tm[FX_TMU0] = NULL; + ti->tm[FX_TMU1] = NULL; + + ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED; + ti->maxFilt = 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; +} + + /* * Return true if texture is resident, false otherwise. */ GLboolean fxDDIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj) { - tfxTexInfo *ti = fxTMGetTexInfo(tObj); - return (ti && ti->isInTM); + tfxTexInfo *ti = fxTMGetTexInfo(tObj); + return (ti && ti->isInTM); } @@ -464,9 +471,8 @@ fxDDTexPalette(GLcontext * ctx, struct gl_texture_object *tObj) fprintf(stderr, "fxDDTexPalette(%d, %x)\n", tObj->Name, (GLuint) tObj->DriverData); } - if (!tObj->DriverData) - tObj->DriverData = fxAllocTexObjData(fxMesa); ti = fxTMGetTexInfo(tObj); + assert(ti); ti->paltype = convertPalette(fxMesa, ti->palette.data, &tObj->Palette); fxTexInvalidate(ctx, tObj); } @@ -501,10 +507,7 @@ fxDDTexUseGlbPalette(GLcontext * ctx, GLboolean state) if ((ctx->Texture.Unit[0]._Current == ctx->Texture.Unit[0].Current2D) && (ctx->Texture.Unit[0]._Current != NULL)) { struct gl_texture_object *tObj = ctx->Texture.Unit[0]._Current; - - if (!tObj->DriverData) - tObj->DriverData = fxAllocTexObjData(fxMesa); - + assert(tObj->DriverData); fxTexInvalidate(ctx, tObj); } } @@ -1218,14 +1221,8 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level, return; } - if (!texObj->DriverData) { - texObj->DriverData = fxAllocTexObjData(fxMesa); - if (!texObj->DriverData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - } ti = fxTMGetTexInfo(texObj); + assert(ti); if (!texImage->DriverData) { texImage->DriverData = CALLOC(sizeof(tfxMipMapLevel)); @@ -1423,11 +1420,6 @@ fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level, fprintf(stderr, "fxDDTexSubImage2D: id=%d\n", texObj->Name); } - if (!texObj->DriverData) { - _mesa_problem(ctx, "problem in fxDDTexSubImage2D"); - return; - } - ti = fxTMGetTexInfo(texObj); assert(ti); mml = FX_MIPMAP_DATA(texImage); @@ -1520,14 +1512,8 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target, return; } - if (!texObj->DriverData) { - texObj->DriverData = fxAllocTexObjData(fxMesa); - if (!texObj->DriverData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); - return; - } - } ti = fxTMGetTexInfo(texObj); + assert(ti); if (!texImage->DriverData) { texImage->DriverData = CALLOC(sizeof(tfxMipMapLevel)); |