summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordok666 <dok666>2003-05-20 20:01:55 +0000
committerdok666 <dok666>2003-05-20 20:01:55 +0000
commit262d5a2e486307d13c6fc3d66239bc901787cfe6 (patch)
tree940e49298b233de7eb1beac57f00446dcc426ce3
parentb5b1632c3895c0d9fda9d9cb7ff0991192b0e068 (diff)
Sync with Ian's version and enhancements of my recent fixes.
-rw-r--r--src/mesa/drivers/dri/mga/mga_texstate.c65
-rw-r--r--src/mesa/drivers/dri/mga/mga_xmesa.c35
-rw-r--r--src/mesa/drivers/dri/mga/mgaregs.h7
-rw-r--r--src/mesa/drivers/dri/mga/mgatex.c17
-rw-r--r--src/mesa/drivers/dri/mga/mgatexmem.c6
5 files changed, 77 insertions, 53 deletions
diff --git a/src/mesa/drivers/dri/mga/mga_texstate.c b/src/mesa/drivers/dri/mga/mga_texstate.c
index b9163ffe789..d057593bd5d 100644
--- a/src/mesa/drivers/dri/mga/mga_texstate.c
+++ b/src/mesa/drivers/dri/mga/mga_texstate.c
@@ -97,65 +97,73 @@ mgaSetTexImages( mgaContextPtr mmesa,
#endif
- /* Calculate mipmap offsets and dimensions.
- */
- totalSize = 0;
-
/* 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.
*/
- firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
+
+ firstLevel = tObj->BaseLevel + (GLint)(tObj->MinLod + 0.5);
firstLevel = MAX2(firstLevel, tObj->BaseLevel);
- lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
+ 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;
- numLevels = MIN2( lastLevel - firstLevel + 1,
- MGA_IS_G200(mmesa) ? G200_TEX_MAXLEVELS : G400_TEX_MAXLEVELS);
+ numLevels = lastLevel - firstLevel + 1;
+ if ( MGA_IS_G200( mmesa ) ) {
+ numLevels = MIN2( numLevels, G200_TEX_MAXLEVELS );
+ }
+ else {
+ assert(numLevels <= G400_TEX_MAXLEVELS);
+ }
+
- baseImage = tObj->Image[firstLevel];
-
+ /* We are going to upload all levels that are present, even if
+ * later levels wouldn't be used by the current filtering mode. This
+ * allows the filtering mode to change without forcing another upload
+ * of the images.
+ */
+
+ totalSize = 0;
for ( i = 0 ; i < numLevels ; i++ ) {
- const struct gl_texture_image *texImage;
+ const struct gl_texture_image * const texImage = tObj->Image[i];
- texImage = tObj->Image[i + firstLevel];
- if ( !texImage ) {
- numLevels = i;
+ if ( (texImage == NULL)
+ || ((i != 0)
+ && ((texImage->Width < 8) || (texImage->Height < 8))) ) {
break;
}
- if (i && (texImage->Width < 8 || texImage->Height < 8)) {
- numLevels = i;
- break;
- }
-
t->offsets[i] = totalSize;
t->base.dirty_images[0] |= (1<<i);
-
+
totalSize += ((MAX2( texImage->Width, 8 ) *
- MAX2( texImage->Height, 8 ) *
- baseImage->TexFormat->TexelBytes) + 31) & ~31;
+ MAX2( texImage->Height, 8 ) *
+ baseImage->TexFormat->TexelBytes) + 31) & ~31;
}
+ numLevels = i;
lastLevel = firstLevel + numLevels - 1;
-
+
/* save these values */
t->firstLevel = firstLevel;
t->lastLevel = lastLevel;
-
+
t->base.totalSize = totalSize;
/* setup hardware register values */
- t->setup.texctl &= (TMC_tformat_MASK & TMC_tpitchext_MASK);
+ t->setup.texctl &= (TMC_tformat_MASK & TMC_tpitch_MASK
+ & TMC_tpitchext_MASK);
t->setup.texctl |= txformat;
t->setup.texctl |= TMC_tpitchlin_enable;
- if ( baseImage->Width < 2048 )
+ if ( baseImage->Width < 2048 ) {
t->setup.texctl |= (baseImage->Width << TMC_tpitchext_SHIFT);
+ }
/* G400 specifies the number of mip levels in a strange way. Since there
* are up to 12 levels, it requires 4 bits. Three of the bits are at the
@@ -163,9 +171,10 @@ mgaSetTexImages( mgaContextPtr mmesa,
*/
/* FIXME: Is this correct for G200?
*/
- t->setup.texfilter &= TF_mapnb_MASK & ~(1U << 18) & ~(0x1ff00);
+
+ t->setup.texfilter &= TF_mapnb_MASK & TF_mapnbhigh_MASK & TF_reserved_MASK;
t->setup.texfilter |= (((numLevels-1) & 0x07) << (TF_mapnb_SHIFT));
- t->setup.texfilter |= (((numLevels-1) & 0x08) << 15);
+ t->setup.texfilter |= (((numLevels-1) & 0x08) << (TF_mapnbhigh_SHIFT - 3));
/* warp texture registers */
ofs = MGA_IS_G200(mmesa) ? 28 : 11;
diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c
index 2ea5e54b4b2..55e6b6033b2 100644
--- a/src/mesa/drivers/dri/mga/mga_xmesa.c
+++ b/src/mesa/drivers/dri/mga/mga_xmesa.c
@@ -273,6 +273,7 @@ static const char * const card_extensions[] =
"GL_EXT_secondary_color",
"GL_EXT_stencil_wrap",
"GL_SGIS_generate_mipmap",
+ "GL_SGIS_texture_lod",
NULL
};
@@ -302,6 +303,7 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
void *sharedContextPrivate )
{
int i;
+ unsigned maxlevels;
GLcontext *ctx, *shareCtx;
mgaContextPtr mmesa;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
@@ -363,31 +365,24 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
ctx = mmesa->glCtx;
if ( mgaScreen->chipset == MGA_CARD_TYPE_G200 ) {
ctx->Const.MaxTextureUnits = 1;
- driCalculateMaxTextureLevels( mmesa->texture_heaps,
- mmesa->nr_heaps,
- & ctx->Const,
- 4,
- 11, /* max 2D texture size is 2048x2048 */
- 0, /* 3D textures unsupported. */
- 0, /* cube textures unsupported. */
- 0, /* texture rectangles unsupported. */
- G200_TEX_MAXLEVELS,
- GL_FALSE );
+ maxlevels = G200_TEX_MAXLEVELS;
+
}
else {
ctx->Const.MaxTextureUnits = 2;
- driCalculateMaxTextureLevels( mmesa->texture_heaps,
- mmesa->nr_heaps,
- & ctx->Const,
- 4,
- 11, /* max 2D texture size is 2048x2048 */
- 0, /* 3D textures unsupported. */
- 0, /* cube textures unsupported. */
- 0, /* texture rectangles unsupported. */
- G400_TEX_MAXLEVELS,
- GL_FALSE );
+ maxlevels = G400_TEX_MAXLEVELS;
}
+ driCalculateMaxTextureLevels( mmesa->texture_heaps,
+ mmesa->nr_heaps,
+ & ctx->Const,
+ 4,
+ 11, /* max 2D texture size is 1024x1024 */
+ 0, /* 3D textures unsupported. */
+ 0, /* cube textures unsupported. */
+ 0, /* texture rectangles unsupported. */
+ maxlevels,
+ GL_FALSE );
ctx->Const.MinLineWidth = 1.0;
ctx->Const.MinLineWidthAA = 1.0;
diff --git a/src/mesa/drivers/dri/mga/mgaregs.h b/src/mesa/drivers/dri/mga/mgaregs.h
index 401913a5bea..ff5b6063ee3 100644
--- a/src/mesa/drivers/dri/mga/mgaregs.h
+++ b/src/mesa/drivers/dri/mga/mgaregs.h
@@ -1137,6 +1137,13 @@
# define TF_magfilter_nrst 0x0 /* val 0, shift 4 */
# define TF_magfilter_bilin 0x20 /* val 2, shift 4 */
# define TF_magfilter_cnst 0x30 /* val 3, shift 4 */
+# define TF_uvoffset_SHIFT 17
+# define TF_uvoffset_OGL (0U << TF_uvoffset_SHIFT)
+# define TF_uvoffset_D3D (1U << TF_uvoffset_SHIFT)
+# define TF_uvoffset_MASK (~(1U << TF_uvoffset_SHIFT))
+# define TF_reserved_MASK (~0x1ff00) /* bits 8-16 */
+# define TF_mapnbhigh_SHIFT 18
+# define TF_mapnbhigh_MASK (~(1U << TF_mapnbhigh_SHIFT))
# define TF_avgstride_MASK 0xfff7ffff /* bit 19 */
# define TF_avgstride_disable 0x0
# define TF_avgstride_enable 0x80000
diff --git a/src/mesa/drivers/dri/mga/mgatex.c b/src/mesa/drivers/dri/mga/mgatex.c
index 203187a4c30..45410c04874 100644
--- a/src/mesa/drivers/dri/mga/mgatex.c
+++ b/src/mesa/drivers/dri/mga/mgatex.c
@@ -264,8 +264,9 @@ mgaAllocTexObj( struct gl_texture_object *tObj )
t->setup.texctl = TMC_takey_1 | TMC_tamask_0;
t->setup.texctl2 = TMC_ckstransdis_enable;
t->setup.texfilter = (TF_minfilter_nrst
- | TF_magfilter_nrst
- | TF_filteralpha_enable);
+ | TF_magfilter_nrst
+ | TF_filteralpha_enable
+ | TF_uvoffset_OGL);
make_empty_list( & t->base );
@@ -422,6 +423,18 @@ mgaDDTexParameter( GLcontext *ctx, GLenum target,
mgaSetTexBorderColor(t, tObj->_BorderChan);
break;
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ driSwapOutTextureObject( (driTextureObject *) t );
+ break;
+
default:
return;
}
diff --git a/src/mesa/drivers/dri/mga/mgatexmem.c b/src/mesa/drivers/dri/mga/mgatexmem.c
index 18768881d9f..cfb79f3a1c2 100644
--- a/src/mesa/drivers/dri/mga/mgatexmem.c
+++ b/src/mesa/drivers/dri/mga/mgatexmem.c
@@ -95,7 +95,7 @@ static void mgaUploadSubImage( mgaContextPtr mmesa,
unsigned offset;
unsigned texelBytes;
unsigned length;
- const int level = hwlevel + t->firstLevel;
+ const int level = hwlevel + t->firstLevel;
if ( (hwlevel < 0)
@@ -121,7 +121,7 @@ static void mgaUploadSubImage( mgaContextPtr mmesa,
/* find the proper destination offset for this level */
- if (MGA_IS_G200(mmesa) ) {
+ if ( MGA_IS_G200(mmesa) ) {
offset = (t->base.memBlock->ofs + t->offsets[hwlevel]);
}
else {
@@ -144,7 +144,7 @@ static void mgaUploadSubImage( mgaContextPtr mmesa,
texelBytes = texImage->TexFormat->TexelBytes;
length = texImage->Width * texImage->Height * texelBytes;
- if (t->base.heap->heapId == MGA_CARD_HEAP ) {
+ if ( t->base.heap->heapId == MGA_CARD_HEAP ) {
unsigned tex_offset = 0;
unsigned to_copy;