Update o3de to use new packages of ISPCTexComp and squish-ccr (#3556)

Update package name and hash
Add compressor names.
Update ImageProcessingAtom unit tests.
Removed some unused test assets under ImageProcessingAtom
Enalbe ISPC to all the platforms.
Better error message with compression/decompression
Add temp folder to git ignore
added ispccompressor for all platform. valid it with linux
Update windows package hashes.
Removed AZ_TRAIT_IMAGEPROCESSING_USE_ISPC_TEXTURE_COMPRESSOR
Minor refactor with image processing unit tests.

Signed-off-by: qingtao <qingtao@amazon.com>
This commit is contained in:
Qing Tao
2021-08-27 10:09:58 -07:00
committed by GitHub
parent 9e5ef08229
commit 9fac26e6a6
44 changed files with 173 additions and 237 deletions
@@ -66,6 +66,7 @@ ly_add_target(
3rdParty::PVRTexTool
3rdParty::squish-ccr
3rdParty::tiff
3rdParty::ISPCTexComp
3rdParty::ilmbase
Legacy::CryCommon
AZ::AzFramework
@@ -70,7 +70,6 @@ namespace ImageProcessingAtom
virtual AZ::u32 GetPixelCount(AZ::u32 mip) const = 0;
virtual AZ::u32 GetWidth(AZ::u32 mip) const = 0;
virtual AZ::u32 GetHeight(AZ::u32 mip) const = 0;
virtual bool IsCubemap() const = 0;
virtual AZ::u32 GetMipCount() const = 0;
//get pixel data buffer
@@ -141,6 +141,11 @@ namespace ImageProcessingAtom
ColorSpace CTSquisher::GetSupportedColorSpace([[maybe_unused]] EPixelFormat compressFormat) const
{
return ColorSpace::autoSelect;
}
const char* CTSquisher::GetName() const
{
return "CTSquisher";
}
EPixelFormat CTSquisher::GetSuggestedUncompressedFormat(EPixelFormat compressedfmt, EPixelFormat uncompressedfmt) const
@@ -27,6 +27,7 @@ namespace ImageProcessingAtom
EPixelFormat GetSuggestedUncompressedFormat(EPixelFormat compressedfmt, EPixelFormat uncompressedfmt) const override;
ColorSpace GetSupportedColorSpace(EPixelFormat compressFormat) const final;
const char* GetName() const final;
private:
static CryTextureSquisher::ECodingPreset GetCompressPreset(EPixelFormat compressFmt, EPixelFormat uncompressFmt);
@@ -10,22 +10,15 @@
#include <Compressors/CTSquisher.h>
#include <Compressors/PVRTC.h>
#include <Compressors/ETC2.h>
// this is required for the AZ_TRAIT_IMAGEPROCESSING_USE_ISPC_TEXTURE_COMPRESSOR define
#include <ImageProcessing_Traits_Platform.h>
#if AZ_TRAIT_IMAGEPROCESSING_USE_ISPC_TEXTURE_COMPRESSOR
#include <Compressors/ISPCTextureCompressor.h>
#endif
namespace ImageProcessingAtom
{
ICompressorPtr ICompressor::FindCompressor(EPixelFormat fmt, ColorSpace colorSpace, bool isCompressing)
ICompressorPtr ICompressor::FindCompressor(EPixelFormat fmt, [[maybe_unused]] ColorSpace colorSpace, bool isCompressing)
{
// The ISPC texture compressor is able to compress BC1, BC3, BC6H and BC7 formats, and all of the ASTC formats.
// Note: The ISPC texture compressor is only able to compress images that are a multiple of the compressed format's blocksize.
// Another limitation is that the compressor requires LDR source images to be in sRGB colorspace.
#if AZ_TRAIT_IMAGEPROCESSING_USE_ISPC_TEXTURE_COMPRESSOR
if (ISPCCompressor::IsCompressedPixelFormatSupported(fmt))
{
if ((isCompressing && ISPCCompressor::IsSourceColorSpaceSupported(colorSpace, fmt)) || (!isCompressing && ISPCCompressor::DoesSupportDecompress(fmt)))
@@ -33,7 +26,6 @@ namespace ImageProcessingAtom
return ICompressorPtr(new ISPCCompressor());
}
}
#endif
if (CTSquisher::IsCompressedPixelFormatSupported(fmt))
{
@@ -48,6 +48,7 @@ namespace ImageProcessingAtom
virtual IImageObjectPtr DecompressImage(IImageObjectPtr srcImage, EPixelFormat fmtDst) const = 0;
virtual EPixelFormat GetSuggestedUncompressedFormat(EPixelFormat compressedfmt, EPixelFormat uncompressedfmt) const = 0;
virtual ColorSpace GetSupportedColorSpace(EPixelFormat compressFormat) const = 0;
virtual const char* GetName() const = 0;
//find compressor for specified compressed pixel format. isCompressing to indicate if it's for compressing or decompressing
static ICompressorPtr FindCompressor(EPixelFormat fmt, ColorSpace colorSpace, bool isCompressing);
@@ -111,6 +111,11 @@ namespace ImageProcessingAtom
{
return ColorSpace::autoSelect;
}
const char* ETC2Compressor::GetName() const
{
return "ETC2Compressor";
}
IImageObjectPtr ETC2Compressor::CompressImage(IImageObjectPtr srcImage, EPixelFormat fmtDst,
const CompressOption* compressOption) const
@@ -24,7 +24,8 @@ namespace ImageProcessingAtom
IImageObjectPtr DecompressImage(IImageObjectPtr srcImage, EPixelFormat fmtDst) const override;
EPixelFormat GetSuggestedUncompressedFormat(EPixelFormat compressedfmt, EPixelFormat uncompressedfmt) const override;
virtual ColorSpace GetSupportedColorSpace(EPixelFormat compressFormat) const final;
ColorSpace GetSupportedColorSpace(EPixelFormat compressFormat) const final;
const char* GetName() const final;
};
} // namespace ImageProcessingAtom
@@ -111,6 +111,11 @@ namespace ImageProcessingAtom
return ColorSpace::autoSelect;
}
const char* ISPCCompressor::GetName() const
{
return "ISPCCompressor";
}
IImageObjectPtr ISPCCompressor::CompressImage(IImageObjectPtr sourceImage, EPixelFormat destinationFormat, const CompressOption* compressOption) const
{
// Used to find the profile setters, depending on the image quality
@@ -28,7 +28,9 @@ namespace ImageProcessingAtom
ColorSpace GetSupportedColorSpace(EPixelFormat compressFormat) const final;
IImageObjectPtr CompressImage(IImageObjectPtr sourceImage, EPixelFormat destinationFormat, const CompressOption* compressOption) const final;
IImageObjectPtr DecompressImage(IImageObjectPtr sourceImage, EPixelFormat destinationFormat) const final;
IImageObjectPtr DecompressImage(IImageObjectPtr sourceImage, EPixelFormat destinationFormat) const final;
const char* GetName() const final;
EPixelFormat GetSuggestedUncompressedFormat(EPixelFormat compressedfmt, EPixelFormat uncompressedfmt) const final;
};
@@ -107,6 +107,11 @@ namespace ImageProcessingAtom
return ColorSpace::autoSelect;
}
const char* PVRTCCompressor::GetName() const
{
return "PVRTCCompressor";
}
bool PVRTCCompressor::DoesSupportDecompress([[maybe_unused]] EPixelFormat fmtDst)
{
return true;
@@ -25,5 +25,6 @@ namespace ImageProcessingAtom
EPixelFormat GetSuggestedUncompressedFormat(EPixelFormat compressedfmt, EPixelFormat uncompressedfmt) const override;
ColorSpace GetSupportedColorSpace(EPixelFormat compressFormat) const final;
const char* GetName() const final;
};
} // namespace ImageProcessingAtom
@@ -6,6 +6,7 @@
*
*/
#include <AzCore/std/time.h>
#include <Processing/ImageFlags.h>
#include <Processing/ImageObjectImpl.h>
@@ -97,9 +98,18 @@ namespace ImageProcessingAtom
else
{
IImageObjectPtr dstImage = nullptr;
const PixelFormatInfo* compressedInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(compressedFmt);
if (isSrcUncompressed)
{
AZ::u64 startTime = AZStd::GetTimeUTCMilliSecond();
dstImage = compressor->CompressImage(Get(), fmtDst, &m_compressOption);
AZ::u64 endTime = AZStd::GetTimeUTCMilliSecond();
[[maybe_unused]] double processTime = static_cast<double>(endTime - startTime) / 1000.0;
if (dstImage)
{
AZ_TracePrintf("Image Processing", "Image [%dx%d] was compressed to [%s] format by [%s] in %.3f seconds\n",
Get()->GetWidth(0), Get()->GetHeight(0), compressedInfo->szName, compressor->GetName(), processTime);
}
}
else
{
@@ -107,11 +117,13 @@ namespace ImageProcessingAtom
}
Set(dstImage);
}
if (Get() == nullptr)
{
AZ_Error("Image Processing", false, "The selected compressor failed to compress this image");
if (dstImage == nullptr)
{
AZ_Error("Image Processing", false, "Failed to use [%s] to %s [%s] format", compressor->GetName(),
isSrcUncompressed ? "compress" : "decompress",
compressedInfo->szName);
}
}
}
}
@@ -74,7 +74,7 @@ namespace ImageProcessingAtom
builderDescriptor.m_busId = azrtti_typeid<ImageBuilderWorker>();
builderDescriptor.m_createJobFunction = AZStd::bind(&ImageBuilderWorker::CreateJobs, &m_imageBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2);
builderDescriptor.m_processJobFunction = AZStd::bind(&ImageBuilderWorker::ProcessJob, &m_imageBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2);
builderDescriptor.m_version = 23; // [ATOM-14022]
builderDescriptor.m_version = 24; // [SPEC-7821]
builderDescriptor.m_analysisFingerprint = ImageProcessingAtom::BuilderSettingManager::Instance()->GetAnalysisFingerprint();
m_imageBuilder.BusConnect(builderDescriptor.m_busId);
AssetBuilderSDK::AssetBuilderBus::Broadcast(&AssetBuilderSDK::AssetBuilderBusTraits::RegisterBuilderInformation, builderDescriptor);
@@ -28,6 +28,7 @@ namespace ImageProcessingAtom
QImage qimage(filename.c_str());
if (qimage.isNull())
{
AZ_Error("ImageProcessing", false, "Failed to load [%s] via QImage", filename.c_str());
return NULL;
}
@@ -13,4 +13,3 @@
#define AZ_TRAIT_IMAGEPROCESSING_PVRTEXLIB_USE_WINDLL_IMPORT 0
#define AZ_TRAIT_IMAGEPROCESSING_SQUISH_DO_NOT_USE_FASTCALL 0
#define AZ_TRAIT_IMAGEPROCESSING_USE_BASE10_BYTE_PREFIX 0
#define AZ_TRAIT_IMAGEPROCESSING_USE_ISPC_TEXTURE_COMPRESSOR 0
@@ -13,4 +13,3 @@
#define AZ_TRAIT_IMAGEPROCESSING_PVRTEXLIB_USE_WINDLL_IMPORT 0
#define AZ_TRAIT_IMAGEPROCESSING_SQUISH_DO_NOT_USE_FASTCALL 1
#define AZ_TRAIT_IMAGEPROCESSING_USE_BASE10_BYTE_PREFIX 0
#define AZ_TRAIT_IMAGEPROCESSING_USE_ISPC_TEXTURE_COMPRESSOR 0
@@ -13,4 +13,3 @@
#define AZ_TRAIT_IMAGEPROCESSING_PVRTEXLIB_USE_WINDLL_IMPORT 0
#define AZ_TRAIT_IMAGEPROCESSING_SQUISH_DO_NOT_USE_FASTCALL 1
#define AZ_TRAIT_IMAGEPROCESSING_USE_BASE10_BYTE_PREFIX 1
#define AZ_TRAIT_IMAGEPROCESSING_USE_ISPC_TEXTURE_COMPRESSOR 0
@@ -13,4 +13,3 @@
#define AZ_TRAIT_IMAGEPROCESSING_PVRTEXLIB_USE_WINDLL_IMPORT 1
#define AZ_TRAIT_IMAGEPROCESSING_SQUISH_DO_NOT_USE_FASTCALL 0
#define AZ_TRAIT_IMAGEPROCESSING_USE_BASE10_BYTE_PREFIX 0
#define AZ_TRAIT_IMAGEPROCESSING_USE_ISPC_TEXTURE_COMPRESSOR 1
@@ -6,11 +6,3 @@
#
#
# windows requires the 3rd Party ISPCTexComp library.
ly_associate_package(PACKAGE_NAME ISPCTexComp-2021.3-rev1-windows TARGETS ISPCTexComp PACKAGE_HASH 324fb051a549bc96571530e63c01e18a4c860db45317734d86276fe27a45f6dd)
set(LY_BUILD_DEPENDENCIES
PUBLIC
3rdParty::ISPCTexComp
)
@@ -9,6 +9,4 @@
set(FILES
ImageProcessing_Traits_Platform.h
ImageProcessing_Traits_Windows.h
../../Compressors/ISPCTextureCompressor.cpp
../../Compressors/ISPCTextureCompressor.h
)
@@ -13,4 +13,3 @@
#define AZ_TRAIT_IMAGEPROCESSING_PVRTEXLIB_USE_WINDLL_IMPORT 0
#define AZ_TRAIT_IMAGEPROCESSING_SQUISH_DO_NOT_USE_FASTCALL 1
#define AZ_TRAIT_IMAGEPROCESSING_USE_BASE10_BYTE_PREFIX 1
#define AZ_TRAIT_IMAGEPROCESSING_USE_ISPC_TEXTURE_COMPRESSOR 0
@@ -869,7 +869,7 @@ namespace ImageProcessingAtom
return process;
}
void ImageConvertProcess::CreateIBLCubemap(AZ::Uuid presetUUID, const char* fileNameSuffix, IImageObjectPtr cubemapImage)
void ImageConvertProcess::CreateIBLCubemap(AZ::Uuid presetUUID, const char* fileNameSuffix, IImageObjectPtr& cubemapImage)
{
const AZStd::string& platformId = m_input->m_platform;
AZStd::string_view filePath;
@@ -161,7 +161,7 @@ namespace ImageProcessingAtom
bool FillCubemapMipmaps();
//IBL cubemap generation, this creates a separate ImageConvertProcess
void CreateIBLCubemap(AZ::Uuid presetUUID, const char* fileNameSuffix, IImageObjectPtr cubemapImage);
void CreateIBLCubemap(AZ::Uuid presetUUID, const char* fileNameSuffix, IImageObjectPtr& cubemapImage);
//convert color space to linear with pixel format rgba32f
bool ConvertToLinear();
@@ -36,10 +36,6 @@ namespace ImageProcessingAtom
AZ::u32 GetWidth(AZ::u32 mip) const override;
AZ::u32 GetHeight(AZ::u32 mip) const override;
AZ::u32 GetMipCount() const override;
bool IsCubemap() const override
{
return false;
};
void GetImagePointer(AZ::u32 mip, AZ::u8*& pMem, AZ::u32& pitch) const override;
AZ::u32 GetMipBufSize(AZ::u32 mip) const override;
@@ -71,11 +71,6 @@ using namespace ImageProcessingAtom;
namespace UnitTest
{
namespace
{
static const char* s_gemFolder;
}
// Expose AZ::AssetManagerComponent::Reflect function for testing
class MyAssetManagerComponent
: public AZ::AssetManagerComponent
@@ -125,6 +120,8 @@ namespace UnitTest
AZStd::unique_ptr<AZ::JsonSystemComponent> m_jsonSystemComponent;
AZStd::vector<AZStd::unique_ptr<AZ::Data::AssetHandler>> m_assetHandlers;
AZStd::string m_gemFolder;
AZStd::string m_outputRootFolder;
AZStd::string m_outputFolder;
void SetUp() override
{
@@ -172,7 +169,7 @@ namespace UnitTest
AzQtComponents::PrepareQtPaths();
m_gemFolder = AZ::Test::GetEngineRootPath() + "/Gems/Atom/Asset/ImageProcessingAtom/";
s_gemFolder = m_gemFolder.c_str();
m_outputFolder = m_gemFolder + AZStd::string("Code/Tests/TestAssets/temp/");
m_defaultSettingFolder = m_gemFolder + AZStd::string("Config/");
m_testFileFolder = m_gemFolder + AZStd::string("Code/Tests/TestAssets/");
@@ -185,7 +182,7 @@ namespace UnitTest
void TearDown() override
{
m_gemFolder = AZStd::string();
s_gemFolder = "";
m_outputFolder = AZStd::string();
m_defaultSettingFolder = AZStd::string();
m_testFileFolder = AZStd::string();
@@ -226,16 +223,16 @@ namespace UnitTest
Image_512X288_RGB8_Tga,
Image_1024X1024_RGB8_Tif,
Image_UpperCase_Tga,
Image_512x512_Normal_Tga,
Image_512x512_Normal_Tga, // QImage doesn't support loading this file.
Image_128x128_Transparent_Tga,
Image_237x177_RGB_Jpg,
Image_GreyScale_Png,
Image_BlackWhite_Png,
Image_Alpha8_64x64_Mip7_Dds,
Image_BGRA_64x64_Mip7_Dds,
Image_Luminance8bpp_66x33_dds,
Image_BGR_64x64_dds,
Image_Sunset_4096x2048_R16G16B16A16F_exr
Image_defaultprobe_cm_1536x256_64bits_tif,
Image_workshop_iblskyboxcm_exr
};
//image file names for testing
@@ -258,17 +255,29 @@ namespace UnitTest
m_imagFileNameMap[Image_128x128_Transparent_Tga] = m_testFileFolder + "128x128_RGBA8.tga";
m_imagFileNameMap[Image_237x177_RGB_Jpg] = m_testFileFolder + "237x177_RGB.jpg";
m_imagFileNameMap[Image_GreyScale_Png] = m_testFileFolder + "greyscale.png";
m_imagFileNameMap[Image_BlackWhite_Png] = m_testFileFolder + "BlackWhite.png";
m_imagFileNameMap[Image_Alpha8_64x64_Mip7_Dds] = m_testFileFolder + "Alpha8_64x64_Mip7.dds";
m_imagFileNameMap[Image_BGRA_64x64_Mip7_Dds] = m_testFileFolder + "BGRA_64x64_MIP7.dds";
m_imagFileNameMap[Image_Luminance8bpp_66x33_dds] = m_testFileFolder + "Luminance8bpp_66x33.dds";
m_imagFileNameMap[Image_BGR_64x64_dds] = m_testFileFolder + "RGBA_64x64.dds";
m_imagFileNameMap[Image_Sunset_4096x2048_R16G16B16A16F_exr] = m_testFileFolder + "sunset_cm.exr";
m_imagFileNameMap[Image_defaultprobe_cm_1536x256_64bits_tif] = m_testFileFolder + "defaultProbe_cm.tif";
m_imagFileNameMap[Image_workshop_iblskyboxcm_exr] = m_testFileFolder + "workshop_iblskyboxcm.exr";
}
public:
void SetOutputSubFolder(const char* subFolderName)
{
if (subFolderName)
{
m_outputFolder = m_outputRootFolder + "/" + subFolderName;
}
else
{
m_outputFolder = m_outputRootFolder;
}
}
//helper function to save an image object to a file through QtImage
static void SaveImageToFile([[maybe_unused]] const IImageObjectPtr imageObject, [[maybe_unused]] const AZStd::string imageName, [[maybe_unused]] AZ::u32 maxMipCnt = 100)
void SaveImageToFile([[maybe_unused]] const IImageObjectPtr imageObject, [[maybe_unused]] const AZStd::string imageName, [[maybe_unused]] AZ::u32 maxMipCnt = 100)
{
#ifndef DEBUG_OUTPUT_IMAGES
return;
@@ -278,12 +287,12 @@ namespace UnitTest
return;
}
//create the directory if it's not exist
AZStd::string outputDir = s_gemFolder + AZStd::string("Code/Tests/TestAssets/Output/");
QDir dir(outputDir.data());
if (!dir.exists())
// create dir if it doesn't exist
QDir dir;
QDir outputDir(m_outputFolder.c_str());
if (!outputDir.exists())
{
dir.mkpath(".");
dir.mkpath(m_outputFolder.c_str());
}
//save origin file pixel format so we could use it to generate name later
@@ -303,12 +312,13 @@ namespace UnitTest
finalImage->GetImagePointer(mip, imageBuf, pitch);
uint32 width = finalImage->GetWidth(mip);
uint32 height = finalImage->GetHeight(mip);
uint32 originalSize = imageObject->GetMipBufSize(mip);
//generate file name
char filePath[2048];
azsprintf(filePath, "%s%s_%s_mip%d_%dx%d.png", outputDir.data(), imageName.c_str()
azsprintf(filePath, "%s%s_%s_mip%d_%dx%d_%d.png", m_outputFolder.data(), imageName.c_str()
, CPixelFormats::GetInstance().GetPixelFormatInfo(originPixelFormat)->szName
, mip, width, height);
, mip, width, height, originalSize);
QImage qimage(imageBuf, width, height, pitch, QImage::Format_RGBA8888);
qimage.save(filePath);
@@ -385,7 +395,7 @@ namespace UnitTest
}
static bool CompareDDSImage(const QString& imagePath1, const QString& imagePath2, QString& output)
bool CompareDDSImage(const QString& imagePath1, const QString& imagePath2, QString& output)
{
IImageObjectPtr image1, alphaImage1, image2, alphaImage2;
@@ -530,15 +540,7 @@ namespace UnitTest
TEST_F(ImageProcessingTest, TestCubemapLayouts)
{
{
IImageObjectPtr srcImage(LoadImageFromFile(m_imagFileNameMap[Image_Sunset_4096x2048_R16G16B16A16F_exr]));
ImageToProcess imageToProcess(srcImage);
imageToProcess.ConvertCubemapLayout(CubemapLayoutHorizontalCross);
ASSERT_TRUE(imageToProcess.Get()->GetWidth(0) * 3 == imageToProcess.Get()->GetHeight(0) * 4);
SaveImageToFile(imageToProcess.Get(), "LatLong", 1);
}
{
IImageObjectPtr srcImage(LoadImageFromFile(m_testFileFolder + "defaultProbe_cm.tif"));
IImageObjectPtr srcImage(LoadImageFromFile(m_imagFileNameMap[Image_defaultprobe_cm_1536x256_64bits_tif]));
ImageToProcess imageToProcess(srcImage);
imageToProcess.ConvertCubemapLayout(CubemapLayoutVertical);
@@ -635,12 +637,8 @@ namespace UnitTest
ASSERT_TRUE(img != nullptr);
ASSERT_TRUE(img->GetPixelFormat() == ePixelFormat_B8G8R8);
// Exr files
img = IImageObjectPtr(LoadImageFromFile(m_imagFileNameMap[Image_Sunset_4096x2048_R16G16B16A16F_exr]));
ASSERT_TRUE(img != nullptr);
img = IImageObjectPtr(LoadImageFromFile(m_testFileFolder + "abandoned_sanatorium_staircase_cm.exr"));
ASSERT_TRUE(img != nullptr);
img = IImageObjectPtr(LoadImageFromFile(m_testFileFolder + "road_in_tenerife_mountain_cm.exr"));
// Exr file
img = IImageObjectPtr(LoadImageFromFile(m_imagFileNameMap[Image_workshop_iblskyboxcm_exr]));
ASSERT_TRUE(img != nullptr);
}
@@ -783,39 +781,36 @@ namespace UnitTest
ASSERT_TRUE(dstImage3->CompareImage(dstImage1));
}
TEST_F(ImageProcessingTest, DISABLED_TestConvertPVRTC)
TEST_F(ImageProcessingTest, TestConvertFormatCompressed)
{
//source image
AZStd::string inputFile;
inputFile = "../AutomatedTesting/Objects/ParticleAssets/ShowRoom/showroom_pipe_blue_001_ddna.tif";
IImageObjectPtr srcImage(LoadImageFromFile(inputFile));
ImageToProcess imageToProcess(srcImage);
for (EPixelFormat pixelFormat = ePixelFormat_PVRTC2; pixelFormat <= ePixelFormat_ETC2a;)
{
imageToProcess.Set(srcImage);
imageToProcess.ConvertFormat(pixelFormat);
SaveImageToFile(imageToProcess.Get(), "Compressor", 1);
//next format
pixelFormat = EPixelFormat(pixelFormat + 1);
}
}
TEST_F(ImageProcessingTest, DISABLED_TestConvertFormat)
{
EPixelFormat pixelFormat;
IImageObjectPtr srcImage;
//images to be tested
static const int imageCount = 5;
static const int imageCount = 4;
ImageFeature images[imageCount] = {
Image_20X16_RGBA8_Png,
Image_32X32_16bit_F_Tif,
Image_32X32_32bit_F_Tif,
Image_512x512_Normal_Tga,
Image_128x128_Transparent_Tga };
Image_237x177_RGB_Jpg,
Image_128x128_Transparent_Tga,
Image_defaultprobe_cm_1536x256_64bits_tif};
// collect all compressed pixel formats
AZStd::vector<EPixelFormat> compressedFormats;
for (uint32 i = 0; i < ePixelFormat_Count; i++)
{
EPixelFormat pixelFormat = (EPixelFormat)i;
auto formatInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(pixelFormat);
if (formatInfo->bCompressed)
{
// exclude astc formats until we add astc compressor to all platforms
// exclude pvrtc formats (deprecating)
if (!IsASTCFormat(pixelFormat)
&& pixelFormat != ePixelFormat_PVRTC2 && pixelFormat != ePixelFormat_PVRTC4
&& !IsETCFormat(pixelFormat)) // skip ETC since it's very slow
{
compressedFormats.push_back(pixelFormat);
}
}
}
for (int imageIdx = 0; imageIdx < imageCount; imageIdx++)
{
@@ -827,42 +822,37 @@ namespace UnitTest
ImageToProcess imageToProcess(srcImage);
//test ConvertFormat functions against all the pixel formats
for (pixelFormat = ePixelFormat_R8G8B8A8; pixelFormat < ePixelFormat_Unknown;)
for (EPixelFormat pixelFormat : compressedFormats)
{
//
if (!CPixelFormats::GetInstance().IsImageSizeValid(pixelFormat, srcImage->GetWidth(0), srcImage->GetHeight(0), false))
{
continue;
}
auto formatInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(pixelFormat);
imageToProcess.Set(srcImage);
imageToProcess.ConvertFormat(pixelFormat);
if (!imageToProcess.Get())
{
AZ_Warning("test", false, "unsupported format: %s", formatInfo->szName);
continue;
}
ASSERT_TRUE(imageToProcess.Get());
ASSERT_TRUE(imageToProcess.Get()->GetPixelFormat() == pixelFormat);
//if the format is compressed and there is no compressor for it, it won't be converted to the expected format
if (ICompressor::FindCompressor(pixelFormat, ImageProcessingAtom::ColorSpace::autoSelect, true) == nullptr
&& !CPixelFormats::GetInstance().IsPixelFormatUncompressed(pixelFormat))
{
ASSERT_TRUE(imageToProcess.Get()->GetPixelFormat() != pixelFormat);
}
else
{
//validate the size and it may not working for some uncompressed format
if (!CPixelFormats::GetInstance().IsImageSizeValid(
pixelFormat, srcImage->GetWidth(0), srcImage->GetHeight(0), false))
{
ASSERT_TRUE(imageToProcess.Get()->GetPixelFormat() != pixelFormat);
}
else
{
ASSERT_TRUE(imageToProcess.Get()->GetPixelFormat() == pixelFormat);
// Get compressor name
ColorSpace sourceColorSpace = srcImage->HasImageFlags(EIF_SRGBRead) ? ColorSpace::sRGB : ColorSpace::linear;
ICompressorPtr compressor = ICompressor::FindCompressor(pixelFormat, sourceColorSpace, true);
//save the image to a file so we can check the visual result
SaveImageToFile(imageToProcess.Get(), imageName, 1);
//save the image to a file so we can check the visual result
AZStd::string outputName = AZStd::string::format("%s_%s", imageName.c_str(), compressor->GetName());
SaveImageToFile(imageToProcess.Get(), outputName, 1);
//convert back to an uncompressed format and expect it will be successful
imageToProcess.ConvertFormat(ePixelFormat_R8G8B8A8);
ASSERT_TRUE(imageToProcess.Get()->GetPixelFormat() == ePixelFormat_R8G8B8A8);
}
}
//next pixel format
pixelFormat = EPixelFormat(pixelFormat + 1);
//convert back to an uncompressed format and expect it will be successful
imageToProcess.ConvertFormat(ePixelFormat_R8G8B8A8);
ASSERT_TRUE(imageToProcess.Get()->GetPixelFormat() == ePixelFormat_R8G8B8A8);
}
}
}
@@ -932,42 +922,6 @@ namespace UnitTest
#endif //AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS
}
TEST_F(ImageProcessingTest, DISABLED_TestCubemap)
{
//load builder presets
auto outcome = BuilderSettingManager::Instance()->LoadConfigFromFolder(m_defaultSettingFolder);
ASSERT_TRUE(outcome.IsSuccess());
const AZStd::string outputFolder = m_gemFolder + AZStd::string("Code/Tests/TestAssets/temp/");
AZStd::string inputFile;
AZStd::vector<AssetBuilderSDK::JobProduct> outProducts;
inputFile = m_testFileFolder + "defaultProbe_cm.tif";
ImageConvertProcess* process = CreateImageConvertProcess(inputFile, outputFolder, "pc", outProducts);
if (process != nullptr)
{
int step = 0;
while (!process->IsFinished())
{
process->UpdateProcess();
step++;
}
//get process result
ASSERT_TRUE(process->IsSucceed());
SaveImageToFile(process->GetOutputImage(), "cubemap", 100);
SaveImageToFile(process->GetOutputIBLSpecularCubemap(), "iblspecularcubemap", 100);
SaveImageToFile(process->GetOutputIBLDiffuseCubemap(), "ibldiffusecubemap", 100);
SaveImageToFile(process->GetOutputAlphaImage(), "alpha", 1);
process->GetAppendOutputProducts(outProducts);
delete process;
}
}
//test image conversion for builder
TEST_F(ImageProcessingTest, TestBuilderImageConvertor)
{
@@ -975,12 +929,11 @@ namespace UnitTest
auto outcome = BuilderSettingManager::Instance()->LoadConfigFromFolder(m_defaultSettingFolder);
ASSERT_TRUE(outcome.IsSuccess());
const AZStd::string outputFolder = m_gemFolder + AZStd::string("Code/Tests/TestAssets/temp/");
AZStd::string inputFile;
AZStd::vector<AssetBuilderSDK::JobProduct> outProducts;
inputFile = m_imagFileNameMap[Image_128x128_Transparent_Tga];
ImageConvertProcess* process = CreateImageConvertProcess(inputFile, outputFolder, "pc", outProducts, m_context.get());
ImageConvertProcess* process = CreateImageConvertProcess(inputFile, m_outputFolder, "pc", outProducts, m_context.get());
if (process != nullptr)
{
@@ -1004,30 +957,38 @@ namespace UnitTest
}
}
//test image loading function for output dds files
TEST_F(ImageProcessingTest, DISABLED_TestLoadDdsImage)
TEST_F(ImageProcessingTest, TestIblSkyboxPreset)
{
IImageObjectPtr originImage, alphaImage;
AZStd::string inputFolder = "../AutomatedTesting/Cache/pc/engineassets/texturemsg/";
//load builder presets
auto outcome = BuilderSettingManager::Instance()->LoadConfigFromFolder(m_defaultSettingFolder);
ASSERT_TRUE(outcome.IsSuccess());
AZStd::string inputFile;
AZStd::vector<AssetBuilderSDK::JobProduct> outProducts;
inputFile = "E:/Javelin_NWLYDev/dev/Cache/Assets/pc/assets/textures/blend_maps/moss/jav_moss_ddn.dds";
inputFile = m_imagFileNameMap[Image_workshop_iblskyboxcm_exr];
ImageConvertProcess* process = CreateImageConvertProcess(inputFile, m_outputFolder, "pc", outProducts, m_context.get());
IImageObjectPtr newImage = IImageObjectPtr(DdsLoader::LoadImageFromFileLegacy(inputFile));
if (newImage->HasImageFlags(EIF_AttachedAlpha))
if (process != nullptr)
{
if (newImage->HasImageFlags(EIF_Splitted))
{
alphaImage = IImageObjectPtr(DdsLoader::LoadImageFromFileLegacy(inputFile + ".a"));
}
else
{
alphaImage = IImageObjectPtr(DdsLoader::LoadAttachedImageFromDdsFileLegacy(inputFile, newImage));
}
}
process->ProcessAll();
SaveImageToFile(newImage, "jav_moss_ddn", 10);
//get process result
ASSERT_TRUE(process->IsSucceed());
auto specularImage = process->GetOutputIBLSpecularCubemap();
auto diffuseImage = process->GetOutputIBLDiffuseCubemap();
ASSERT_TRUE(process->GetOutputImage());
ASSERT_TRUE(specularImage);
ASSERT_TRUE(diffuseImage);
// output converted result if save image is enabled
SaveImageToFile(process->GetOutputImage(), "ibl_skybox", 10);
SaveImageToFile(specularImage, "ibl_specular", 10);
SaveImageToFile(diffuseImage, "ibl_diffuse", 10);
delete process;
}
}
TEST_F(ImageProcessingTest, DISABLED_CompareOutputImage)
@@ -0,0 +1 @@
[Tt]emp/**
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:969c6597a6346c5ff8ae24b4ae143bacbeed2944dd139ddef9b440483dbe4c02
size 8866921
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ef6c54d5fa8dd3906d07eb4d3a4d664e82d957103e4bfbcaa951e3722348300d
size 749794
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:265ae231486dc6d5d61aa2416b0010ea743722f7238660faeed9edacd46e8a6b
size 6303186
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a559d4b21606d663bc9c7f9d8086646770f5e383c2214e6d3be0b192abbc6888
size 7736382
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:37d146db3de179add861ee86d2316ef1dd413cdb0b02448b3b95bf0023f44bae
size 613
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:95ec8e752ba10edb8242a9bb8cc78e5b85fe2861268cf95e06942e2a10ef243c
size 7484335
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:da49114be7305fad10121f92cdf6f153ebb3bc302edc662f2ed75cd45306ab7f
size 50364729
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:010165af78bdafe61dad187b250598fa670325428271f5bcf9bd4d839f4cc1c0
size 20114684
@@ -129,6 +129,8 @@ set(FILES
Source/Compressors/CryTextureSquisher/ColorBlockRGBA4x4s.h
Source/Compressors/CryTextureSquisher/ColorBlockRGBA4x4c.h
Source/Compressors/CryTextureSquisher/ColorTypes.h
Source/Compressors/ISPCTextureCompressor.cpp
Source/Compressors/ISPCTextureCompressor.h
Source/Thumbnail/ImageThumbnail.cpp
Source/Thumbnail/ImageThumbnail.h
Source/Thumbnail/ImageThumbnailSystemComponent.cpp