diff options
Diffstat (limited to 'src/mesa/drivers/dri/i830/i830_texstate.c')
-rw-r--r-- | src/mesa/drivers/dri/i830/i830_texstate.c | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/src/mesa/drivers/dri/i830/i830_texstate.c b/src/mesa/drivers/dri/i830/i830_texstate.c index 03c98d2ee96..4d211176fd2 100644 --- a/src/mesa/drivers/dri/i830/i830_texstate.c +++ b/src/mesa/drivers/dri/i830/i830_texstate.c @@ -62,7 +62,7 @@ static void i830SetTexImages( i830ContextPtr imesa, GLuint total_height, pitch, i, textureFormat; i830TextureObjectPtr t = (i830TextureObjectPtr) tObj->DriverData; const struct gl_texture_image *baseImage = tObj->Image[tObj->BaseLevel]; - GLint firstLevel, lastLevel, numLevels; + GLint numLevels; switch( baseImage->TexFormat->MesaFormat ) { case MESA_FORMAT_L8: @@ -119,52 +119,27 @@ static void i830SetTexImages( i830ContextPtr imesa, } /* Compute which mipmap levels we really want to send to the hardware. - * This depends on the base image size, GL_TEXTURE_MIN_LOD, - * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL. - * Yes, this looks overly complicated, but it's all needed. */ - switch (tObj->Target) { - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5); - firstLevel = MAX2(firstLevel, tObj->BaseLevel); - lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5); - lastLevel = MAX2(lastLevel, tObj->BaseLevel); - lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2); - lastLevel = MIN2(lastLevel, tObj->MaxLevel); - lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */ - break; - case GL_TEXTURE_RECTANGLE_NV: - firstLevel = lastLevel = 0; - break; - default: - fprintf(stderr, "%s: bad target %s\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(tObj->Target)); - return; - } - - /* save these values */ - t->base.firstLevel = firstLevel; - t->base.lastLevel = lastLevel; + driCalculateTextureFirstLastLevel( (driTextureObject *) t ); /* Figure out the amount of memory required to hold all the mipmap * levels. Choose the smallest pitch to accomodate the largest * mipmap: */ - numLevels = lastLevel - firstLevel + 1; + numLevels = t->base.lastLevel - t->base.firstLevel + 1; /* Pitch would be subject to additional rules if texture memory were * tiled. Currently it isn't. */ if (0) { pitch = 128; - while (pitch < tObj->Image[firstLevel]->Width * t->texelBytes) + while (pitch < tObj->Image[t->base.firstLevel]->Width * t->texelBytes) pitch *= 2; } else { - pitch = tObj->Image[firstLevel]->Width * t->texelBytes; + pitch = tObj->Image[t->base.firstLevel]->Width * t->texelBytes; pitch = (pitch + 3) & ~3; } @@ -173,7 +148,7 @@ static void i830SetTexImages( i830ContextPtr imesa, * lines required: */ for ( total_height = i = 0 ; i < numLevels ; i++ ) { - t->image[0][i].image = tObj->Image[firstLevel + i]; + t->image[0][i].image = tObj->Image[t->base.firstLevel + i]; if (!t->image[0][i].image) break; @@ -185,8 +160,8 @@ static void i830SetTexImages( i830ContextPtr imesa, t->Pitch = pitch; t->base.totalSize = total_height*pitch; t->Setup[I830_TEXREG_TM0S1] = - (((tObj->Image[firstLevel]->Height - 1) << TM0S1_HEIGHT_SHIFT) | - ((tObj->Image[firstLevel]->Width - 1) << TM0S1_WIDTH_SHIFT) | + (((tObj->Image[t->base.firstLevel]->Height - 1) << TM0S1_HEIGHT_SHIFT) | + ((tObj->Image[t->base.firstLevel]->Width - 1) << TM0S1_WIDTH_SHIFT) | textureFormat); t->Setup[I830_TEXREG_TM0S2] = ((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT)); |