Bladeren bron

More android fixes

Panagiotis Christopoulos Charitos 4 jaren geleden
bovenliggende
commit
900324a889
3 gewijzigde bestanden met toevoegingen van 34 en 3 verwijderingen
  1. 3 2
      AnKi/Resource/ImageLoader.cpp
  2. 9 1
      AnKi/Resource/ImageLoader.h
  3. 22 0
      AnKi/Resource/ImageResource.cpp

+ 3 - 2
AnKi/Resource/ImageLoader.cpp

@@ -341,7 +341,7 @@ Error ImageLoader::loadAnkiImage(FileInterface& file, U32 maxImageSize,
 								 DynamicArray<ImageLoaderSurface>& surfaces, DynamicArray<ImageLoaderVolume>& volumes,
 								 GenericMemoryPoolAllocator<U8>& alloc, U32& width, U32& height, U32& depth,
 								 U32& layerCount, U32& mipCount, ImageBinaryType& imageType,
-								 ImageBinaryColorFormat& colorFormat)
+								 ImageBinaryColorFormat& colorFormat, UVec2& astcBlockSize)
 {
 	//
 	// Read and check the header
@@ -411,6 +411,7 @@ Error ImageLoader::loadAnkiImage(FileInterface& file, U32 maxImageSize,
 	// Set a few things
 	colorFormat = header.m_colorFormat;
 	imageType = header.m_type;
+	astcBlockSize = UVec2(header.m_astcBlockSizeX, header.m_astcBlockSizeY);
 
 	U32 faceCount = 1;
 	switch(header.m_type)
@@ -692,7 +693,7 @@ Error ImageLoader::loadInternal(FileInterface& file, const CString& filename, U3
 #endif
 
 		ANKI_CHECK(loadAnkiImage(file, maxImageSize, m_compression, m_surfaces, m_volumes, m_alloc, m_width, m_height,
-								 m_depth, m_layerCount, m_mipmapCount, m_imageType, m_colorFormat));
+								 m_depth, m_layerCount, m_mipmapCount, m_imageType, m_colorFormat, m_astcBlockSize));
 	}
 	else if(ext == "png" || ext == "jpg")
 	{

+ 9 - 1
AnKi/Resource/ImageLoader.h

@@ -93,6 +93,13 @@ public:
 		return m_imageType;
 	}
 
+	UVec2 getAstcBlockSize() const
+	{
+		ANKI_ASSERT(!!(m_compression & ImageBinaryDataCompression::ASTC));
+		ANKI_ASSERT(m_astcBlockSize != UVec2(0u));
+		return m_astcBlockSize;
+	}
+
 	const ImageLoaderSurface& getSurface(U32 level, U32 face, U32 layer) const;
 
 	const ImageLoaderVolume& getVolume(U32 level) const;
@@ -121,6 +128,7 @@ private:
 	U32 m_height = 0;
 	U32 m_depth = 0;
 	U32 m_layerCount = 0;
+	UVec2 m_astcBlockSize = UVec2(0u);
 	ImageBinaryDataCompression m_compression = ImageBinaryDataCompression::NONE;
 	ImageBinaryColorFormat m_colorFormat = ImageBinaryColorFormat::NONE;
 	ImageBinaryType m_imageType = ImageBinaryType::NONE;
@@ -145,7 +153,7 @@ private:
 											   DynamicArray<ImageLoaderVolume>& volumes,
 											   GenericMemoryPoolAllocator<U8>& alloc, U32& width, U32& height,
 											   U32& depth, U32& layerCount, U32& mipCount, ImageBinaryType& imageType,
-											   ImageBinaryColorFormat& colorFormat);
+											   ImageBinaryColorFormat& colorFormat, UVec2& astcBlockSize);
 
 	ANKI_USE_RESULT Error loadInternal(FileInterface& file, const CString& filename, U32 maxImageSize);
 };

+ 22 - 0
AnKi/Resource/ImageResource.cpp

@@ -122,6 +122,17 @@ Error ImageResource::load(const ResourceFilename& filename, Bool async)
 		case ImageBinaryDataCompression::S3TC:
 			init.m_format = Format::BC1_RGB_UNORM_BLOCK;
 			break;
+		case ImageBinaryDataCompression::ASTC:
+			if(loader.getAstcBlockSize() == UVec2(4u))
+			{
+				init.m_format = Format::ASTC_4x4_UNORM_BLOCK;
+			}
+			else
+			{
+				ANKI_ASSERT(loader.getAstcBlockSize() == UVec2(8u));
+				init.m_format = Format::ASTC_8x8_UNORM_BLOCK;
+			}
+			break;
 		default:
 			ANKI_ASSERT(0);
 		}
@@ -136,6 +147,17 @@ Error ImageResource::load(const ResourceFilename& filename, Bool async)
 		case ImageBinaryDataCompression::S3TC:
 			init.m_format = Format::BC3_UNORM_BLOCK;
 			break;
+		case ImageBinaryDataCompression::ASTC:
+			if(loader.getAstcBlockSize() == UVec2(4u))
+			{
+				init.m_format = Format::ASTC_4x4_UNORM_BLOCK;
+			}
+			else
+			{
+				ANKI_ASSERT(loader.getAstcBlockSize() == UVec2(8u));
+				init.m_format = Format::ASTC_8x8_UNORM_BLOCK;
+			}
+			break;
 		default:
 			ANKI_ASSERT(0);
 		}