summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfxkuehl <fxkuehl>2004-02-09 22:38:11 +0000
committerfxkuehl <fxkuehl>2004-02-09 22:38:11 +0000
commit1ce511a2262fdbe6f005cac1a85cb49be4fc6bd5 (patch)
tree7c21be31c17db4bcd30d092ff7da9ed724a38ab6
parenta0273edff29eb67e7fbae03e1acc3a21b53e08c3 (diff)
Texture tiling format differs between Savage4 and newer chips. Now the driver tiles textures correctly for both. The right tiling format is detected at driver initialization. This fixes texture corruption on Savage4.
-rwxr-xr-xxc/lib/GL/mesa/src/drv/savage/savagetex.c97
-rwxr-xr-xxc/lib/GL/mesa/src/drv/savage/savagetex.h7
2 files changed, 95 insertions, 9 deletions
diff --git a/xc/lib/GL/mesa/src/drv/savage/savagetex.c b/xc/lib/GL/mesa/src/drv/savage/savagetex.c
index ab11568be..8834035d7 100755
--- a/xc/lib/GL/mesa/src/drv/savage/savagetex.c
+++ b/xc/lib/GL/mesa/src/drv/savage/savagetex.c
@@ -43,6 +43,18 @@
#include "swrast/swrast.h"
+/* declarations of static and inline functions */
+__inline GLuint GetTiledCoordinates8(GLuint iBufferWidth, GLint x, GLint y);
+static GLuint GetTiledCoordinates16_4( GLint iBufferWidth,GLint x,GLint y );
+static GLuint GetTiledCoordinates16_8( GLint iBufferWidth,GLint x,GLint y );
+static GLuint GetTiledCoordinates32_4( GLint iBufferWidth, GLint x, GLint y );
+static GLuint GetTiledCoordinates32_8( GLint iBufferWidth, GLint x, GLint y );
+__inline GLuint GetTiledCoordinates( GLint iDepth,GLint iBufferWidth,GLint x,GLint y );
+__inline GLubyte * savageMakeTexel(savageTextureObjectPtr t, GLubyte * src, GLubyte * dst, GLuint level);
+__inline void savageUploadImage(savageTextureObjectPtr t, GLuint level, GLuint startx, GLuint starty, GLuint reloc);
+__inline void savageTileTex(savageTextureObjectPtr tex, GLuint level);
+
+/* tile sizes depending on texel color depth */
GLuint gTileWidth[5] =
{
64, /* 4-bit */
@@ -83,7 +95,41 @@ __inline GLuint GetTiledCoordinates8(GLuint iBufferWidth, GLint x, GLint y)
((y105 * uWidthInTiles) + x106) << 11 );
}
-__inline GLuint GetTiledCoordinates16( GLint iBufferWidth,
+/* 4-pixel wide subtiles */
+static GLuint GetTiledCoordinates16_4( GLint iBufferWidth,
+ GLint x,
+ GLint y )
+{
+ GLint x106;
+ GLint x10;
+ GLint x52;
+ GLint y104;
+ GLint y20;
+ GLint y3;
+ GLuint uiWidthInTiles;
+
+ /*
+ // calculating tiled address
+ */
+
+ uiWidthInTiles = (iBufferWidth + 63) >> 6;
+
+ x10 = x & 0x3;
+ x52 = (x & 0x3c ) >> 2;
+ x106 = (x & 0x7c0) >> 6;
+
+ y20 = y & 0x7;
+ y3 = (y & 8 ) >> 3;
+ y104 = (y & 0x7f0) >> 4;
+
+ return( (x10 << 1) |
+ (y20 << 3) |
+ (x52 << 6) |
+ (y3 << 10) |
+ ((y104 * uiWidthInTiles) + x106) << 11 );
+}
+/* 8-pixel wide subtiles */
+static GLuint GetTiledCoordinates16_8( GLint iBufferWidth,
GLint x,
GLint y )
{
@@ -115,8 +161,44 @@ __inline GLuint GetTiledCoordinates16( GLint iBufferWidth,
(y3 << 10) |
((y104 * uiWidthInTiles) + x106) << 11 );
}
+/* function pointer set to the correct version in savageDDInitTextureFuncs */
+GLuint (*GetTiledCoordinates16) (GLint, GLint, GLint);
+
+/* 4-pixel wide subtiles */
+static GLuint GetTiledCoordinates32_4( GLint iBufferWidth,
+ GLint x,
+ GLint y )
+{
+ GLint x10;
+ GLint y20;
+ GLuint uiWidthInTiles;
+ GLint x42;
+ GLint x105;
+ GLint y3;
+ GLint y104;
+
+ /*
+ // calculating tiled address
+ */
+
+ uiWidthInTiles = (iBufferWidth + 31) >> 5;
-__inline GLuint GetTiledCoordinates32( GLint iBufferWidth,
+ x10 = x & 0x3;
+ x42 = (x & 0x1c ) >> 2;
+ x105 = (x & 0x7e0) >> 5;
+
+ y20 = y & 0x7;
+ y3 = (y & 8 ) >> 3;
+ y104 = (y & 0x7f0) >> 4;
+
+ return( (x10 << 2) |
+ (y20 << 4) |
+ (x42 << 7) |
+ (y3 << 10) |
+ ((y104 * uiWidthInTiles) + x105) << 11 );
+}
+/* 8-pixel wide subtiles */
+static GLuint GetTiledCoordinates32_8( GLint iBufferWidth,
GLint x,
GLint y )
{
@@ -148,6 +230,8 @@ __inline GLuint GetTiledCoordinates32( GLint iBufferWidth,
(y3 << 10) |
((y104 * uiWidthInTiles) + x105) << 11 );
}
+/* function pointer set to the correct version in savageDDInitTextureFuncs */
+GLuint (*GetTiledCoordinates32) (GLint, GLint, GLint);
__inline GLuint GetTiledCoordinates( GLint iDepth,
GLint iBufferWidth,
@@ -1801,6 +1885,15 @@ static GLboolean savageIsTextureResident( GLcontext *ctx,
void savageDDInitTextureFuncs( GLcontext *ctx )
{
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+ if (imesa->savageScreen->chipset <= S3_SAVAGE4) {
+ GetTiledCoordinates16 = GetTiledCoordinates16_4;
+ GetTiledCoordinates32 = GetTiledCoordinates32_4;
+ } else {
+ GetTiledCoordinates16 = GetTiledCoordinates16_8;
+ GetTiledCoordinates32 = GetTiledCoordinates32_8;
+ }
+
ctx->Driver.TexEnv = savageTexEnv;
#if 0
ctx->Driver.TexImage = savageTexImage;
diff --git a/xc/lib/GL/mesa/src/drv/savage/savagetex.h b/xc/lib/GL/mesa/src/drv/savage/savagetex.h
index 2578ca43e..c265bee28 100755
--- a/xc/lib/GL/mesa/src/drv/savage/savagetex.h
+++ b/xc/lib/GL/mesa/src/drv/savage/savagetex.h
@@ -118,11 +118,4 @@ void savageTexturesGone( savageContextPtr imesa, GLuint heap,
void savagePrintLocalLRU( savageContextPtr imesa ,GLuint heap);
void savagePrintGlobalLRU( savageContextPtr imesa ,GLuint heap);
-__inline GLuint GetTiledCoordinates8(GLuint iBufferWidth, GLint x, GLint y);
-__inline GLuint GetTiledCoordinates16( GLint iBufferWidth,GLint x,GLint y );
-__inline GLuint GetTiledCoordinates32( GLint iBufferWidth, GLint x, GLint y );
-__inline GLuint GetTiledCoordinates( GLint iDepth,GLint iBufferWidth,GLint x,GLint y );
-__inline GLubyte * savageMakeTexel(savageTextureObjectPtr t, GLubyte * src, GLubyte * dst, GLuint level);
-__inline void savageUploadImage(savageTextureObjectPtr t, GLuint level, GLuint startx, GLuint starty, GLuint reloc);
-__inline void savageTileTex(savageTextureObjectPtr tex, GLuint level);
#endif