--- src/mesa/main/texcompress_s3tc.c | 193 ++++++++++++-------------------------- 1 files changed, 59 insertions(+), 134 deletions(-)
diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index 25257ec..8ab688a 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -29,14 +29,9 @@ * GL_EXT_texture_compression_s3tc support. */ -#ifndef USE_EXTERNAL_DXTN_LIB -#define USE_EXTERNAL_DXTN_LIB 1 -#endif - #include "glheader.h" #include "imports.h" #include "colormac.h" -#include "dlopen.h" #include "image.h" #include "macros.h" #include "mfeatures.h" @@ -44,21 +39,11 @@ #include "texcompress.h" #include "texcompress_s3tc.h" #include "texstore.h" +#include "txc_dxtn.h" #if FEATURE_texture_s3tc - -#if defined(_WIN32) || defined(WIN32) -#define DXTN_LIBNAME "dxtn.dll" -#define RTLD_LAZY 0 -#define RTLD_GLOBAL 0 -#elif defined(__DJGPP__) -#define DXTN_LIBNAME "dxtn.dxe" -#else -#define DXTN_LIBNAME "libtxc_dxtn.so" -#endif - #if FEATURE_EXT_texture_sRGB /** * Convert an 8-bit sRGB value from non-linear space to a @@ -88,72 +73,18 @@ nonlinear_to_linear(GLubyte cs8) } #endif /* FEATURE_EXT_texture_sRGB */ -typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut ); - -dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL; -dxtFetchTexelFuncExt fetch_ext_rgba_dxt1 = NULL; -dxtFetchTexelFuncExt fetch_ext_rgba_dxt3 = NULL; -dxtFetchTexelFuncExt fetch_ext_rgba_dxt5 = NULL; - -typedef void (*dxtCompressTexFuncExt)(GLint srccomps, GLint width, - GLint height, const GLchan *srcPixData, - GLenum destformat, GLubyte *dest, - GLint dstRowStride); - -static dxtCompressTexFuncExt ext_tx_compress_dxtn = NULL; - -static void *dxtlibhandle = NULL; - void _mesa_init_texture_s3tc( struct gl_context *ctx ) { /* called during context initialization */ +#ifndef ENABLE_PATENTED ctx->Mesa_DXTn = GL_FALSE; -#if USE_EXTERNAL_DXTN_LIB - if (!dxtlibhandle) { - dxtlibhandle = _mesa_dlopen(DXTN_LIBNAME, 0); - if (!dxtlibhandle) { - _mesa_warning(ctx, "couldn't open " DXTN_LIBNAME ", software DXTn " - "compression/decompression unavailable"); - } - else { - /* the fetch functions are not per context! Might be problematic... */ - fetch_ext_rgb_dxt1 = (dxtFetchTexelFuncExt) - _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgb_dxt1"); - fetch_ext_rgba_dxt1 = (dxtFetchTexelFuncExt) - _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt1"); - fetch_ext_rgba_dxt3 = (dxtFetchTexelFuncExt) - _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt3"); - fetch_ext_rgba_dxt5 = (dxtFetchTexelFuncExt) - _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt5"); - ext_tx_compress_dxtn = (dxtCompressTexFuncExt) - _mesa_dlsym(dxtlibhandle, "tx_compress_dxtn"); - - if (!fetch_ext_rgb_dxt1 || - !fetch_ext_rgba_dxt1 || - !fetch_ext_rgba_dxt3 || - !fetch_ext_rgba_dxt5 || - !ext_tx_compress_dxtn) { - _mesa_warning(ctx, "couldn't reference all symbols in " - DXTN_LIBNAME ", software DXTn compression/decompression " - "unavailable"); - fetch_ext_rgb_dxt1 = NULL; - fetch_ext_rgba_dxt1 = NULL; - fetch_ext_rgba_dxt3 = NULL; - fetch_ext_rgba_dxt5 = NULL; - ext_tx_compress_dxtn = NULL; - _mesa_dlclose(dxtlibhandle); - dxtlibhandle = NULL; - } - } - } - if (dxtlibhandle) { - ctx->Mesa_DXTn = GL_TRUE; - } -#else - (void) ctx; -#endif + _mesa_warning(ctx, "mesa compiled without --enable-patented, " + "software DXTn compression/decompression unavailable\n"); +#else /* ENABLE_PATENTED */ + ctx->Mesa_DXTn = GL_TRUE; +#endif /* ENABLE_PATENTED */ } /** @@ -203,14 +134,13 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) dstFormat, texWidth, (GLubyte *) dstAddr); - if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels, - GL_COMPRESSED_RGB_S3TC_DXT1_EXT, - dst, dstRowStride); - } - else { - _mesa_warning(ctx, "external dxt library not available: texstore_rgb_dxt1"); - } +#ifdef ENABLE_PATENTED + tx_compress_dxtn(3, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + dst, dstRowStride); +#else /* ENABLE_PATENTED */ + _mesa_warning(ctx, "texstore_rgb_dxt1: mesa compiled without --enable-patented"); +#endif /* ENABLE_PATENTED */ if (tempImage) free((void *) tempImage); @@ -265,14 +195,13 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS) dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, dstFormat, texWidth, (GLubyte *) dstAddr); - if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, - GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, - dst, dstRowStride); - } - else { - _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt1"); - } +#ifdef ENABLE_PATENTED + tx_compress_dxtn(4, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + dst, dstRowStride); +#else /* ENABLE_PATENTED */ + _mesa_warning(ctx, "texstore_rgba_dxt1: mesa compiled without --enable-patented"); +#endif /* ENABLE_PATENTED */ if (tempImage) free((void*) tempImage); @@ -326,14 +255,13 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS) dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, dstFormat, texWidth, (GLubyte *) dstAddr); - if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, - GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, - dst, dstRowStride); - } - else { - _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt3"); - } +#ifdef ENABLE_PATENTED + tx_compress_dxtn(4, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + dst, dstRowStride); +#else /* ENABLE_PATENTED */ + _mesa_warning(ctx, "texstore_rgba_dxt3: mesa compiled without --enable-patented"); +#endif /* ENABLE_PATENTED */ if (tempImage) free((void *) tempImage); @@ -387,14 +315,13 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, dstFormat, texWidth, (GLubyte *) dstAddr); - if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, - GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, - dst, dstRowStride); - } - else { - _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt5"); - } +#ifdef ENABLE_PATENTED + tx_compress_dxtn(4, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, + dst, dstRowStride); +#else /* ENABLE_PATENTED */ + _mesa_warning(ctx, "texstore_rgba_dxt5: mesa compiled without --enable-patented"); +#endif /* ENABLE_PATENTED */ if (tempImage) free((void *) tempImage); @@ -408,13 +335,12 @@ 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: fetch_texel_2d_rgb_dxt1"); +#ifdef ENABLE_PATENTED + fetch_2d_texel_rgb_dxt1(texImage->RowStride, + (GLubyte *)(texImage)->Data, i, j, texel); +#else /* ENABLE_PATENTED */ + _mesa_debug(NULL, "attempted to decode s3tc texture when mesa compiled without --enable-patented: fetch_texel_2d_rgb_dxt1"); +#endif /* ENABLE_PATENTED */ } @@ -437,12 +363,12 @@ fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { (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: fetch_texel_2d_rgba_dxt1\n"); +#ifdef ENABLE_PATENTED + fetch_2d_texel_rgba_dxt1(texImage->RowStride, + (GLubyte *)(texImage)->Data, i, j, texel); +#else /* ENABLE_PATENTED */ + _mesa_debug(NULL, "attempted to decode s3tc texture when mesa compiled without --enable-patented: fetch_texel_2d_rgba_dxt1\n"); +#endif /* ENABLE_PATENTED */ } @@ -465,13 +391,12 @@ fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { (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: fetch_texel_2d_rgba_dxt3\n"); +#ifdef ENABLE_PATENTED + fetch_2d_texel_rgba_dxt3(texImage->RowStride, (GLubyte *)(texImage)->Data, + i, j, texel); +#else /* ENABLE_PATENTED */ + _mesa_debug(NULL, "attempted to decode s3tc texture when mesa compiled without --enable-patented: fetch_texel_2d_rgba_dxt3\n"); +#endif /* ENABLE_PATENTED */ } @@ -494,12 +419,12 @@ fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { (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: fetch_texel_2d_rgba_dxt5\n"); +#ifdef ENABLE_PATENTED + fetch_2d_texel_rgba_dxt5(texImage->RowStride, (GLubyte *)(texImage)->Data, + i, j, texel); +#else /* ENABLE_PATENTED */ + _mesa_debug(NULL, "attempted to decode s3tc texture when mesa compiled without --enable-patented: fetch_texel_2d_rgba_dxt5\n"); +#endif /* ENABLE_PATENTED */ } -- 1.7.3.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev