summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/glide/fxtexman.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/glide/fxtexman.c')
-rw-r--r--src/mesa/drivers/glide/fxtexman.c125
1 files changed, 75 insertions, 50 deletions
diff --git a/src/mesa/drivers/glide/fxtexman.c b/src/mesa/drivers/glide/fxtexman.c
index 5189816cdef..648649c0328 100644
--- a/src/mesa/drivers/glide/fxtexman.c
+++ b/src/mesa/drivers/glide/fxtexman.c
@@ -1,4 +1,4 @@
-/* $Id: fxtexman.c,v 1.16 2003/08/19 15:52:53 brianp Exp $ */
+/* $Id: fxtexman.c,v 1.17 2003/10/02 17:36:44 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -116,10 +116,11 @@ fxTMNewRangeNode(fxMesaContext fxMesa, FxU32 start, FxU32 end)
}
else {
if (!(result = MALLOC(sizeof(MemRange)))) {
- fprintf(stderr, "fxDriver: out of memory!\n");
+ fprintf(stderr, "%s: ERROR: out of memory!\n", __FUNCTION__);
fxCloseHardware();
exit(-1);
}
+ result->next = NULL;
}
result->startAddr = start;
result->endAddr = end;
@@ -137,11 +138,13 @@ static void
fxTMUInit(fxMesaContext fxMesa, int tmu)
{
MemRange *tmn, *last;
- FxU32 start, end, blockstart, blockend;
+ FxU32 start, end, blockstart, blockend, boundary;
start = grTexMinAddress(tmu);
end = grTexMaxAddress(tmu);
+ boundary = (fxMesa->type >= GR_SSTTYPE_Banshee) ? (end - start) : FX_2MB_SPLIT;
+
if (fxMesa->verbose) {
fprintf(stderr, "Voodoo %s configuration:\n",
(tmu == FX_TMU0) ? "TMU0" : "TMU1");
@@ -149,7 +152,7 @@ fxTMUInit(fxMesaContext fxMesa, int tmu)
(unsigned int) start);
fprintf(stderr, "Voodoo Higher texture memory address (%u)\n",
(unsigned int) end);
- fprintf(stderr, "Voodoo Splitting Texture memory in 2b blocks:\n");
+ fprintf(stderr, "Voodoo Splitting Texture memory in %luMB blocks:\n", boundary >> 20);
}
fxMesa->freeTexMem[tmu] = end - start;
@@ -158,17 +161,16 @@ fxTMUInit(fxMesaContext fxMesa, int tmu)
last = 0;
blockstart = start;
while (blockstart < end) {
- if (blockstart + FX_2MB_SPLIT > end)
+ if (blockstart + boundary > end)
blockend = end;
else
- blockend = blockstart + FX_2MB_SPLIT;
+ blockend = blockstart + boundary;
if (fxMesa->verbose)
fprintf(stderr, "Voodoo %07u-%07u\n",
(unsigned int) blockstart, (unsigned int) blockend);
tmn = fxTMNewRangeNode(fxMesa, blockstart, blockend);
- tmn->next = 0;
if (last)
last->next = tmn;
@@ -176,7 +178,7 @@ fxTMUInit(fxMesaContext fxMesa, int tmu)
fxMesa->tmFree[tmu] = tmn;
last = tmn;
- blockstart += FX_2MB_SPLIT;
+ blockstart += boundary;
}
}
@@ -210,9 +212,12 @@ fxTMFindStartAddr(fxMesaContext fxMesa, GLint tmu, int size)
tmp = tmp->next;
}
/* No free space. Discard oldest */
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "%s: No free space. Discard oldest\n", __FUNCTION__);
+ }
obj = fxTMFindOldestObject(fxMesa, tmu);
if (!obj) {
- fprintf(stderr, "fx Driver: No space for texture\n");
+ fprintf(stderr, "%s: ERROR: No space for texture\n", __FUNCTION__);
return -1;
}
fxTMMoveOutTM(fxMesa, obj);
@@ -224,6 +229,7 @@ static void
fxTMRemoveRange(fxMesaContext fxMesa, GLint tmu, MemRange * range)
{
MemRange *tmp, *prev;
+ FxU32 boundary = (fxMesa->type >= GR_SSTTYPE_Banshee) ? -1 : (FX_2MB_SPLIT - 1);
if (range->startAddr == range->endAddr) {
fxTMDeleteRangeNode(fxMesa, range);
@@ -246,7 +252,7 @@ fxTMRemoveRange(fxMesaContext fxMesa, GLint tmu, MemRange * range)
range->next = tmp;
if (tmp) {
if (range->endAddr == tmp->startAddr
- && tmp->startAddr & (FX_2MB_SPLIT - 1)) {
+ && tmp->startAddr & boundary) {
/* Combine */
tmp->startAddr = range->startAddr;
fxTMDeleteRangeNode(fxMesa, range);
@@ -255,7 +261,7 @@ fxTMRemoveRange(fxMesaContext fxMesa, GLint tmu, MemRange * range)
}
if (prev) {
if (prev->endAddr == range->startAddr
- && range->startAddr & (FX_2MB_SPLIT - 1)) {
+ && range->startAddr & boundary) {
/* Combine */
prev->endAddr = range->endAddr;
prev->next = range->next;
@@ -273,15 +279,19 @@ static struct gl_texture_object *
fxTMFindOldestObject(fxMesaContext fxMesa, int tmu)
{
GLuint age, old, lasttime, bindnumber;
+ GLfloat lowestPriority;
tfxTexInfo *info;
- struct gl_texture_object *obj, *tmp;
+ struct gl_texture_object *obj, *tmp, *lowestPriorityObj;
tmp = fxMesa->glCtx->Shared->TexObjectList;
if (!tmp)
return 0;
- obj = 0;
+ obj = NULL;
old = 0;
+ lowestPriorityObj = NULL;
+ lowestPriority = 1.0F;
+
bindnumber = fxMesa->texBindNumber;
while (tmp) {
info = fxTMGetTexInfo(tmp);
@@ -300,10 +310,29 @@ fxTMFindOldestObject(fxMesaContext fxMesa, int tmu)
old = age;
obj = tmp;
}
+
+ /* examine priority */
+ if (obj->Priority < lowestPriority) {
+ lowestPriority = tmp->Priority;
+ lowestPriorityObj = tmp;
+ }
}
tmp = tmp->Next;
}
- return obj;
+
+ if (lowestPriority < 1.0) {
+ ASSERT(lowestPriorityObj);
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxTMFindOldestObject: %d pri=%f\n", lowestPriorityObj->Name, lowestPriority);
+ }
+ return lowestPriorityObj;
+ }
+ else {
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxTMFindOldestObject: %d age=%d\n", obj->Name, old);
+ }
+ return obj;
+ }
}
static MemRange *
@@ -330,15 +359,14 @@ fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj,
int i, l;
int texmemsize;
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxTMMoveInTM(%d)\n", tObj->Name);
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "%s(%d)\n", __FUNCTION__, tObj->Name);
}
fxMesa->stats.reqTexUpload++;
if (!ti->validated) {
- fprintf(stderr,
- "fx Driver: internal error in fxTMMoveInTM() -> not validated\n");
+ fprintf(stderr, "%s: INTERNAL ERROR: not validated\n", __FUNCTION__);
fxCloseHardware();
exit(-1);
}
@@ -355,9 +383,9 @@ fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj,
}
}
- if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) {
- fprintf(stderr, "fxmesa: downloading %x (%d) in texture memory in %d\n",
- (GLuint) tObj, tObj->Name, where);
+ if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) {
+ fprintf(stderr, "%s: downloading %p (%d) in texture memory in %d\n",
+ __FUNCTION__, (void *)tObj, tObj->Name, where);
}
ti->whichTMU = (FxU32) where;
@@ -419,9 +447,9 @@ fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj,
ti->tm[FX_TMU0] = fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
fxMesa->stats.memTexUpload += texmemsize;
- texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+ /*texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info));*/
ti->tm[FX_TMU1] = fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize);
- fxMesa->stats.memTexUpload += texmemsize;
+ fxMesa->stats.memTexUpload += texmemsize; /* ZZZ: required? */
for (i = FX_largeLodValue(ti->info), l = ti->minLevel;
i <= FX_smallLodValue(ti->info); i++, l++) {
@@ -446,9 +474,7 @@ fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj,
}
break;
default:
- fprintf(stderr,
- "fx Driver: internal error in fxTMMoveInTM() -> wrong tmu (%d)\n",
- where);
+ fprintf(stderr, "%s: INTERNAL ERROR: wrong tmu (%d)\n", __FUNCTION__, where);
fxCloseHardware();
exit(-1);
}
@@ -479,14 +505,17 @@ fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj,
struct gl_texture_image *texImage = tObj->Image[level];
tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxTMReloadMipMapLevel(%p (%d), %d)\n", (void *)tObj, tObj->Name, level);
+ }
+
assert(mml);
assert(mml->width > 0);
assert(mml->height > 0);
assert(mml->glideFormat > 0);
if (!ti->validated) {
- fprintf(stderr,
- "fx Driver: internal error in fxTMReloadMipMapLevel() -> not validated\n");
+ fprintf(stderr, "%s: INTERNAL ERROR: not validated\n", __FUNCTION__);
fxCloseHardware();
exit(-1);
}
@@ -494,16 +523,14 @@ fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj,
tmu = (int) ti->whichTMU;
fxTMMoveInTM(fxMesa, tObj, tmu);
- fxTexGetInfo(mml->width, mml->height,
- &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ lodlevel = ti->info.largeLodLog2 - (level - ti->minLevel);
- lodlevel -= level;
switch (tmu) {
case FX_TMU0:
case FX_TMU1:
grTexDownloadMipMapLevel(tmu,
ti->tm[tmu]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)),
+ lodlevel,
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
@@ -512,7 +539,7 @@ fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj,
case FX_TMU_SPLIT:
grTexDownloadMipMapLevel(GR_TMU0,
ti->tm[GR_TMU0]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)),
+ lodlevel,
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
@@ -520,7 +547,7 @@ fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj,
grTexDownloadMipMapLevel(GR_TMU1,
ti->tm[GR_TMU1]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)),
+ lodlevel,
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
@@ -529,7 +556,7 @@ fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj,
case FX_TMU_BOTH:
grTexDownloadMipMapLevel(GR_TMU0,
ti->tm[GR_TMU0]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)),
+ lodlevel,
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
@@ -537,7 +564,7 @@ fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj,
grTexDownloadMipMapLevel(GR_TMU1,
ti->tm[GR_TMU1]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)),
+ lodlevel,
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
@@ -545,9 +572,7 @@ fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj,
break;
default:
- fprintf(stderr,
- "fx Driver: internal error in fxTMReloadMipMapLevel() -> wrong tmu (%d)\n",
- tmu);
+ fprintf(stderr, "%s: INTERNAL ERROR: wrong tmu (%d)\n", __FUNCTION__, tmu);
fxCloseHardware();
exit(-1);
}
@@ -568,8 +593,7 @@ fxTMReloadSubMipMapLevel(fxMesaContext fxMesa,
assert(mml);
if (!ti->validated) {
- fprintf(stderr,
- "fx Driver: internal error in fxTMReloadSubMipMapLevel() -> not validated\n");
+ fprintf(stderr, "%s: INTERNAL ERROR: not validated\n", __FUNCTION__);
fxCloseHardware();
exit(-1);
}
@@ -578,7 +602,7 @@ fxTMReloadSubMipMapLevel(fxMesaContext fxMesa,
fxTMMoveInTM(fxMesa, tObj, tmu);
fxTexGetInfo(mml->width, mml->height,
- &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ &lodlevel, NULL, NULL, NULL, NULL, NULL);
if ((ti->info.format == GR_TEXFMT_INTENSITY_8) ||
(ti->info.format == GR_TEXFMT_P_8) ||
@@ -643,9 +667,7 @@ fxTMReloadSubMipMapLevel(fxMesaContext fxMesa,
yoffset, yoffset + height - 1);
break;
default:
- fprintf(stderr,
- "fx Driver: internal error in fxTMReloadSubMipMapLevel() -> wrong tmu (%d)\n",
- tmu);
+ fprintf(stderr, "%s: INTERNAL ERROR: wrong tmu (%d)\n", __FUNCTION__, tmu);
fxCloseHardware();
exit(-1);
}
@@ -656,9 +678,8 @@ fxTMMoveOutTM(fxMesaContext fxMesa, struct gl_texture_object *tObj)
{
tfxTexInfo *ti = fxTMGetTexInfo(tObj);
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxTMMoveOutTM(%x (%d))\n", (GLuint) tObj,
- tObj->Name);
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "%s(%p (%d))\n", __FUNCTION__, (void *)tObj, tObj->Name);
}
if (!ti->isInTM)
@@ -675,7 +696,7 @@ fxTMMoveOutTM(fxMesaContext fxMesa, struct gl_texture_object *tObj)
fxTMRemoveRange(fxMesa, FX_TMU1, ti->tm[FX_TMU1]);
break;
default:
- fprintf(stderr, "fx Driver: internal error in fxTMMoveOutTM()\n");
+ fprintf(stderr, "%s: INTERNAL ERROR: bad TMU (%ld)\n", __FUNCTION__, ti->whichTMU);
fxCloseHardware();
exit(-1);
}
@@ -690,13 +711,17 @@ fxTMFreeTexture(fxMesaContext fxMesa, struct gl_texture_object *tObj)
tfxTexInfo *ti = fxTMGetTexInfo(tObj);
int i;
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "%s(%p (%d))\n", __FUNCTION__, (void *)tObj, tObj->Name);
+ }
+
fxTMMoveOutTM(fxMesa, tObj);
for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
struct gl_texture_image *texImage = tObj->Image[i];
if (texImage) {
if (texImage->Data) {
- FREE(texImage->Data);
+ MESA_PBUFFER_FREE(texImage->Data);
texImage->Data = NULL;
}
if (texImage->DriverData) {