Przeglądaj źródła

Add BIMG_DECODE_ASTC

Vladimir Vukicevic 5 lat temu
rodzic
commit
504ea68273
2 zmienionych plików z 28 dodań i 16 usunięć
  1. 4 0
      src/config.h
  2. 24 16
      src/image.cpp

+ 4 - 0
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

+ 24 - 16
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;