summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorbin Simpson <MostAwesomeDude@gmail.com>2010-03-29 20:51:39 -0700
committerCorbin Simpson <MostAwesomeDude@gmail.com>2010-03-31 18:55:13 -0700
commita3d6162200013dddbeab1d73d04a4d668f407fb3 (patch)
tree565eb3e7294023d5a62569ff1d52eb1f9f5ada10
parent3623202834e9ca1073a4aa66f72f584812fb14df (diff)
main: Gracefully refuse to compress to DXTC formats without libdxtn.
ARB_texture_compression permits a differing internal format from the requested internal format, if the compression can't be carried out for any reason. Apps should be expected to check the results of their compression request. See issue 10 of ARB_texture_compression for details. Whoo, language lawyering! Respin: Handle both EXT_texture_compression_s3tc and S3_s3tc enums. As if anybody ever touched this extension. Makes the second row of texcmp options work.
-rw-r--r--src/mesa/main/teximage.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index d72e91b3a3..4af4e39442 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2043,9 +2043,15 @@ check_gen_mipmap(GLcontext *ctx, GLenum target,
}
-/** Debug helper: override the user-requested internal format */
+/**
+ * Override the user-requested internal format.
+ * There are many cases where we want this, but the primary case is to avoid
+ * the software compression path if we don't have the compression routines
+ * available.
+ */
static GLenum
-override_internal_format(GLenum internalFormat, GLint width, GLint height)
+override_internal_format(GLcontext *ctx, GLenum internalFormat,
+ GLint width, GLint height)
{
#if 0
if (internalFormat == GL_RGBA16F_ARB ||
@@ -2073,17 +2079,32 @@ override_internal_format(GLenum internalFormat, GLint width, GLint height)
printf("Convert luminance float tex to int %d x %d\n", width, height);
return GL_ALPHA;
}
- /*
- else if (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) {
- internalFormat = GL_RGBA;
- }
- */
else {
return internalFormat;
}
-#else
- return internalFormat;
#endif
+
+ /* Refuse to compress textures without libdxtn. */
+ if (ctx->Mesa_DXTn == GL_FALSE) {
+ switch (internalFormat) {
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ internalFormat = GL_RGB;
+ break;
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ internalFormat = GL_RGBA;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return internalFormat;
}
@@ -2106,7 +2127,9 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
_mesa_lookup_enum_by_nr(format),
_mesa_lookup_enum_by_nr(type), pixels);
- internalFormat = override_internal_format(internalFormat, width, 1);
+ if (internalFormat != format) {
+ internalFormat = override_internal_format(ctx, internalFormat, width, 1);
+ }
#if FEATURE_convolve
if (_mesa_is_color_format(internalFormat)) {
@@ -2218,7 +2241,9 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
border, _mesa_lookup_enum_by_nr(format),
_mesa_lookup_enum_by_nr(type), pixels);
- internalFormat = override_internal_format(internalFormat, width, height);
+ if (internalFormat != format) {
+ internalFormat = override_internal_format(ctx, internalFormat, width, height);
+ }
#if FEATURE_convolve
if (_mesa_is_color_format(internalFormat)) {
@@ -2347,7 +2372,9 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
depth, border, _mesa_lookup_enum_by_nr(format),
_mesa_lookup_enum_by_nr(type), pixels);
- internalFormat = override_internal_format(internalFormat, width, height);
+ if (internalFormat != format) {
+ internalFormat = override_internal_format(ctx, internalFormat, width, height);
+ }
if (target == GL_TEXTURE_3D ||
(ctx->Extensions.MESA_texture_array &&