summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorDaniel Borca <dborca@users.sourceforge.net>2004-05-10 07:42:26 +0000
committerDaniel Borca <dborca@users.sourceforge.net>2004-05-10 07:42:26 +0000
commit39fe9a7fe38081d6f40c4bf388a132c583330912 (patch)
treed758eb50d57c882b1f1759a86a0c952eadec88c2 /src/mesa
parent1cbee9c159384e210e7dbbe0f5acd9d78cf4ce23 (diff)
fixed bugs in fxddtex.c
cleaned up win32 definition files
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/glide/fxdd.c24
-rw-r--r--src/mesa/drivers/glide/fxddtex.c441
-rw-r--r--src/mesa/drivers/glide/fxdrv.h7
-rw-r--r--src/mesa/drivers/glide/fxsetup.c2
-rw-r--r--src/mesa/drivers/windows/gdi/mesa.def1
-rw-r--r--src/mesa/glapi/mesadef.py3
-rw-r--r--src/mesa/main/mesa.def1
7 files changed, 261 insertions, 218 deletions
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index 106c7d0e07..ffebcdae46 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -1485,21 +1485,14 @@ fxDDInitExtensions(GLcontext * ctx)
* fake NCC multitexturing through multipass rendering, but...
* ohwell, it's not worth the effort...
* This stand true for multitexturing palletized textures.
- * 3) since NCC is not an OpenGL standard (as opposed to FXT1), we
- * would need to plug deeper into the core... First, we would need to
- * bind NCC to GL_COMPRESSED_RGB[A]. Then, we would need to trick
- * Mesa into reporting our texture as compressed. Last, we would need
- * to stash the NCC decompression table into the mipmap data and adjust
- * CompressedSize accordingly!
+ * 3) since NCC is not an OpenGL standard (as opposed to FXT1/DXTC), we
+ * can't use precompressed textures!
*/
- if (fxMesa->HaveTexus2) {
- _mesa_enable_extension(ctx, "GL_ARB_texture_compression");
-
- if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
- _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
- _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
- _mesa_enable_extension(ctx, "GL_S3_s3tc");
- }
+ _mesa_enable_extension(ctx, "GL_ARB_texture_compression");
+ if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
+ _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
+ _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
+ _mesa_enable_extension(ctx, "GL_S3_s3tc");
}
if (fxMesa->HaveCmbExt) {
@@ -1517,7 +1510,7 @@ fxDDInitExtensions(GLcontext * ctx)
/* core-level extensions */
#if 0
/* not until texel fetchers are right */
- _mesa_enable_extension(ctx, "GL_SGIS_generate_mipmaps");
+ _mesa_enable_extension(ctx, "GL_SGIS_generate_mipmap");
#endif
#if 0
/* breaks UT2004 */
@@ -1727,6 +1720,7 @@ fxSetupDDPointers(GLcontext * ctx)
ctx->Driver.ChooseTextureFormat = fxDDChooseTextureFormat;
ctx->Driver.TexImage1D = fxDDTexImage1D;
ctx->Driver.TexImage2D = fxDDTexImage2D;
+ ctx->Driver.TexSubImage1D = fxDDTexSubImage1D;
ctx->Driver.TexSubImage2D = fxDDTexSubImage2D;
ctx->Driver.CompressedTexImage2D = fxDDCompressedTexImage2D;
ctx->Driver.CompressedTexSubImage2D = fxDDCompressedTexSubImage2D;
diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c
index b0deb252b5..c2d4af9d7d 100644
--- a/src/mesa/drivers/glide/fxddtex.c
+++ b/src/mesa/drivers/glide/fxddtex.c
@@ -170,10 +170,13 @@ fxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
/* apply any lod biasing right now */
if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
- grTexLodBiasValue(GR_TMU0, *param);
+ GLfloat bias = *param;
+ CLAMP_SELF(bias, -8.0, 7.75);
+
+ grTexLodBiasValue(GR_TMU0, bias);
if (fxMesa->haveTwoTMUs) {
- grTexLodBiasValue(GR_TMU1, *param);
+ grTexLodBiasValue(GR_TMU1, bias);
}
}
@@ -923,7 +926,6 @@ GLuint fxDDCompressedTextureSize (GLcontext *ctx,
GLsizei width, GLsizei height, GLsizei depth,
GLenum format)
{
- GLuint size;
int wScale, hScale;
ASSERT(depth == 1);
@@ -937,43 +939,9 @@ GLuint fxDDCompressedTextureSize (GLcontext *ctx,
NULL, NULL, /* sscale, tscale */
&wScale, &hScale);
- width *= wScale;
- height *= hScale;
-
-#if FX_TC_NAPALM || FX_TC_NCC
- switch (format) {
- case GL_COMPRESSED_RGB:
-#if FX_TC_NAPALM
- {
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
- format = GL_COMPRESSED_RGB_FXT1_3DFX;
- break;
- }
- }
-#endif
-#if FX_TC_NCC
- return (width * height * 8 >> 3) + 12 * 4;
-#endif
- case GL_COMPRESSED_RGBA:
-#if FX_TC_NAPALM
- {
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
- format = GL_COMPRESSED_RGBA_FXT1_3DFX;
- break;
- }
- }
-#endif
-#if FX_TC_NCC
- return (width * height * 16 >> 3) + 12 * 4;
-#endif
- }
-#endif
-
return _mesa_compressed_texture_size(ctx,
- width,
- height,
+ width * wScale,
+ height * hScale,
depth,
format);
}
@@ -992,12 +960,10 @@ fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
switch (internalFormat) {
case GL_COMPRESSED_RGB:
-#if 0 && FX_TC_NAPALM /* [koolsmoky] */
- if (ctx->Extensions.TDFX_texture_compression_FXT1) {
- return &_mesa_texformat_rgb_fxt1;
- } else if (ctx->Extensions.EXT_texture_compression_s3tc) {
- return &_mesa_texformat_rgb_dxt1;
- }
+#if FX_TC_NCC
+ if (fxMesa->HaveTexus2) {
+ return &_mesa_texformat_argb8888;
+ }
#endif
/* intentional fall through */
case 3:
@@ -1016,12 +982,10 @@ fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_RGBA4:
return &_mesa_texformat_argb4444;
case GL_COMPRESSED_RGBA:
-#if 0 && FX_TC_NAPALM /* [koolsmoky] */
- if (ctx->Extensions.TDFX_texture_compression_FXT1) {
- return &_mesa_texformat_rgba_fxt1;
- } else if (ctx->Extensions.EXT_texture_compression_s3tc) {
- return &_mesa_texformat_rgba_dxt3;
- }
+#if FX_TC_NCC
+ if (fxMesa->HaveTexus2) {
+ return &_mesa_texformat_argb8888;
+ }
#endif
/* intentional fall through */
case 4:
@@ -1195,6 +1159,87 @@ fxFetchFunction(GLint mesaFormat)
}
}
+
+static GLboolean
+adjust2DRatio (GLcontext *ctx,
+ GLint xoffset, GLint yoffset,
+ GLint width, GLint height,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ tfxMipMapLevel *mml,
+ struct gl_texture_image *texImage,
+ GLint texelBytes,
+ GLint dstRowStride)
+{
+ const GLint newWidth = width * mml->wScale;
+ const GLint newHeight = height * mml->hScale;
+ GLvoid *tempImage;
+
+ if (!texImage->IsCompressed) {
+ GLubyte *destAddr;
+ tempImage = MALLOC(width * height * texelBytes);
+ if (!tempImage) {
+ return GL_FALSE;
+ }
+
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, tempImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * texelBytes, /* dstRowStride */
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+
+ /* now rescale */
+ /* compute address of dest subimage within the overal tex image */
+ destAddr = (GLubyte *) texImage->Data
+ + (yoffset * mml->hScale * mml->width
+ + xoffset * mml->wScale) * texelBytes;
+
+ _mesa_rescale_teximage2d(texelBytes,
+ dstRowStride, /* dst stride */
+ width, height,
+ newWidth, newHeight,
+ tempImage, destAddr);
+ } else {
+ const GLint rawBytes = 4;
+ GLvoid *rawImage = MALLOC(width * height * rawBytes);
+ if (!rawImage) {
+ return GL_FALSE;
+ }
+ tempImage = MALLOC(newWidth * newHeight * rawBytes);
+ if (!tempImage) {
+ return GL_FALSE;
+ }
+ /* unpack image, apply transfer ops and store in rawImage */
+ _mesa_texstore_argb8888(ctx, 2, GL_RGBA,
+ &_mesa_texformat_argb8888, rawImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * rawBytes, /* dstRowStride */
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+ _mesa_rescale_teximage2d(rawBytes,
+ newWidth * rawBytes, /* dst stride */
+ width, height, /* src */
+ newWidth, newHeight, /* dst */
+ rawImage /*src*/, tempImage /*dst*/ );
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, texImage->Data,
+ xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ 0, /* dstImageStride */
+ newWidth, newHeight, 1,
+ GL_BGRA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
+ FREE(rawImage);
+ }
+
+ FREE(tempImage);
+
+ return GL_TRUE;
+}
+
+
void
fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
GLint internalFormat, GLint width, GLint height, GLint border,
@@ -1258,14 +1303,34 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
case GL_RGB4_S3TC:
internalFormat = GL_COMPRESSED_RGB_FXT1_3DFX;
break;
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
case GL_RGBA_S3TC:
case GL_RGBA4_S3TC:
+ texImage->CompressedSize /= 2;
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
internalFormat = GL_COMPRESSED_RGBA_FXT1_3DFX;
- texImage->CompressedSize *= 2;
}
+ texImage->IntFormat = internalFormat;
+ }
+#endif
+#if FX_TC_NAPALM
+ if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
+ GLenum texNapalm = 0;
+ if (internalFormat == GL_COMPRESSED_RGB) {
+ texNapalm = GL_COMPRESSED_RGB_FXT1_3DFX;
+ } else if (internalFormat == GL_COMPRESSED_RGBA) {
+ texNapalm = GL_COMPRESSED_RGBA_FXT1_3DFX;
+ }
+ if (texNapalm) {
+ texImage->IntFormat = internalFormat = texNapalm;
+ texImage->IsCompressed = GL_TRUE;
+ texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
+ mml->width,
+ mml->height,
+ 1,
+ texNapalm);
+ }
}
#endif
@@ -1278,9 +1343,6 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
/*if (!fxMesa->HaveTexFmt) assert(texelBytes == 1 || texelBytes == 2);*/
mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
- /* [dBorca] ZYX: how do we handle FX_TC_NCC/FX_TC_NAPALM? */
- /* [dBorca] ZYX: how do we handle S3TC outside MESA?!?!?! */
- /* [dBorca] ZYX: how do we handle aspectratio adjustemnt? */
/* allocate mipmap buffer */
assert(!texImage->Data);
@@ -1298,73 +1360,19 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
if (mml->wScale != 1 || mml->hScale != 1) {
/* rescale image to overcome 1:8 aspect limitation */
- GLvoid *tempImage;
- if (texImage->IsCompressed) {
- /* [dBorca] worst case:
- * we have to rescale a compressed texture
- * first, we unpack the image to RGBA, doing transfer ops
- * next, we rescale the image
- * last, we compress
- * hint: too heavy-handed; also may unpack/transferop twice
- */
- const GLint rgbaBytes = 4;
- GLvoid *rgbaImage = MALLOC(width * height * rgbaBytes);
- if (!rgbaImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
- return;
- }
- tempImage = MALLOC(mml->width * mml->height * rgbaBytes);
- if (!tempImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
- return;
- }
- /* unpack image, apply transfer ops and store in rgbaImage */
- _mesa_texstore_argb8888(ctx, 2, texImage->Format,
- &_mesa_texformat_argb8888, rgbaImage,
- 0, 0, 0, /* dstX/Y/Zoffset */
- width * rgbaBytes, /* dstRowStride */
- 0, /* dstImageStride */
- width, height, 1,
- format, type, pixels, packing);
- _mesa_rescale_teximage2d(rgbaBytes,
- mml->width * rgbaBytes, /* dst stride */
- width, height, /* src */
- mml->width, mml->height, /* dst */
- rgbaImage /*src*/, tempImage /*dst*/ );
- texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
- texImage->TexFormat, texImage->Data,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- 0, /* dstImageStride */
- mml->width, mml->height, 1,
- GL_BGRA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
- FREE(rgbaImage);
- } else {
- /* [dBorca] mild case:
- * we have to rescale a texture
- * first, we unpack the image, doing transfer ops
- * last, we rescale the image
- */
- tempImage = MALLOC(width * height * texelBytes);
- if (!tempImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
- return;
- }
- /* unpack image, apply transfer ops and store in tempImage */
- texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
- texImage->TexFormat, tempImage,
- 0, 0, 0, /* dstX/Y/Zoffset */
- width * texelBytes, /* dstRowStride */
- 0, /* dstImageStride */
- width, height, 1,
- format, type, pixels, packing);
- _mesa_rescale_teximage2d(texelBytes,
- mml->width * texelBytes, /* dst stride */
- width, height, /* src */
- mml->width, mml->height, /* dst */
- tempImage /*src*/, texImage->Data /*dst*/ );
+ if (!adjust2DRatio(ctx,
+ 0, 0,
+ width, height,
+ format, type, pixels,
+ packing,
+ mml,
+ texImage,
+ texelBytes,
+ dstRowStride)
+ ) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
}
- FREE(tempImage);
}
else {
/* no rescaling needed */
@@ -1377,10 +1385,52 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
width, height, 1,
format, type, pixels, packing);
}
+#if FX_TC_NCC
+ if (fxMesa->HaveTexus2) {
+ GLenum texNCC = 0;
+ GLuint texSize = mml->width * mml->height;
+ if (internalFormat == GL_COMPRESSED_RGB) {
+ texNCC = GR_TEXFMT_YIQ_422;
+ } else if (internalFormat == GL_COMPRESSED_RGBA) {
+ texNCC = GR_TEXFMT_AYIQ_8422;
+ texSize <<= 1;
+ }
+ if (texNCC) {
+ TxMip txMip, pxMip;
+ GLubyte *tempImage = MESA_PBUFFER_ALLOC(texSize);
+ if (!tempImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ txMip.width = mml->width;
+ txMip.height = mml->height;
+ txMip.depth = 1;
+ txMip.data[0] = texImage->Data;
+ pxMip.data[0] = tempImage;
+ fxMesa->Glide.txMipQuantize(&pxMip, &txMip, texNCC, TX_DITHER_ERR, TX_COMPRESSION_HEURISTIC);
+ if (level == 0) {
+ fxMesa->Glide.txPalToNcc((GuNccTable *)(&(ti->palette)), pxMip.pal);
+ }
+ MESA_PBUFFER_FREE(texImage->Data);
+ texImage->Data = tempImage;
+ mml->glideFormat = texNCC;
+ }
+ }
+#endif
ti->info.format = mml->glideFormat;
texImage->FetchTexelc = fxFetchFunction(texImage->TexFormat->MesaFormat);
+ /* [dBorca] take care of aspectratio */
+#if 0
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
+ }
+#endif
+
/* [dBorca]
* Hack alert: unsure...
*/
@@ -1407,10 +1457,10 @@ fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
fxMesaContext fxMesa = FX_CONTEXT(ctx);
tfxTexInfo *ti;
tfxMipMapLevel *mml;
- GLint texelBytes;
+ GLint texelBytes, dstRowStride;
/* [dBorca] Hack alert:
- * fix the goddamn texture compression here
+ * FX_TC_NCC not supported
*/
if (TDFX_DEBUG & VERBOSE_TEXTURE) {
@@ -1431,47 +1481,34 @@ fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
assert(texImage->Format);
texelBytes = texImage->TexFormat->TexelBytes;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat, mml->width);
+ } else {
+ dstRowStride = mml->width * texelBytes;
+ }
if (mml->wScale != 1 || mml->hScale != 1) {
/* need to rescale subimage to match mipmap level's rescale factors */
- const GLint newWidth = width * mml->wScale;
- const GLint newHeight = height * mml->hScale;
- GLvoid *tempImage;
- GLubyte *destAddr;
- tempImage = MALLOC(width * height * texelBytes);
- if (!tempImage) {
+ if (!adjust2DRatio(ctx,
+ xoffset, yoffset,
+ width, height,
+ format, type, pixels,
+ packing,
+ mml,
+ texImage,
+ texelBytes,
+ dstRowStride)
+ ) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
return;
}
-
- texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
- texImage->TexFormat, tempImage,
- 0, 0, 0, /* dstX/Y/Zoffset */
- width * texelBytes, /* dstRowStride */
- 0, /* dstImageStride */
- width, height, 1,
- format, type, pixels, packing);
-
- /* now rescale */
- /* compute address of dest subimage within the overal tex image */
- destAddr = (GLubyte *) texImage->Data
- + (yoffset * mml->hScale * mml->width
- + xoffset * mml->wScale) * texelBytes;
-
- _mesa_rescale_teximage2d(texelBytes,
- mml->width * texelBytes, /* dst stride */
- width, height,
- newWidth, newHeight,
- tempImage, destAddr);
-
- FREE(tempImage);
}
else {
/* no rescaling needed */
texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
texImage->TexFormat, (GLubyte *) texImage->Data,
xoffset, yoffset, 0, /* dstX/Y/Zoffset */
- mml->width * texelBytes, /* dstRowStride */
+ dstRowStride,
0, /* dstImageStride */
width, height, 1,
format, type, pixels, packing);
@@ -1547,27 +1584,6 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
* given the user's internal texture format hint.
*/
mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
-#if FX_TC_NCC || FX_TC_NAPALM
- if (internalFormat == GL_COMPRESSED_RGB) {
-#if FX_TC_NCC
- mml->glideFormat = GR_TEXFMT_YIQ_422;
-#endif
-#if FX_TC_NAPALM
- if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
- mml->glideFormat = GR_TEXFMT_ARGB_CMP_FXT1;
- }
-#endif
- } else if (internalFormat == GL_COMPRESSED_RGBA) {
-#if FX_TC_NCC
- mml->glideFormat = GR_TEXFMT_AYIQ_8422;
-#endif
-#if FX_TC_NAPALM
- if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
- mml->glideFormat = GR_TEXFMT_ARGB_CMP_FXT1;
- }
-#endif
- }
-#endif
/* allocate new storage for texture image, if needed */
if (!texImage->Data) {
@@ -1580,19 +1596,26 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
/* save the texture data */
MEMCPY(texImage->Data, data, imageSize);
-#if FX_TC_NCC
- if ((mml->glideFormat == GR_TEXFMT_AYIQ_8422) ||
- (mml->glideFormat == GR_TEXFMT_YIQ_422)) {
- MEMCPY(&(ti->palette.data[16]), (char *)data + imageSize - 12 * 4, 12 * 4);
- }
-#endif
+ /* [dBorca] Hack alert:
+ * in order to account for apect ratio and other anomalies,
+ * we would need to decompress the image. Note, however that
+ * certain rescaling factors (x4, x8) can be treated simpler
+ * if they match the compressed texture microtile size.
+ * Cheeky idea: use textureBuffer to decompress in hardware!
+ */
ti->info.format = mml->glideFormat;
texImage->FetchTexelc = fxFetchFunction(texImage->TexFormat->MesaFormat);
- /* [dBorca] Hack alert:
- * what about different size/texel? other anomalies? SW rescaling?
- */
+ /* [dBorca] take care of aspectratio */
+#if 0
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
+ }
+#endif
/* [dBorca]
* Hack alert: unsure...
@@ -1620,6 +1643,9 @@ fxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
fxMesaContext fxMesa = FX_CONTEXT(ctx);
tfxTexInfo *ti;
tfxMipMapLevel *mml;
+ GLint destRowStride, srcRowStride;
+ GLint i, rows;
+ GLubyte *dest;
if (TDFX_DEBUG & VERBOSE_TEXTURE) {
fprintf(stderr, "fxDDCompressedTexSubImage2D: id=%d\n", texObj->Name);
@@ -1630,25 +1656,26 @@ fxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
mml = FX_MIPMAP_DATA(texImage);
assert(mml);
- /*
- * We punt if we are not replacing the entire image. This
- * is allowed by the spec.
- *
- * [dBorca] Hack alert:
- * ohwell, we should NOT! Look into _mesa_store_compressed_texsubimage2d
- * on how to calculate the sub-image.
- */
- if ((xoffset != 0) && (yoffset != 0)
- && (width != texImage->Width)
- && (height != texImage->Height)) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexSubImage2D(CHICKEN)");
- return;
+ srcRowStride = _mesa_compressed_row_stride(texImage->IntFormat, width);
+
+ destRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ texImage->Width);
+ dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
+ texImage->IntFormat,
+ texImage->Width,
+ (GLubyte*) texImage->Data);
+
+ rows = height / 4; /* [dBorca] hardcoded 4, but works for FXT1/DXTC */
+
+ for (i = 0; i < rows; i++) {
+ MEMCPY(dest, data, srcRowStride);
+ dest += destRowStride;
+ data = (GLvoid *)((GLuint)data + (GLuint)srcRowStride);
}
/* [dBorca] Hack alert:
- * what about different size/texel? other anomalies? SW rescaling?
+ * see fxDDCompressedTexImage2D for caveats
*/
- MEMCPY(texImage->Data, data, imageSize);
/* [dBorca]
* Hack alert: unsure...
@@ -1677,6 +1704,24 @@ fxDDTexImage1D (GLcontext *ctx, GLenum target, GLint level,
}
+void
+fxDDTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
+ GLint xoffset,
+ GLsizei width,
+ GLenum format, GLenum type, const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ fxDDTexSubImage2D(ctx, target, level,
+ xoffset, 0, width, 1,
+ format, type, pixels,
+ packing,
+ texObj,
+ texImage);
+}
+
+
GLboolean
fxDDTestProxyTexImage (GLcontext *ctx, GLenum target,
GLint level, GLint internalFormat,
diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h
index a4ad247c50..37612a55ac 100644
--- a/src/mesa/drivers/glide/fxdrv.h
+++ b/src/mesa/drivers/glide/fxdrv.h
@@ -613,6 +613,13 @@ extern void fxDDTexImage1D(GLcontext * ctx, GLenum target, GLint level,
const struct gl_pixelstore_attrib *packing,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage);
+extern void fxDDTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
+ GLint xoffset, GLint width,
+ GLenum format, GLenum type,
+ const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
extern GLboolean fxDDTestProxyTexImage (GLcontext *ctx, GLenum target,
GLint level, GLint internalFormat,
GLenum format, GLenum type,
diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c
index da4dc2c83c..5b09dce24f 100644
--- a/src/mesa/drivers/glide/fxsetup.c
+++ b/src/mesa/drivers/glide/fxsetup.c
@@ -1323,7 +1323,7 @@ fxDDBlendFuncSeparate(GLcontext * ctx, GLenum sfactor, GLenum dfactor, GLenum as
* It indicates whether we really have HW alpha buffer...
*/
-/*
+/* Use the text below to implement GL_NV_blend_square!
When the value A_COLOR is selected as the destination alpha blending factor,
the source pixel color is used as the destination blending factor. When the
value A_COLOR is selected as the source alpha blending factor, the destination
diff --git a/src/mesa/drivers/windows/gdi/mesa.def b/src/mesa/drivers/windows/gdi/mesa.def
index 5eb834cbe0..a393149b0a 100644
--- a/src/mesa/drivers/windows/gdi/mesa.def
+++ b/src/mesa/drivers/windows/gdi/mesa.def
@@ -976,7 +976,6 @@ EXPORTS
_ac_InvalidateState
_glapi_get_context
_glapi_get_proc_address
- _mesa_base_compressed_texformat
_mesa_buffer_data
_mesa_buffer_map
_mesa_buffer_subdata
diff --git a/src/mesa/glapi/mesadef.py b/src/mesa/glapi/mesadef.py
index 09fc82f531..7aa2776ca4 100644
--- a/src/mesa/glapi/mesadef.py
+++ b/src/mesa/glapi/mesadef.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-# $Id: mesadef.py,v 1.1 2004/01/14 17:45:24 kschultz Exp $
+# $Id: mesadef.py,v 1.2 2004/05/10 07:42:27 dborca Exp $
# Mesa 3-D graphics library
# Version: 4.1
@@ -110,7 +110,6 @@ def PrintTail():
print '\t_ac_InvalidateState'
print '\t_glapi_get_context'
print '\t_glapi_get_proc_address'
- print '\t_mesa_base_compressed_texformat'
print '\t_mesa_buffer_data'
print '\t_mesa_buffer_map'
print '\t_mesa_buffer_subdata'
diff --git a/src/mesa/main/mesa.def b/src/mesa/main/mesa.def
index 0ce2f6a4e2..b0c9ab3ca1 100644
--- a/src/mesa/main/mesa.def
+++ b/src/mesa/main/mesa.def
@@ -444,7 +444,6 @@ EXPORTS
_mesa_store_compressed_teximage2d
_mesa_store_compressed_teximage1d
_mesa_choose_tex_format
- _mesa_base_compressed_texformat
_mesa_compressed_texture_size
_swrast_ReadPixels
_swrast_DrawPixels