diff options
author | Neil Roberts <[email protected]> | 2014-07-17 14:33:10 +0100 |
---|---|---|
committer | Neil Roberts <[email protected]> | 2014-08-12 18:23:50 +0100 |
commit | 17cde55c538009764207bd29b78a909d2c5d14b4 (patch) | |
tree | 23bff537d60f843ad38e87b4fb5bd23b8cdb92d4 /src/mesa/main/texstore.c | |
parent | 442bcd7fd373b2a55c0db9ee806f6f4be64b0285 (diff) |
mesa: Add texstore functions for BPTC-compressed textures
This adds compressors for all four of the BPTC compressed-texture formats. The
compressor is written from scratch and takes a very simple approach. It always
uses a single mode of the BPTC format (4 for unorm and 3 for half-floats) and
picks the two endpoints by dividing the texels into those which have more or
less than the average luminance of the block and then calculating an average
color of the texels within each division.
It's probably not really sensible to try to use BPTC compression at runtime
because for example with the Nvidia offline compression tool it can take in
the order of an hour to compress a full-screen image. With that in mind I
don't think it's worth having a proper compressor in Mesa and this approach
gives reasonable results for a usage that is basically a corner case.
v2: Always use the custom compressor, even for the unorm formats. Fix the
quantization step for the half-float format compressor. Fixed a typo which
was breaking the right-hand edge of half-float textures with a width that
isn't a multiple of four.
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r-- | src/mesa/main/texstore.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 0e036d9ebe6..50306d80bf8 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -68,6 +68,7 @@ #include "texcompress_rgtc.h" #include "texcompress_s3tc.h" #include "texcompress_etc.h" +#include "texcompress_bptc.h" #include "teximage.h" #include "texstore.h" #include "enums.h" @@ -1426,6 +1427,15 @@ texstore_compressed(TEXSTORE_PARAMS) table[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1] = _mesa_texstore_etc2_srgb8_punchthrough_alpha1; + table[MESA_FORMAT_BPTC_RGBA_UNORM] = + _mesa_texstore_bptc_rgba_unorm; + table[MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM] = + _mesa_texstore_bptc_rgba_unorm; + table[MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT] = + _mesa_texstore_bptc_rgb_signed_float; + table[MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT] = + _mesa_texstore_bptc_rgb_unsigned_float; + initialized = GL_TRUE; } |