From 504ea68273939d636191fe060d5492655f250652 Mon Sep 17 00:00:00 2001 From: Vladimir Vukicevic Date: Fri, 31 Jan 2020 17:26:53 -0800 Subject: [PATCH] Add BIMG_DECODE_ASTC --- src/config.h | 4 ++++ src/image.cpp | 40 ++++++++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/config.h b/src/config.h index b76ad15..9d79fc0 100644 --- a/src/config.h +++ b/src/config.h @@ -44,6 +44,10 @@ # define BIMG_DECODE_ATC BIMG_DECODE_ENABLE #endif // BIMG_DECODE_ATC +#ifndef BIMG_DECODE_ASTC +# define BIMG_DECODE_ASTC BIMG_DECODE_ENABLE +#endif // BIMG_DECODE_ASTC + #ifndef BIMG_DECODE_ETC1 # define BIMG_DECODE_ETC1 BIMG_DECODE_ENABLE #endif // BIMG_DECODE_ETC1 diff --git a/src/image.cpp b/src/image.cpp index cf5a314..e99ec3e 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -4709,23 +4709,31 @@ namespace bimg case TextureFormat::ASTC8x5: case TextureFormat::ASTC8x6: case TextureFormat::ASTC10x5: - if (!astc_codec::ASTCDecompressToRGBA( - (const uint8_t*)_src - , imageGetSize(NULL, uint16_t(_width), uint16_t(_height), 0, false, false, 1, _srcFormat) - , _width - , _height - , TextureFormat::ASTC4x4 == _srcFormat ? astc_codec::FootprintType::k4x4 - : TextureFormat::ASTC5x5 == _srcFormat ? astc_codec::FootprintType::k5x5 - : TextureFormat::ASTC6x6 == _srcFormat ? astc_codec::FootprintType::k6x6 - : TextureFormat::ASTC8x5 == _srcFormat ? astc_codec::FootprintType::k8x5 - : TextureFormat::ASTC8x6 == _srcFormat ? astc_codec::FootprintType::k8x6 - : astc_codec::FootprintType::k10x5 - , (uint8_t*)_dst - , _width*_height*4 - , _dstPitch - ) ) + if (BX_ENABLED(BIMG_DECODE_ASTC) ) { - imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xffffff00) ); + if (!astc_codec::ASTCDecompressToRGBA( + (const uint8_t*)_src + , imageGetSize(NULL, uint16_t(_width), uint16_t(_height), 0, false, false, 1, _srcFormat) + , _width + , _height + , TextureFormat::ASTC4x4 == _srcFormat ? astc_codec::FootprintType::k4x4 + : TextureFormat::ASTC5x5 == _srcFormat ? astc_codec::FootprintType::k5x5 + : TextureFormat::ASTC6x6 == _srcFormat ? astc_codec::FootprintType::k6x6 + : TextureFormat::ASTC8x5 == _srcFormat ? astc_codec::FootprintType::k8x5 + : TextureFormat::ASTC8x6 == _srcFormat ? astc_codec::FootprintType::k8x6 + : astc_codec::FootprintType::k10x5 + , (uint8_t*)_dst + , _width*_height*4 + , _dstPitch + ) ) + { + imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xffffff00) ); + } + } + else + { + BX_WARN(false, "ASTC decoder is disabled (BIMG_DECODE_ASTC)."); + imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00) ); } break;