summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Borca <dborca@users.sourceforge.net>2003-10-30 11:44:19 +0000
committerDaniel Borca <dborca@users.sourceforge.net>2003-10-30 11:44:19 +0000
commite81b180065f0a9f80c1310ac447509b1debc4559 (patch)
tree9757f3e47b7251c56bb581627453e7768384277f /src
parent63a5ca08f3bdaee975c9b059caf15ffd3ddd8d38 (diff)
bugfixes wrt texture compression
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/glide/fxddtex.c109
-rw-r--r--src/mesa/drivers/glide/fxg.c24
-rw-r--r--src/mesa/drivers/glide/fxg.h2
-rw-r--r--src/mesa/drivers/glide/fxvb.c2
4 files changed, 50 insertions, 87 deletions
diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c
index bfff09aea1..0885dad12c 100644
--- a/src/mesa/drivers/glide/fxddtex.c
+++ b/src/mesa/drivers/glide/fxddtex.c
@@ -857,26 +857,23 @@ PrintTexture(int w, int h, int c, const GLubyte * data)
}
-#define fxDDIsCompressedFormatMacro(internalFormat) (\
- ((internalFormat) == GL_COMPRESSED_RGB_FXT1_3DFX) || \
- ((internalFormat) == GL_COMPRESSED_RGBA_FXT1_3DFX) || \
- ((internalFormat) == GL_COMPRESSED_RGB_S3TC_DXT1_EXT) || \
- ((internalFormat) == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) || \
- ((internalFormat) == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) || \
- ((internalFormat) == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT))
-
-/* [dBorca]
- * we are handling differently the above formats from the generic
- * GL_COMPRESSED_RGB[A]. For this, we will never call the function
- * below! It is just a callback for core functions.
- */
-
GLboolean fxDDIsCompressedFormat ( GLcontext *ctx, GLenum internalFormat )
{
- if (fxDDIsCompressedFormatMacro(internalFormat)) {
+ if ((internalFormat == GL_COMPRESSED_RGB_FXT1_3DFX) ||
+ (internalFormat == GL_COMPRESSED_RGBA_FXT1_3DFX) ||
+ (internalFormat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT) ||
+ (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ||
+ (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) ||
+ (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)) {
return GL_TRUE;
}
+/* [dBorca]
+ * we are handling differently the above formats from the generic
+ * GL_COMPRESSED_RGB[A]. For this, we will always separately
+ * check for the ones below!
+ */
+
#if FX_TC_NCC || FX_TC_NAPALM
if ((internalFormat == GL_COMPRESSED_RGB) || (internalFormat == GL_COMPRESSED_RGBA)) {
return GL_TRUE;
@@ -955,7 +952,6 @@ GLuint fxDDCompressedTextureSize (GLcontext *ctx,
}
#endif
#if FX_TC_NCC
- /* should really use `txBitsPerPixel' instead of 8; also add NCC table */
return (width * height * 8 >> 3) + 12 * 4;
#endif
case GL_COMPRESSED_RGBA:
@@ -968,7 +964,6 @@ GLuint fxDDCompressedTextureSize (GLcontext *ctx,
}
#endif
#if FX_TC_NCC
- /* should really use `txBitsPerPixel' instead of 16; also add NCC table */
return (width * height * 16 >> 3) + 12 * 4;
#endif
default:
@@ -1198,7 +1193,6 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
GLvoid *_final_texImage_Data;
const struct gl_texture_format *_final_texImage_TexFormat;
- GLboolean isCompressed = fxDDIsCompressedFormatMacro(internalFormat);
if (TDFX_DEBUG & VERBOSE_TEXTURE) {
fprintf(stderr, "fxDDTexImage2D: id=%d int 0x%x format 0x%x type 0x%x %dx%d\n",
@@ -1249,23 +1243,19 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
#if FX_TC_NCC || FX_TC_NAPALM
if (internalFormat == GL_COMPRESSED_RGB) {
#if FX_TC_NCC
- isCompressed = GL_TRUE;
mml->glideFormat = GR_TEXFMT_YIQ_422;
#endif
#if FX_TC_NAPALM
if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
- isCompressed = GL_TRUE;
mml->glideFormat = GR_TEXFMT_ARGB_CMP_FXT1;
}
#endif
} else if (internalFormat == GL_COMPRESSED_RGBA) {
#if FX_TC_NCC
- isCompressed = GL_TRUE;
mml->glideFormat = GR_TEXFMT_AYIQ_8422;
#endif
#if FX_TC_NAPALM
if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
- isCompressed = GL_TRUE;
mml->glideFormat = GR_TEXFMT_ARGB_CMP_FXT1;
}
#endif
@@ -1274,7 +1264,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
/* allocate mipmap buffer */
assert(!texImage->Data);
- if (isCompressed) {
+ if (texImage->IsCompressed) {
texImage->Data = MESA_PBUFFER_ALLOC(texImage->CompressedSize);
texelBytes = 4;
_final_texImage_TexFormat = &_mesa_texformat_argb8888;
@@ -1328,7 +1318,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
}
/* now compress */
- if (isCompressed) {
+ if (texImage->IsCompressed) {
#if FX_TC_NCC
if ((mml->glideFormat == GR_TEXFMT_AYIQ_8422) ||
(mml->glideFormat == GR_TEXFMT_YIQ_422)) {
@@ -1438,6 +1428,7 @@ fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
}
else {
/* no rescaling needed */
+ /* [dBorca] Hack alert: compute address of dest subimage within the overal tex image */
_mesa_transfer_teximage(ctx, 2, texImage->Format, /* Tex int format */
texImage->TexFormat, /* dest format */
(GLubyte *) texImage->Data,/* dest */
@@ -1467,10 +1458,8 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
struct gl_texture_image *texImage)
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GrTextureFormat_t gldFormat;
tfxTexInfo *ti;
tfxMipMapLevel *mml;
- GLint dstWidth, dstHeight, wScale, hScale;
if (TDFX_DEBUG & VERBOSE_TEXTURE) {
fprintf(stderr, "fxDDCompressedTexImage2D: id=%d int 0x%x %dx%d\n",
@@ -1478,19 +1467,13 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
width, height);
}
+ assert(texImage->IsCompressed);
+
if (!fxIsTexSupported(target, internalFormat, texImage)) {
_mesa_problem(NULL, "fx Driver: unsupported texture in fxDDCompressedTexImg()\n");
return;
}
-#if FX_TC_NCC || FX_TC_NAPALM
- if ((internalFormat != GL_COMPRESSED_RGB) && (internalFormat != GL_COMPRESSED_RGBA))
-#endif
- if (!fxDDIsCompressedFormatMacro(internalFormat)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage2D(format)");
- return;
- }
-
if (!texObj->DriverData) {
texObj->DriverData = fxAllocTexObjData(fxMesa);
if (!texObj->DriverData) {
@@ -1509,43 +1492,45 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
}
mml = FX_MIPMAP_DATA(texImage);
+ fxTexGetInfo(width, height, NULL, NULL, NULL, NULL,
+ &mml->wScale, &mml->hScale);
+
+ mml->width = width * mml->wScale;
+ mml->height = height * mml->hScale;
+
+
+ /* choose the texture format */
+ assert(ctx->Driver.ChooseTextureFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, format, type);
+ assert(texImage->TexFormat);
+
/* Determine the appropriate Glide texel format,
* given the user's internal texture format hint.
*/
- gldFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
+ mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
#if FX_TC_NCC || FX_TC_NAPALM
if (internalFormat == GL_COMPRESSED_RGB) {
#if FX_TC_NCC
- gldFormat = GR_TEXFMT_YIQ_422;
+ mml->glideFormat = GR_TEXFMT_YIQ_422;
#endif
#if FX_TC_NAPALM
if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
- gldFormat = GR_TEXFMT_ARGB_CMP_FXT1;
+ mml->glideFormat = GR_TEXFMT_ARGB_CMP_FXT1;
}
#endif
} else if (internalFormat == GL_COMPRESSED_RGBA) {
#if FX_TC_NCC
- gldFormat = GR_TEXFMT_AYIQ_8422;
+ mml->glideFormat = GR_TEXFMT_AYIQ_8422;
#endif
#if FX_TC_NAPALM
if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
- gldFormat = GR_TEXFMT_ARGB_CMP_FXT1;
+ mml->glideFormat = GR_TEXFMT_ARGB_CMP_FXT1;
}
#endif
}
#endif
- /* Determine width and height scale factors for texture.
- * Remember, Glide is limited to 8:1 aspect ratios.
- */
- fxTexGetInfo(width, height,
- NULL, /* lod level */
- NULL, /* aspect ratio */
- NULL, NULL, /* sscale, tscale */
- &wScale, &hScale);
- dstWidth = width * wScale;
- dstHeight = height * hScale;
-
/* allocate new storage for texture image, if needed */
if (!texImage->Data) {
texImage->Data = MESA_PBUFFER_ALLOC(imageSize);
@@ -1558,8 +1543,8 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
/* save the texture data */
MEMCPY(texImage->Data, data, imageSize);
#if FX_TC_NCC
- if ((gldFormat == GR_TEXFMT_AYIQ_8422) ||
- (gldFormat == GR_TEXFMT_YIQ_422)) {
+ if ((mml->glideFormat == GR_TEXFMT_AYIQ_8422) ||
+ (mml->glideFormat == GR_TEXFMT_YIQ_422)) {
MEMCPY(&(ti->palette), (char *)texImage->Data + imageSize - 12 * 4, 12 * 4);
}
#endif
@@ -1567,16 +1552,20 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
/* [dBorca] Hack alert:
* what about different size/texel? other anomalies? SW rescaling?
*/
- if (1 || mml->glideFormat != gldFormat ||
- mml->width != dstWidth || mml->height != dstHeight ||
- !ti->validated || !ti->isInTM || (fxMesa->new_state & FX_NEW_TEXTURING)) {
- mml->glideFormat = gldFormat;
- mml->width = dstWidth;
- mml->height = dstHeight;
- fxTexInvalidate(ctx, texObj);
- } else {
+ ti->info.format = mml->glideFormat;
+ texImage->FetchTexel = fxFetchFunction(texImage->TexFormat->MesaFormat);
+
+ /* [dBorca]
+ * Hack alert: unsure...
+ */
+ if (0 && ti->validated && ti->isInTM) {
+ /*fprintf(stderr, "reloadmipmaplevels\n"); */
fxTMReloadMipMapLevel(fxMesa, texObj, level);
}
+ else {
+ /*fprintf(stderr, "invalidate2\n"); */
+ fxTexInvalidate(ctx, texObj);
+ }
}
diff --git a/src/mesa/drivers/glide/fxg.c b/src/mesa/drivers/glide/fxg.c
index 1ead397fdd..7d39ddbe5f 100644
--- a/src/mesa/drivers/glide/fxg.c
+++ b/src/mesa/drivers/glide/fxg.c
@@ -41,11 +41,9 @@
#include "fxg.h"
/* texus.h */
-FX_ENTRY int FX_CALL txBitsPerPixel (GrTextureFormat_t format);
FX_ENTRY void FX_CALL txImgQuantize (char *dst, char *src, int w, int h, FxU32 format, FxU32 dither);
FX_ENTRY void FX_CALL txMipQuantize (TxMip *pxMip, TxMip *txMip, int fmt, FxU32 d, FxU32 comp);
FX_ENTRY void FX_CALL txPalToNcc (GuNccTable *ncc_table, const FxU32 *pal);
-FX_ENTRY void FX_CALL txErrorSetCallback (TxErrorCallbackFnc_t fnc, TxErrorCallbackFnc_t *old_fnc);
/* texus.h */
@@ -2160,17 +2158,6 @@ void FX_CALL trap_grTBufferWriteMaskExt (FxU32 tmask)
/*
** texus functions
*/
-int FX_CALL trap_txBitsPerPixel (GrTextureFormat_t format)
-{
-#define FN_NAME "txBitsPerPixel"
- int rv;
- TRAP_LOG("%s(%s)\n", FN_NAME, TRP_TEXFMT(format));
- rv = txBitsPerPixel(format);
- TRAP_LOG(GOT "%d\n", rv);
- return rv;
-#undef FN_NAME
-}
-
void FX_CALL trap_txImgQuantize (char *dst,
char *src,
int w,
@@ -2204,15 +2191,6 @@ void FX_CALL trap_txPalToNcc (GuNccTable *ncc_table,
txPalToNcc(ncc_table, pal);
#undef FN_NAME
}
-
-void FX_CALL trap_txErrorSetCallback (TxErrorCallbackFnc_t fnc,
- TxErrorCallbackFnc_t *old_fnc)
-{
-#define FN_NAME "txErrorSetCallback"
- TRAP_LOG("%s(%p, %p)\n", FN_NAME, (void *)fnc, (void *)old_fnc);
- txErrorSetCallback(fnc, old_fnc);
-#undef FN_NAME
-}
#endif
@@ -2293,11 +2271,9 @@ void tdfx_hook_glide (struct tdfx_glide *Glide)
/*
** texus
*/
- GET_TXS_ADDR(txBitsPerPixel);
GET_TXS_ADDR(txImgQuantize);
GET_TXS_ADDR(txMipQuantize);
GET_TXS_ADDR(txPalToNcc);
- GET_TXS_ADDR(txErrorSetCallback);
/* housekeeping: make sure the pointcast always point to something valid */
if (grGetProcAddress("grTexDownloadTableExt") == NULL) {
diff --git a/src/mesa/drivers/glide/fxg.h b/src/mesa/drivers/glide/fxg.h
index cae63cb69f..2841bab16c 100644
--- a/src/mesa/drivers/glide/fxg.h
+++ b/src/mesa/drivers/glide/fxg.h
@@ -371,11 +371,9 @@ struct tdfx_glide {
/*
** Texus2 functions
*/
- int (FX_CALL *txBitsPerPixel) (GrTextureFormat_t format);
void (FX_CALL *txImgQuantize) (char *dst, char *src, int w, int h, FxU32 format, FxU32 dither);
void (FX_CALL *txMipQuantize) (TxMip *pxMip, TxMip *txMip, int fmt, FxU32 d, FxU32 comp);
void (FX_CALL *txPalToNcc) (GuNccTable *ncc_table, const FxU32 *pal);
- void (FX_CALL *txErrorSetCallback) (TxErrorCallbackFnc_t fnc, TxErrorCallbackFnc_t *old_fnc);
};
void tdfx_hook_glide (struct tdfx_glide *Glide);
diff --git a/src/mesa/drivers/glide/fxvb.c b/src/mesa/drivers/glide/fxvb.c
index c8d6495f54..2d9f73d6a8 100644
--- a/src/mesa/drivers/glide/fxvb.c
+++ b/src/mesa/drivers/glide/fxvb.c
@@ -393,7 +393,7 @@ void fxFreeVB( GLcontext *ctx )
}
if (fxMesa->UbyteColor.Ptr) {
- ALIGN_FREE(fxMesa->UbyteColor.Ptr);
+ ALIGN_FREE((void *)fxMesa->UbyteColor.Ptr);
fxMesa->UbyteColor.Ptr = 0;
}
}