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>
monroegm-disable-blank-issue-2
Qing Tao 4 years ago committed by GitHub
parent 9e5ef08229
commit 9fac26e6a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,6 +10,7 @@
#ifndef AZSTD_FUNCTION_BASE_HEADER
#define AZSTD_FUNCTION_BASE_HEADER
#include <AzCore/std/allocator.h>
#include <AzCore/std/base.h>
#include <AzCore/std/utils.h>
#include <AzCore/std/function/function_fwd.h>

@ -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)
{
//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)
TEST_F(ImageProcessingTest, TestConvertFormatCompressed)
{
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);
ASSERT_TRUE(imageToProcess.Get());
//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
if (!imageToProcess.Get())
{
//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);
//save the image to a file so we can check the visual result
SaveImageToFile(imageToProcess.Get(), imageName, 1);
//convert back to an uncompressed format and expect it will be successful
imageToProcess.ConvertFormat(ePixelFormat_R8G8B8A8);
ASSERT_TRUE(imageToProcess.Get()->GetPixelFormat() == ePixelFormat_R8G8B8A8);
}
AZ_Warning("test", false, "unsupported format: %s", formatInfo->szName);
continue;
}
ASSERT_TRUE(imageToProcess.Get());
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);
//next pixel format
pixelFormat = EPixelFormat(pixelFormat + 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);
}
}
}
@ -932,22 +922,22 @@ namespace UnitTest
#endif //AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS
}
TEST_F(ImageProcessingTest, DISABLED_TestCubemap)
//test image conversion for builder
TEST_F(ImageProcessingTest, TestBuilderImageConvertor)
{
//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);
inputFile = m_imagFileNameMap[Image_128x128_Transparent_Tga];
ImageConvertProcess* process = CreateImageConvertProcess(inputFile, m_outputFolder, "pc", outProducts, m_context.get());
if (process != nullptr)
{
//the process can be stopped if the job is canceled or the worker is shutting down
int step = 0;
while (!process->IsFinished())
{
@ -958,78 +948,49 @@ namespace UnitTest
//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);
SaveImageToFile(process->GetOutputImage(), "rgb", 10);
SaveImageToFile(process->GetOutputAlphaImage(), "alpha", 10);
process->GetAppendOutputProducts(outProducts);
delete process;
}
}
//test image conversion for builder
TEST_F(ImageProcessingTest, TestBuilderImageConvertor)
TEST_F(ImageProcessingTest, TestIblSkyboxPreset)
{
//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_imagFileNameMap[Image_128x128_Transparent_Tga];
ImageConvertProcess* process = CreateImageConvertProcess(inputFile, outputFolder, "pc", outProducts, m_context.get());
inputFile = m_imagFileNameMap[Image_workshop_iblskyboxcm_exr];
ImageConvertProcess* process = CreateImageConvertProcess(inputFile, m_outputFolder, "pc", outProducts, m_context.get());
if (process != nullptr)
{
//the process can be stopped if the job is canceled or the worker is shutting down
int step = 0;
while (!process->IsFinished())
{
process->UpdateProcess();
step++;
}
process->ProcessAll();
//get process result
ASSERT_TRUE(process->IsSucceed());
SaveImageToFile(process->GetOutputImage(), "rgb", 10);
SaveImageToFile(process->GetOutputAlphaImage(), "alpha", 10);
auto specularImage = process->GetOutputIBLSpecularCubemap();
auto diffuseImage = process->GetOutputIBLDiffuseCubemap();
ASSERT_TRUE(process->GetOutputImage());
ASSERT_TRUE(specularImage);
ASSERT_TRUE(diffuseImage);
process->GetAppendOutputProducts(outProducts);
// 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 image loading function for output dds files
TEST_F(ImageProcessingTest, DISABLED_TestLoadDdsImage)
{
IImageObjectPtr originImage, alphaImage;
AZStd::string inputFolder = "../AutomatedTesting/Cache/pc/engineassets/texturemsg/";
AZStd::string inputFile;
inputFile = "E:/Javelin_NWLYDev/dev/Cache/Assets/pc/assets/textures/blend_maps/moss/jav_moss_ddn.dds";
IImageObjectPtr newImage = IImageObjectPtr(DdsLoader::LoadImageFromFileLegacy(inputFile));
if (newImage->HasImageFlags(EIF_AttachedAlpha))
{
if (newImage->HasImageFlags(EIF_Splitted))
{
alphaImage = IImageObjectPtr(DdsLoader::LoadImageFromFileLegacy(inputFile + ".a"));
}
else
{
alphaImage = IImageObjectPtr(DdsLoader::LoadAttachedImageFromDdsFileLegacy(inputFile, newImage));
}
}
SaveImageToFile(newImage, "jav_moss_ddn", 10);
}
TEST_F(ImageProcessingTest, DISABLED_CompareOutputImage)
{
AZStd::string curretTextureFolder = "../TestAssets/TextureAssets/assets_new/textures";

@ -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

@ -9,7 +9,6 @@
# shared by other platforms:
ly_associate_package(PACKAGE_NAME ilmbase-2.3.0-rev4-multiplatform TARGETS ilmbase PACKAGE_HASH 97547fdf1fbc4d81b8ccf382261f8c25514ed3b3c4f8fd493f0a4fa873bba348)
ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform TARGETS assimplib PACKAGE_HASH 1a9113788b893ef4a2ee63ac01eb71b981a92894a5a51175703fa225f5804dec)
ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3)
ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326)
ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf)
ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-rev1-multiplatform TARGETS RapidJSON PACKAGE_HASH 2f5e26ecf86c3b7a262753e7da69ac59928e78e9534361f3d00c1ad5879e4023)
@ -45,5 +44,7 @@ ly_associate_package(PACKAGE_NAME DirectXShaderCompilerDxc-1.6.2104-o3de-rev3-li
ly_associate_package(PACKAGE_NAME SPIRVCross-2021.04.29-rev1-linux TARGETS SPIRVCross PACKAGE_HASH 7889ee5460a688e9b910c0168b31445c0079d363affa07b25d4c8aeb608a0b80)
ly_associate_package(PACKAGE_NAME azslc-1.7.23-rev2-linux TARGETS azslc PACKAGE_HASH 1ba84d8321a566d35a1e9aa7400211ba8e6d1c11c08e4be3c93e6e74b8f7aef1)
ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev1-linux TARGETS zlib PACKAGE_HASH 6418e93b9f4e6188f3b62cbd3a7822e1c4398a716e786d1522b809a727d08ba9)
ly_associate_package(PACKAGE_NAME squish-ccr-deb557d-rev1-linux TARGETS squish-ccr PACKAGE_HASH 85fecafbddc6a41a27c5f59ed4a5dfb123a94cb4666782cf26e63c0a4724c530)
ly_associate_package(PACKAGE_NAME ISPCTexComp-36b80aa-rev1-linux TARGETS ISPCTexComp PACKAGE_HASH 065fd12abe4247dde247330313763cf816c3375c221da030bdec35024947f259)

