X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fglide%2Ffxtexman.c;h=940c8fd0b97d92c9d065b6b8753ae2a61a0193aa;hb=646ed82e6b2c092c6db364bf87d6881f39e83eec;hp=f891657d92a16b842991b82da6c997278c9cb9cc;hpb=28442852978e8ca0bcc5fda6393fc7b94fcf2bbf;p=mesa.git diff --git a/src/mesa/drivers/glide/fxtexman.c b/src/mesa/drivers/glide/fxtexman.c index f891657d92a..940c8fd0b97 100644 --- a/src/mesa/drivers/glide/fxtexman.c +++ b/src/mesa/drivers/glide/fxtexman.c @@ -40,6 +40,7 @@ #if defined(FX) +#include "hash.h" #include "fxdrv.h" int texSwaps = 0; @@ -150,15 +151,9 @@ fxTMUInit(fxMesaContext fxMesa, int tmu) end = grTexMaxAddress(tmu); chunk = (fxMesa->type >= GR_SSTTYPE_Banshee) ? (end - start) : FX_2MB_SPLIT; - + if (fxMesa->verbose) { - fprintf(stderr, "Voodoo %s configuration:\n", - (tmu == FX_TMU0) ? "TMU0" : "TMU1"); - fprintf(stderr, "Voodoo Lower texture memory address (%u)\n", - (unsigned int) start); - fprintf(stderr, "Voodoo Higher texture memory address (%u)\n", - (unsigned int) end); - fprintf(stderr, "Voodoo Splitting Texture memory in %luMB blocks:\n", chunk >> 20); + fprintf(stderr, "Voodoo TMU%d configuration:\n", tmu); } fxMesa->freeTexMem[tmu] = end - start; @@ -173,7 +168,7 @@ fxTMUInit(fxMesaContext fxMesa, int tmu) blockend = blockstart + chunk; if (fxMesa->verbose) - fprintf(stderr, "Voodoo %07u-%07u\n", + fprintf(stderr, "Voodoo %08u-%08u\n", (unsigned int) blockstart, (unsigned int) blockend); tmn = fxTMNewRangeNode(fxMesa, blockstart, blockend); @@ -239,9 +234,8 @@ fxTMFindStartAddr(fxMesaContext fxMesa, GLint tmu, int size) int fxTMCheckStartAddr (fxMesaContext fxMesa, GLint tmu, tfxTexInfo *ti) { - MemRange *prev, *tmp; + MemRange *tmp; int size; - struct gl_texture_object *obj; if (fxMesa->HaveTexUma) { return FXTRUE; @@ -318,12 +312,13 @@ fxTMFindOldestObject(fxMesaContext fxMesa, int tmu) { GLuint age, old, lasttime, bindnumber; GLfloat lowestPriority; - tfxTexInfo *info; - struct gl_texture_object *obj, *tmp, *lowestPriorityObj; + struct gl_texture_object *obj, *lowestPriorityObj; + struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; + GLuint id; - tmp = fxMesa->glCtx->Shared->TexObjectList; - if (!tmp) + if (!_mesa_HashFirstEntry(textures)) return 0; + obj = NULL; old = 0; @@ -331,12 +326,21 @@ fxTMFindOldestObject(fxMesaContext fxMesa, int tmu) lowestPriority = 1.0F; bindnumber = fxMesa->texBindNumber; - while (tmp) { - info = fxTMGetTexInfo(tmp); + + for (id = _mesa_HashFirstEntry(textures); + id; + id = _mesa_HashNextEntry(textures, id)) { + struct gl_texture_object *tmp + = (struct gl_texture_object *) _mesa_HashLookup(textures, id); + tfxTexInfo *info = fxTMGetTexInfo(tmp); if (info && info->isInTM && - ((info->whichTMU == tmu) || (info->whichTMU == FX_TMU_BOTH) || - (info->whichTMU == FX_TMU_SPLIT))) { + ((info->whichTMU == tmu) || + (info->whichTMU == FX_TMU_BOTH) || + (info->whichTMU == FX_TMU_SPLIT) || + fxMesa->HaveTexUma + ) + ) { lasttime = info->lastTimeUsed; if (lasttime > bindnumber) @@ -355,7 +359,6 @@ fxTMFindOldestObject(fxMesaContext fxMesa, int tmu) lowestPriorityObj = tmp; } } - tmp = tmp->Next; } if (lowestPriorityObj != NULL) { @@ -366,7 +369,9 @@ fxTMFindOldestObject(fxMesaContext fxMesa, int tmu) } else { if (TDFX_DEBUG & VERBOSE_TEXTURE) { - fprintf(stderr, "fxTMFindOldestObject: %d age=%d\n", obj->Name, old); + if (obj != NULL) { + fprintf(stderr, "fxTMFindOldestObject: %d age=%d\n", obj->Name, old); + } } return obj; } @@ -436,7 +441,7 @@ fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj, for (i = FX_largeLodValue(ti->info), l = ti->minLevel; i <= FX_smallLodValue(ti->info); i++, l++) { - struct gl_texture_image *texImage = tObj->Image[l]; + struct gl_texture_image *texImage = tObj->Image[0][l]; grTexDownloadMipMapLevel(where, ti->tm[where]->startAddr, FX_valueToLod(i), @@ -458,7 +463,7 @@ fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj, for (i = FX_largeLodValue(ti->info), l = ti->minLevel; i <= FX_smallLodValue(ti->info); i++, l++) { - struct gl_texture_image *texImage = tObj->Image[l]; + struct gl_texture_image *texImage = tObj->Image[0][l]; grTexDownloadMipMapLevel(GR_TMU0, ti->tm[FX_TMU0]->startAddr, @@ -486,11 +491,11 @@ fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj, /*texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info));*/ ti->tm[FX_TMU1] = fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize); - fxMesa->stats.memTexUpload += texmemsize; /* ZZZ: required? */ + fxMesa->stats.memTexUpload += texmemsize; for (i = FX_largeLodValue(ti->info), l = ti->minLevel; i <= FX_smallLodValue(ti->info); i++, l++) { - struct gl_texture_image *texImage = tObj->Image[l]; + struct gl_texture_image *texImage = tObj->Image[0][l]; grTexDownloadMipMapLevel(GR_TMU0, ti->tm[FX_TMU0]->startAddr, FX_valueToLod(i), @@ -539,7 +544,7 @@ fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj, tfxTexInfo *ti = fxTMGetTexInfo(tObj); GrLOD_t lodlevel; GLint tmu; - struct gl_texture_image *texImage = tObj->Image[level]; + struct gl_texture_image *texImage = tObj->Image[0][level]; tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); if (TDFX_DEBUG & VERBOSE_TEXTURE) { @@ -550,6 +555,7 @@ fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj, assert(mml->width > 0); assert(mml->height > 0); assert(mml->glideFormat > 0); + assert(ti->isInTM); if (!ti->validated) { fprintf(stderr, "fxTMReloadMipMapLevel: INTERNAL ERROR: not validated\n"); @@ -558,17 +564,8 @@ fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj, } tmu = (int) ti->whichTMU; -#if 0 - /* [dBorca] - * We get here by (see Tex[Sub]Image2D), thus we are in TMU. - * Also, we just set the correct TMU above. fxTMMoveInTM will - * bail early, so don't bother... - */ - fxTMMoveInTM(fxMesa, tObj, tmu); -#else fxMesa->stats.reqTexUpload++; fxMesa->stats.texUpload++; -#endif lodlevel = ti->info.largeLodLog2 - (level - ti->minLevel); @@ -634,7 +631,7 @@ fxTMReloadSubMipMapLevel(fxMesaContext fxMesa, GrLOD_t lodlevel; unsigned short *data; GLint tmu; - struct gl_texture_image *texImage = tObj->Image[level]; + struct gl_texture_image *texImage = tObj->Image[0][level]; tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); assert(mml); @@ -765,12 +762,8 @@ fxTMFreeTexture(fxMesaContext fxMesa, struct gl_texture_object *tObj) fxTMMoveOutTM(fxMesa, tObj); for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { - struct gl_texture_image *texImage = tObj->Image[i]; + struct gl_texture_image *texImage = tObj->Image[0][i]; if (texImage) { - if (texImage->Data) { - MESA_PBUFFER_FREE(texImage->Data); - texImage->Data = NULL; - } if (texImage->DriverData) { FREE(texImage->DriverData); texImage->DriverData = NULL; @@ -838,26 +831,29 @@ fxTMClose(fxMesaContext fxMesa) void fxTMRestoreTextures_NoLock(fxMesaContext ctx) { - tfxTexInfo *ti; - struct gl_texture_object *tObj; - int i, where; - - tObj = ctx->glCtx->Shared->TexObjectList; - while (tObj) { - ti = fxTMGetTexInfo(tObj); + struct _mesa_HashTable *textures = ctx->glCtx->Shared->TexObjects; + GLuint id; + + for (id = _mesa_HashFirstEntry(textures); + id; + id = _mesa_HashNextEntry(textures, id)) { + struct gl_texture_object *tObj + = (struct gl_texture_object *) _mesa_HashLookup(textures, id); + tfxTexInfo *ti = fxTMGetTexInfo(tObj); if (ti && ti->isInTM) { - for (i = 0; i < MAX_TEXTURE_UNITS; i++) + int i; + for (i = 0; i < MAX_TEXTURE_UNITS; i++) { if (ctx->glCtx->Texture.Unit[i]._Current == tObj) { /* Force the texture onto the board, as it could be in use */ - where = ti->whichTMU; + int where = ti->whichTMU; fxTMMoveOutTM_NoLock(ctx, tObj); fxTMMoveInTM_NoLock(ctx, tObj, where); break; } + } if (i == MAX_TEXTURE_UNITS) /* Mark the texture as off the board */ fxTMMoveOutTM_NoLock(ctx, tObj); } - tObj = tObj->Next; } }