diff options
Diffstat (limited to 'src/mesa/drivers/dri/savage')
-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 f07d4aadd38..3eb7953f6de 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; |