diff options
Diffstat (limited to 'src/mesa/drivers/dri/r200/r200_texstate.c')
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_texstate.c | 96 |
1 files changed, 26 insertions, 70 deletions
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c index e1dc206d927..3d82aac3234 100644 --- a/src/mesa/drivers/dri/r200/r200_texstate.c +++ b/src/mesa/drivers/dri/r200/r200_texstate.c @@ -1,6 +1,5 @@ -/* $XFree86$ */ -/************************************************************************** - +/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_texstate.c,v 1.3 2003/02/15 22:18:47 dawes Exp $ */ +/* Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved. The Weather Channel (TM) funded Tungsten Graphics to develop the @@ -106,7 +105,7 @@ static void r200SetTexImages( r200ContextPtr rmesa, const struct gl_texture_image *baseImage = tObj->Image[tObj->BaseLevel]; GLint curOffset; GLint i; - GLint firstLevel=0, lastLevel=0, numLevels; + GLint numLevels; GLint log2Width, log2Height, log2Depth; /* Set the hardware texture format @@ -126,66 +125,15 @@ static void r200SetTexImages( r200ContextPtr rmesa, } - /* 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. */ - if (R200_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, - "%s: BaseLevel %d MinLod %f MaxLod %f MaxLevel %d\n", - __FUNCTION__, - tObj->BaseLevel, tObj->MinLod, tObj->MaxLod, - tObj->MaxLevel); - - - switch (tObj->Target) { - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_CUBE_MAP: - 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 */ - log2Width = tObj->Image[firstLevel]->WidthLog2; - log2Height = tObj->Image[firstLevel]->HeightLog2; - log2Depth = 0; - break; - case GL_TEXTURE_3D: - firstLevel = tObj->BaseLevel; - lastLevel = tObj->BaseLevel; - log2Width = tObj->Image[firstLevel]->WidthLog2; - log2Height = tObj->Image[firstLevel]->HeightLog2; - log2Depth = tObj->Image[firstLevel]->DepthLog2; - break; - case GL_TEXTURE_RECTANGLE_NV: - firstLevel = lastLevel = 0; - log2Width = log2Height = 1; /* ? */ - log2Depth = 0; - break; - default: - return; - } - - /* save these values */ - t->base.firstLevel = firstLevel; - t->base.lastLevel = lastLevel; - numLevels = lastLevel - firstLevel + 1; - - if (R200_DEBUG & DEBUG_TEXTURE) - fprintf(stderr, - "%s: firstLevel %d last Level %d w,h: %d,%d log(w,h) %d,%d\n", - __FUNCTION__, firstLevel, lastLevel, - tObj->Image[firstLevel]->Width, - tObj->Image[firstLevel]->Height, - tObj->Image[firstLevel]->WidthLog2, - tObj->Image[firstLevel]->HeightLog2); + driCalculateTextureFirstLastLevel( (driTextureObject *) t ); + log2Width = tObj->Image[t->base.firstLevel]->WidthLog2; + log2Height = tObj->Image[t->base.firstLevel]->HeightLog2; + log2Depth = tObj->Image[t->base.firstLevel]->DepthLog2; + numLevels = t->base.lastLevel - t->base.firstLevel + 1; assert(numLevels <= RADEON_MAX_TEXTURE_LEVELS); @@ -199,7 +147,7 @@ static void r200SetTexImages( r200ContextPtr rmesa, const struct gl_texture_image *texImage; GLuint size; - texImage = tObj->Image[i + firstLevel]; + texImage = tObj->Image[i + t->base.firstLevel]; if ( !texImage ) break; @@ -219,10 +167,12 @@ static void r200SetTexImages( r200ContextPtr rmesa, } assert(size > 0); - if (curOffset & 0x1f) { - /* align to 32-byte offset */ - curOffset = (curOffset + 0x1f) & ~0x1f; - } + + /* Align to 32-byte offset. It is faster to do this unconditionally + * (no branch penalty). + */ + + curOffset = (curOffset + 0x1f) & ~0x1f; t->image[0][i].x = curOffset % BLIT_WIDTH_BYTES; t->image[0][i].y = curOffset / BLIT_WIDTH_BYTES; @@ -305,17 +255,17 @@ static void r200SetTexImages( r200ContextPtr rmesa, (log2Height << R200_FACE_HEIGHT_4_SHIFT)); } - t->pp_txsize = (((tObj->Image[firstLevel]->Width - 1) << 0) | - ((tObj->Image[firstLevel]->Height - 1) << 16)); + t->pp_txsize = (((tObj->Image[t->base.firstLevel]->Width - 1) << 0) | + ((tObj->Image[t->base.firstLevel]->Height - 1) << 16)); /* Only need to round to nearest 32 for textures, but the blitter * requires 64-byte aligned pitches, and we may/may not need the * blitter. NPOT only! */ if (baseImage->IsCompressed) - t->pp_txpitch = (tObj->Image[firstLevel]->Width + 63) & ~(63); + t->pp_txpitch = (tObj->Image[t->base.firstLevel]->Width + 63) & ~(63); else - t->pp_txpitch = ((tObj->Image[firstLevel]->Width * baseImage->TexFormat->TexelBytes) + 63) & ~(63); + t->pp_txpitch = ((tObj->Image[t->base.firstLevel]->Width * baseImage->TexFormat->TexelBytes) + 63) & ~(63); t->pp_txpitch -= 32; t->dirty_state = TEX_ALL; @@ -1561,6 +1511,12 @@ static GLboolean enable_tex_3d( GLcontext *ctx, int unit ) ASSERT(tObj->Target == GL_TEXTURE_3D); + /* R100 & R200 do not support mipmaps for 3D textures. + */ + if ( (tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR) ) { + return GL_FALSE; + } + if ( t->base.dirty_images[0] ) { R200_FIREVERTICES( rmesa ); r200SetTexImages( rmesa, tObj ); @@ -1633,7 +1589,7 @@ static GLboolean enable_tex_rect( GLcontext *ctx, int unit ) R200_FIREVERTICES( rmesa ); r200SetTexImages( rmesa, tObj ); r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, 0 ); - if ( !t->base.memBlock && !rmesa->prefer_agp_client_texturing ) + if ( !t->base.memBlock && !rmesa->prefer_gart_client_texturing ) return GL_FALSE; } |