diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2012-08-21 15:20:23 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2012-08-29 15:09:38 -0700 |
commit | 42723d88d370a7599398cc1c2349aeb951ba1c57 (patch) | |
tree | 6125f14627d325767430677e578455eea066b247 | |
parent | 0e0d66446194ab0b2d114dc83e76ec9c9b1a01f1 (diff) |
mesa: Do something sensible when on-line compression is requested but not possible
It is possible to force S3TC extensions to be enabled. This is
generally done to support applications that will only supply
pre-compressed textures. This accounts for the vast majority of
applications.
However, there is still the possibility of an application asking for
on-line compression. In that case, generate a warning and substitute a
generic compressed format. The driver will either pick an uncompressed
format or a compressed format that Mesa can handle on-line (e.g., FXT1).
This should only cause problems for applications that request on-line
compression and read the compressed texture back. This is likely an
infinitesimal subset of an already infinitesimal subset.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
-rw-r--r-- | src/mesa/main/teximage.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index c0868fabb21..11b1b3043a9 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c | |||
@@ -2799,6 +2799,37 @@ _mesa_choose_texture_format(struct gl_context *ctx, | |||
2799 | } | 2799 | } |
2800 | } | 2800 | } |
2801 | 2801 | ||
2802 | /* If the application requested compression to an S3TC format but we don't | ||
2803 | * have the DTXn library, force a generic compressed format instead. | ||
2804 | */ | ||
2805 | if (internalFormat != format) { | ||
2806 | const GLenum before = internalFormat; | ||
2807 | |||
2808 | switch (internalFormat) { | ||
2809 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | ||
2810 | if (!ctx->Mesa_DXTn) | ||
2811 | internalFormat = GL_COMPRESSED_RGB; | ||
2812 | break; | ||
2813 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | ||
2814 | case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | ||
2815 | case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: | ||
2816 | if (!ctx->Mesa_DXTn) | ||
2817 | internalFormat = GL_COMPRESSED_RGBA; | ||
2818 | break; | ||
2819 | default: | ||
2820 | break; | ||
2821 | } | ||
2822 | |||
2823 | if (before != internalFormat) { | ||
2824 | _mesa_warning(ctx, | ||
2825 | "DXT compression requested (%s), " | ||
2826 | "but libtxc_dxtn library not installed. Using %s " | ||
2827 | "instead.", | ||
2828 | _mesa_lookup_enum_by_nr(before), | ||
2829 | _mesa_lookup_enum_by_nr(internalFormat)); | ||
2830 | } | ||
2831 | } | ||
2832 | |||
2802 | /* choose format from scratch */ | 2833 | /* choose format from scratch */ |
2803 | f = ctx->Driver.ChooseTextureFormat(ctx, texObj->Target, internalFormat, | 2834 | f = ctx->Driver.ChooseTextureFormat(ctx, texObj->Target, internalFormat, |
2804 | format, type); | 2835 | format, type); |