From 5999c5b620236fb6a996cf56759aec31f01c126b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 May 2006 19:14:38 +0000 Subject: Fix a number of texture compression issues. Pass the MESA_FORMAT_* token to the _mesa_compressed_row_stride(), _mesa_compressed_texture_size() and _mesa_compressed_image_address() functions since we want to use the driver-chosen format, not the user's internalFormat hint. Consolidate code related to choosing the texture format in texstoree.c --- src/mesa/main/texcompress_s3tc.c | 64 +++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 24 deletions(-) (limited to 'src/mesa/main/texcompress_s3tc.c') diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index 5a6685e0f3..c572e19e49 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -172,11 +172,13 @@ texstore_rgb_dxt1(STORE_PARAMS) } dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + dstFormat->MesaFormat, texWidth, (GLubyte *) dstAddr); if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, dst, dstRowStride); + (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + dst, dstRowStride); } else { _mesa_problem(ctx, "external dxt library not available"); @@ -232,10 +234,12 @@ texstore_rgba_dxt1(STORE_PARAMS) } dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + dstFormat->MesaFormat, texWidth, (GLubyte *) dstAddr); if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, dst, dstRowStride); + (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + dst, dstRowStride); } else { _mesa_problem(ctx, "external dxt library not available"); @@ -290,10 +294,12 @@ texstore_rgba_dxt3(STORE_PARAMS) } dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + dstFormat->MesaFormat, texWidth, (GLubyte *) dstAddr); if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, dst, dstRowStride); + (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + dst, dstRowStride); } else { _mesa_problem(ctx, "external dxt library not available"); @@ -348,10 +354,12 @@ texstore_rgba_dxt5(STORE_PARAMS) } dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, + dstFormat->MesaFormat, texWidth, (GLubyte *) dstAddr); if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, dst, dstRowStride); + (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, + dst, dstRowStride); } else { _mesa_problem(ctx, "external dxt library not available"); @@ -368,12 +376,14 @@ static void fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { - (void) k; - if (fetch_ext_rgb_dxt1) { - ASSERT (sizeof(GLchan) == sizeof(GLubyte)); - (*fetch_ext_rgb_dxt1)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel); - } - else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n"); + (void) k; + if (fetch_ext_rgb_dxt1) { + ASSERT (sizeof(GLchan) == sizeof(GLubyte)); + fetch_ext_rgb_dxt1(texImage->RowStride, + (GLubyte *)(texImage)->Data, i, j, texel); + } + else + _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n"); } @@ -397,9 +407,11 @@ fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage, { (void) k; if (fetch_ext_rgba_dxt1) { - (*fetch_ext_rgba_dxt1)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel); - } - else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n"); + fetch_ext_rgba_dxt1(texImage->RowStride, + (GLubyte *)(texImage)->Data, i, j, texel); + } + else + _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n"); } @@ -423,10 +435,12 @@ fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage, { (void) k; if (fetch_ext_rgba_dxt3) { - ASSERT (sizeof(GLchan) == sizeof(GLubyte)); - (*fetch_ext_rgba_dxt3)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel); - } - else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n"); + ASSERT (sizeof(GLchan) == sizeof(GLubyte)); + fetch_ext_rgba_dxt3(texImage->RowStride, (GLubyte *)(texImage)->Data, + i, j, texel); + } + else + _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n"); } @@ -450,9 +464,11 @@ fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage, { (void) k; if (fetch_ext_rgba_dxt5) { - (*fetch_ext_rgba_dxt5)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel); - } - else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n"); + fetch_ext_rgba_dxt5(texImage->RowStride, (GLubyte *)(texImage)->Data, + i, j, texel); + } + else + _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n"); } -- cgit v1.2.3