diff options
author | Felix Kuehling <fxkuehl@gmx.de> | 2004-03-21 18:50:21 +0000 |
---|---|---|
committer | Felix Kuehling <fxkuehl@gmx.de> | 2004-03-21 18:50:21 +0000 |
commit | 7e4a56d110bbac1fa7887253385006010940717e (patch) | |
tree | d62d166d063aa9e9004f63e053266ae18bc5e715 | |
parent | 57ff474cb01160d9e6b12512135b945fb1f151a1 (diff) |
Improved MaxTextureLevel computation to take the nr. of tex units and both
texture heaps into account.
-rw-r--r-- | src/mesa/drivers/dri/savage/savage_xmesa.c | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c index f07d4aadd3..3eb7953f6d 100644 --- a/src/mesa/drivers/dri/savage/savage_xmesa.c +++ b/src/mesa/drivers/dri/savage/savage_xmesa.c @@ -234,6 +234,7 @@ savageCreateContext( const __GLcontextModes *mesaVis, savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private; drm_savage_sarea_t *saPriv=(drm_savage_sarea_t *)(((char*)sPriv->pSAREA)+ savageScreen->sarea_priv_offset); + GLuint maxTextureSize, minTextureSize, maxTextureLevels; int i; imesa = (savageContextPtr)Xcalloc(sizeof(savageContext), 1); if (!imesa) { @@ -257,18 +258,6 @@ savageCreateContext( const __GLcontextModes *mesaVis, } driContextPriv->driverPrivate = imesa; - /* BEGIN;*/ - /* Set the maximum texture size small enough that we can guarentee - * that both texture units can bind a maximal texture and have them - * in memory at once. - */ - if (savageScreen->textureSize[SAVAGE_CARD_HEAP] < 2*1024*1024) { - ctx->Const.MaxTextureLevels = 9; - } else if (savageScreen->textureSize[SAVAGE_CARD_HEAP] < 8*1024*1024) { - ctx->Const.MaxTextureLevels = 10; - } else { - ctx->Const.MaxTextureLevels = 11; - } if (savageScreen->chipset >= S3_SAVAGE4) ctx->Const.MaxTextureUnits = 2; else @@ -276,6 +265,39 @@ savageCreateContext( const __GLcontextModes *mesaVis, ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits; ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits; + /* Set the maximum texture size small enough that we can guarentee + * that all texture units can bind a maximal texture and have them + * in memory at once. + */ + if (savageScreen->textureSize[SAVAGE_CARD_HEAP] > + savageScreen->textureSize[SAVAGE_AGP_HEAP]) { + maxTextureSize = savageScreen->textureSize[SAVAGE_CARD_HEAP]; + minTextureSize = savageScreen->textureSize[SAVAGE_AGP_HEAP]; + } else { + maxTextureSize = savageScreen->textureSize[SAVAGE_AGP_HEAP]; + minTextureSize = savageScreen->textureSize[SAVAGE_CARD_HEAP]; + } + if (ctx->Const.MaxTextureUnits == 2) { + /* How to distribute two maximum sized textures to two texture heaps? + * If the smaller heap is less then half the size of the bigger one + * then the maximum size is half the size of the bigger heap. + * Otherwise it's the size of the smaller heap. */ + if (minTextureSize < maxTextureSize / 2) + maxTextureSize = maxTextureSize / 2; + else + maxTextureSize = minTextureSize; + } + for (maxTextureLevels = 1; maxTextureLevels <= 11; ++maxTextureLevels) { + GLuint size = 1 << maxTextureLevels; + size *= size * 4; /* 4 bytes per texel */ + size *= 2; /* all mipmap levels together take roughly twice the size of + the biggest level */ + if (size > maxTextureSize) + break; + } + ctx->Const.MaxTextureLevels = maxTextureLevels-1; + assert (ctx->Const.MaxTextureLevels >= 6); /*spec requires at least 64x64*/ + #if 0 ctx->Const.MinLineWidth = 1.0; ctx->Const.MinLineWidthAA = 1.0; |