@ -1,9 +0,0 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set(SQUISH-CCR_LIBS ${BASE_PATH}/lib/Linux/Release/libsquish-ccr.a)

@ -9,7 +9,6 @@
# shared by other platforms:
ly_associate_package(PACKAGE_NAME ilmbase-2.3.0-rev4-multiplatform TARGETS ilmbase PACKAGE_HASH 97547fdf1fbc4d81b8ccf382261f8c25514ed3b3c4f8fd493f0a4fa873bba348)
ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform TARGETS assimplib PACKAGE_HASH 1a9113788b893ef4a2ee63ac01eb71b981a92894a5a51175703fa225f5804dec)
ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3)
ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326)
ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf)
ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-rev1-multiplatform TARGETS RapidJSON PACKAGE_HASH 2f5e26ecf86c3b7a262753e7da69ac59928e78e9534361f3d00c1ad5879e4023)
@ -43,3 +42,6 @@ ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev1-mac
ly_associate_package(PACKAGE_NAME qt-5.15.2-rev5-mac TARGETS Qt PACKAGE_HASH 9d25918351898b308ded3e9e571fff6f26311b2071aeafd00dd5b249fdf53f7e)
ly_associate_package(PACKAGE_NAME libsamplerate-0.2.1-rev2-mac TARGETS libsamplerate PACKAGE_HASH b912af40c0ac197af9c43d85004395ba92a6a859a24b7eacd920fed5854a97fe)
ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev1-mac TARGETS zlib PACKAGE_HASH 7fd8a77b3598423d9d6be5f8c60d52aecf346ab4224f563a5282db283aa0da02)
ly_associate_package(PACKAGE_NAME squish-ccr-deb557d-rev1-mac TARGETS squish-ccr PACKAGE_HASH 155bfbfa17c19a9cd2ef025de14c5db598f4290045d5b0d83ab58cb345089a77)
ly_associate_package(PACKAGE_NAME ISPCTexComp-36b80aa-rev1-mac TARGETS ISPCTexComp PACKAGE_HASH 8a4e93277b8face6ea2fd57c6d017bdb55643ed3d6387110bc5f6b3b884dd169)

