From: Brian Paul Date: Sat, 5 Feb 2005 17:37:00 +0000 (+0000) Subject: removed need for Shared->TexObjectList, walk over texture hash table entries instead X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cf899d400d480d7017311d92f2cfd94391b785b4;p=mesa.git removed need for Shared->TexObjectList, walk over texture hash table entries instead --- diff --git a/src/mesa/drivers/dri/tdfx/tdfx_context.c b/src/mesa/drivers/dri/tdfx/tdfx_context.c index c1491ce472b..e251c03a1ca 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_context.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_context.c @@ -49,6 +49,7 @@ #include "tdfx_span.h" #include "tdfx_texman.h" #include "extensions.h" +#include "hash.h" #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" @@ -560,12 +561,24 @@ tdfxDestroyContext( __DRIcontextPrivate *driContextPriv ) /* This share group is about to go away, free our private * texture object data. */ +#if 0 struct gl_texture_object *tObj; tObj = fxMesa->glCtx->Shared->TexObjectList; while (tObj) { tdfxTMFreeTexture(fxMesa, tObj); tObj = tObj->Next; } +#else + struct _mesa_HashTable *textures = fxMesa->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); + tdfxTMFreeTexture(fxMesa, tObj); + } +#endif } tdfxTMClose(fxMesa); /* free texture memory */ diff --git a/src/mesa/drivers/dri/tdfx/tdfx_texman.c b/src/mesa/drivers/dri/tdfx/tdfx_texman.c index 2b2c93f1c32..63cae17e4e9 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_texman.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_texman.c @@ -38,6 +38,7 @@ #include "tdfx_context.h" #include "tdfx_tex.h" #include "tdfx_texman.h" +#include "hash.h" #define BAD_ADDRESS ((FxU32) -1) @@ -76,10 +77,14 @@ VerifyFreeList(tdfxContextPtr fxMesa, FxU32 tmu) assert(totalFree == shared->freeTexMem[tmu]); { - struct gl_texture_object *obj; - for (obj = mesaShared->TexObjectList; obj; obj = obj->Next) { - tdfxTexInfo *ti = TDFX_TEXTURE_DATA(obj); - numObj++; + struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; + GLuint id; + for (id = _mesa_HashFirstEntry(textures); + id; + id = _mesa_HashNextEntry(textures, id)) { + struct gl_texture_object *tObj; + tObj = (struct gl_texture_object *) _mesa_HashLookup(textures, id); + tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); if (ti) { if (ti->isInTM) { numRes++; @@ -106,13 +111,18 @@ static void dump_texmem(tdfxContextPtr fxMesa) { struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; + struct _mesa_HashTable *textures = mesaShared->TexObjects; struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - struct gl_texture_object *oldestObj, *obj, *lowestPriorityObj; tdfxMemRange *r; FxU32 prev; + GLuint id; printf("DUMP Objects:\n"); - for (obj = mesaShared->TexObjectList; obj; obj = obj->Next) { + for (id = _mesa_HashFirstEntry(textures); + id; + id = _mesa_HashNextEntry(textures, id)) { + struct gl_texture_object *obj + = (struct gl_texture_object *) _mesa_HashLookup(textures, id); tdfxTexInfo *info = TDFX_TEXTURE_DATA(obj); if (info && info->isInTM) { @@ -378,9 +388,11 @@ static struct gl_texture_object * FindOldestObject(tdfxContextPtr fxMesa, FxU32 tmu) { const GLuint bindnumber = fxMesa->texBindNumber; - struct gl_texture_object *oldestObj, *obj, *lowestPriorityObj; + struct gl_texture_object *oldestObj, *lowestPriorityObj; GLfloat lowestPriority; GLuint oldestAge; + GLuint id; + struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; oldestObj = NULL; oldestAge = 0; @@ -388,7 +400,11 @@ FindOldestObject(tdfxContextPtr fxMesa, FxU32 tmu) lowestPriority = 1.0F; lowestPriorityObj = NULL; - for (obj = fxMesa->glCtx->Shared->TexObjectList; obj; obj = obj->Next) { + for (id = _mesa_HashFirstEntry(textures); + id; + id = _mesa_HashNextEntry(textures, id)) { + struct gl_texture_object *obj + = (struct gl_texture_object *) _mesa_HashLookup(textures, id); tdfxTexInfo *info = TDFX_TEXTURE_DATA(obj); if (info && info->isInTM && @@ -437,11 +453,14 @@ FindOldestObject(tdfxContextPtr fxMesa, FxU32 tmu) static void FlushTexMemory(tdfxContextPtr fxMesa) { - struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared; - struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData; - struct gl_texture_object *obj; - - for (obj = mesaShared->TexObjectList; obj; obj = obj->Next) { + struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects; + GLuint id; + + for (id = _mesa_HashFirstEntry(textures); + id; + id = _mesa_HashNextEntry(textures, id)) { + struct gl_texture_object *obj + = (struct gl_texture_object *) _mesa_HashLookup(textures, id); if (obj->RefCount < 2) { /* don't flush currently bound textures */ tdfxTMMoveOutTM_NoLock(fxMesa, obj); @@ -946,12 +965,17 @@ tdfxTMFreeTexture(tdfxContextPtr fxMesa, struct gl_texture_object *tObj) void tdfxTMRestoreTextures_NoLock( tdfxContextPtr fxMesa ) { GLcontext *ctx = fxMesa->glCtx; - struct gl_texture_object *tObj; - int i; - - for ( tObj = ctx->Shared->TexObjectList ; tObj ; tObj = tObj->Next ) { + struct _mesa_HashTable *textures = fxMesa->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); tdfxTexInfo *ti = TDFX_TEXTURE_DATA( tObj ); if ( ti && ti->isInTM ) { + int i; for ( i = 0 ; i < MAX_TEXTURE_UNITS ; i++ ) { if ( ctx->Texture.Unit[i]._Current == tObj ) { tdfxTMDownloadTexture( fxMesa, tObj );