@ -1,9 +0,0 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set(SQUISH-CCR_LIBS ${BASE_PATH}/lib/Mac/Release/libsquish-ccr.a)

@ -9,7 +9,6 @@
# shared by other platforms:
ly_associate_package(PACKAGE_NAME ilmbase-2.3.0-rev4-multiplatform TARGETS ilmbase PACKAGE_HASH 97547fdf1fbc4d81b8ccf382261f8c25514ed3b3c4f8fd493f0a4fa873bba348)
ly_associate_package(PACKAGE_NAME assimp-5.0.1-rev11-multiplatform TARGETS assimplib PACKAGE_HASH 1a9113788b893ef4a2ee63ac01eb71b981a92894a5a51175703fa225f5804dec)
ly_associate_package(PACKAGE_NAME squish-ccr-20150601-rev3-multiplatform TARGETS squish-ccr PACKAGE_HASH c878c6c0c705e78403c397d03f5aa7bc87e5978298710e14d09c9daf951a83b3)
ly_associate_package(PACKAGE_NAME ASTCEncoder-2017_11_14-rev2-multiplatform TARGETS ASTCEncoder PACKAGE_HASH c240ffc12083ee39a5ce9dc241de44d116e513e1e3e4cc1d05305e7aa3bdc326)
ly_associate_package(PACKAGE_NAME md5-2.0-multiplatform TARGETS md5 PACKAGE_HASH 29e52ad22c78051551f78a40c2709594f0378762ae03b417adca3f4b700affdf)
ly_associate_package(PACKAGE_NAME RapidJSON-1.1.0-rev1-multiplatform TARGETS RapidJSON PACKAGE_HASH 2f5e26ecf86c3b7a262753e7da69ac59928e78e9534361f3d00c1ad5879e4023)
@ -51,3 +50,5 @@ ly_associate_package(PACKAGE_NAME civetweb-1.8-rev1-windows
ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev2-windows TARGETS OpenSSL PACKAGE_HASH 9af1c50343f89146b4053101a7aeb20513319a3fe2f007e356d7ce25f9241040)
ly_associate_package(PACKAGE_NAME Crashpad-0.8.0-rev1-windows TARGETS Crashpad PACKAGE_HASH d162aa3070147bc0130a44caab02c5fe58606910252caf7f90472bd48d4e31e2)
ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev1-windows TARGETS zlib PACKAGE_HASH 6fb46a0ef8c8614cde3517b50fca47f2a6d1fd059b21f3b8ff13e635ca7f2fa6)
ly_associate_package(PACKAGE_NAME squish-ccr-deb557d-rev1-windows TARGETS squish-ccr PACKAGE_HASH 5c3d9fa491e488ccaf802304ad23b932268a2b2846e383f088779962af2bfa84)
ly_associate_package(PACKAGE_NAME ISPCTexComp-36b80aa-rev1-windows TARGETS ISPCTexComp PACKAGE_HASH b6fa6ea28a2808a9a5524c72c37789c525925e435770f2d94eb2d387360fa2d0)

@ -1,9 +0,0 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set(SQUISH-CCR_LIBS ${BASE_PATH}/lib/Windows/Release/squish-ccr.lib)
Loading…
Cancel
Save