ATOM-16320 Remove PVRTC and ETC compressor (#4557)

Signed-off-by: Qing Tao <qingtao@amazon.com>
monroegm-disable-blank-issue-2
Qing Tao 4 years ago committed by GitHub
parent 2496bc38b5
commit e64b9d3536
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,7 +25,7 @@ namespace UnitTest
R"X(Executing RC.EXE: '"E:\lyengine\dev\windows\bin\profile\rc.exe" "E:/Directory/File.tga")X", R"X(Executing RC.EXE: '"E:\lyengine\dev\windows\bin\profile\rc.exe" "E:/Directory/File.tga")X",
R"X(Executing RC.EXE with working directory : '')X", R"X(Executing RC.EXE with working directory : '')X",
R"X(ResourceCompiler 64 - bit DEBUG)X", R"X(ResourceCompiler 64 - bit DEBUG)X",
R"X(Platform support : PC, PowerVR, etc2Comp)X", R"X(Platform support : PC, PowerVR)X",
R"X(Version 1.1.8.6 Nov 5 2018 13 : 28 : 28)X" R"X(Version 1.1.8.6 Nov 5 2018 13 : 28 : 28)X"
}; };

@ -63,13 +63,10 @@ ly_add_target(
3rdParty::Qt::Widgets 3rdParty::Qt::Widgets
3rdParty::Qt::Gui 3rdParty::Qt::Gui
3rdParty::astc-encoder 3rdParty::astc-encoder
3rdParty::etc2comp
3rdParty::PVRTexTool
3rdParty::squish-ccr 3rdParty::squish-ccr
3rdParty::tiff 3rdParty::tiff
3rdParty::ISPCTexComp 3rdParty::ISPCTexComp
3rdParty::ilmbase 3rdParty::ilmbase
Legacy::CryCommon
AZ::AzFramework AZ::AzFramework
AZ::AzToolsFramework AZ::AzToolsFramework
AZ::AzQtComponents AZ::AzQtComponents

@ -39,16 +39,7 @@ namespace ImageProcessingAtom
ePixelFormat_ASTC_10x8, ePixelFormat_ASTC_10x8,
ePixelFormat_ASTC_10x10, ePixelFormat_ASTC_10x10,
ePixelFormat_ASTC_12x10, ePixelFormat_ASTC_12x10,
ePixelFormat_ASTC_12x12, ePixelFormat_ASTC_12x12,
//Formats supported by PowerVR GPU. Mainly for ios devices.
ePixelFormat_PVRTC2, //2bpp
ePixelFormat_PVRTC4, //4bpp
//formats for opengl and opengles 3.0 (android devices)
ePixelFormat_EAC_R11, //one channel unsigned data
ePixelFormat_EAC_RG11, //two channel unsigned data
ePixelFormat_ETC2, //Compresses RGB888 data, it taks 4x4 groups of pixel data and compresses each into a 64-bit
ePixelFormat_ETC2a1, //Compresses RGB888A1 data, it taks 4x4 groups of pixel data and compresses each into a 64-bit
ePixelFormat_ETC2a, //Compresses RGBA8888 data with full alpha support
// Standardized Compressed DXGI Formats (DX10+) // Standardized Compressed DXGI Formats (DX10+)
// Data in these compressed formats is hardware decodable on all DX10 chips, and manageable with the DX10-API. // Data in these compressed formats is hardware decodable on all DX10 chips, and manageable with the DX10-API.
@ -88,7 +79,6 @@ namespace ImageProcessingAtom
}; };
bool IsASTCFormat(EPixelFormat fmt); bool IsASTCFormat(EPixelFormat fmt);
bool IsETCFormat(EPixelFormat fmt);
} // namespace ImageProcessingAtom } // namespace ImageProcessingAtom
namespace AZ namespace AZ

@ -109,13 +109,6 @@ namespace ImageProcessingAtom
->Value("ASTC_10x10", EPixelFormat::ePixelFormat_ASTC_10x10) ->Value("ASTC_10x10", EPixelFormat::ePixelFormat_ASTC_10x10)
->Value("ASTC_12x10", EPixelFormat::ePixelFormat_ASTC_12x10) ->Value("ASTC_12x10", EPixelFormat::ePixelFormat_ASTC_12x10)
->Value("ASTC_12x12", EPixelFormat::ePixelFormat_ASTC_12x12) ->Value("ASTC_12x12", EPixelFormat::ePixelFormat_ASTC_12x12)
->Value("PVRTC2", EPixelFormat::ePixelFormat_PVRTC2)
->Value("PVRTC4", EPixelFormat::ePixelFormat_PVRTC4)
->Value("EAC_R11", EPixelFormat::ePixelFormat_EAC_R11)
->Value("EAC_RG11", EPixelFormat::ePixelFormat_EAC_RG11)
->Value("ETC2", EPixelFormat::ePixelFormat_ETC2)
->Value("ETC2a1", EPixelFormat::ePixelFormat_ETC2a1)
->Value("ETC2a", EPixelFormat::ePixelFormat_ETC2a)
->Value("BC1", EPixelFormat::ePixelFormat_BC1) ->Value("BC1", EPixelFormat::ePixelFormat_BC1)
->Value("BC1a", EPixelFormat::ePixelFormat_BC1a) ->Value("BC1a", EPixelFormat::ePixelFormat_BC1a)
->Value("BC3", EPixelFormat::ePixelFormat_BC3) ->Value("BC3", EPixelFormat::ePixelFormat_BC3)

@ -10,8 +10,6 @@
#include <AzCore/PlatformIncl.h> #include <AzCore/PlatformIncl.h>
#include <Compressors/ASTCCompressor.h> #include <Compressors/ASTCCompressor.h>
#include <Compressors/CTSquisher.h> #include <Compressors/CTSquisher.h>
#include <Compressors/PVRTC.h>
#include <Compressors/ETC2.h>
#include <Compressors/ISPCTextureCompressor.h> #include <Compressors/ISPCTextureCompressor.h>
namespace ImageProcessingAtom namespace ImageProcessingAtom
@ -42,26 +40,6 @@ namespace ImageProcessingAtom
} }
} }
// Both ETC2Compressor and PVRTCCompressor can process ETC formats
// According to Mobile team, Etc2Com is faster than PVRTexLib, so we check with ETC2Compressor before PVRTCCompressor
// Note: with the test I have done, I found out it cost similar time for both Etc2Com and PVRTexLib to compress
// a 2048x2048 test texture to EAC_R11 and EAC_RG11. It was around 7 minutes for EAC_R11 and 14 minutes for EAC_RG11
if (ETC2Compressor::IsCompressedPixelFormatSupported(fmt))
{
if (isCompressing || (!isCompressing && ETC2Compressor::DoesSupportDecompress(fmt)))
{
return ICompressorPtr(new ETC2Compressor());
}
}
if (PVRTCCompressor::IsCompressedPixelFormatSupported(fmt))
{
if (isCompressing || (!isCompressing && PVRTCCompressor::DoesSupportDecompress(fmt)))
{
return ICompressorPtr(new PVRTCCompressor());
}
}
return nullptr; return nullptr;
} }

@ -1,233 +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
*
*/
#include <Atom/ImageProcessing/ImageObject.h>
#include <Processing/PixelFormatInfo.h>
#include <Processing/ImageFlags.h>
#include <Converters/PixelOperation.h>
#include <Compressors/ETC2.h>
#include <EtcConfig.h>
#include <Etc.h>
#include <EtcImage.h>
#include <EtcColorFloatRGBA.h>
namespace ImageProcessingAtom
{
//limited to 1 thread because AP requires so. We may change to n when AP allocate n thread to a job in the furture
static const int MAX_COMP_JOBS = 1;
static const int MIN_COMP_JOBS = 1;
static const float ETC_LOW_EFFORT_LEVEL = 25.0f;
static const float ETC_MED_EFFORT_LEVEL = 40.0f;
static const float ETC_HIGH_EFFORT_LEVEL = 80.0f;
//Grab the Etc2Comp specific pixel format enum
static Etc::Image::Format FindEtc2PixelFormat(EPixelFormat fmt)
{
switch (fmt)
{
case ePixelFormat_EAC_RG11:
return Etc::Image::Format::RG11;
case ePixelFormat_EAC_R11:
return Etc::Image::Format::R11;
case ePixelFormat_ETC2:
return Etc::Image::Format::RGB8;
case ePixelFormat_ETC2a1:
return Etc::Image::Format::RGB8A1;
case ePixelFormat_ETC2a:
return Etc::Image::Format::RGBA8;
default:
return Etc::Image::Format::FORMATS;
}
}
//Get the errmetric required for the compression
static Etc::ErrorMetric FindErrMetric(Etc::Image::Format fmt)
{
switch (fmt)
{
case Etc::Image::Format::RG11:
return Etc::ErrorMetric::NORMALXYZ;
case Etc::Image::Format::R11:
return Etc::ErrorMetric::NUMERIC;
case Etc::Image::Format::RGB8:
return Etc::ErrorMetric::RGBX;
case Etc::Image::Format::RGBA8:
case Etc::Image::Format::RGB8A1:
return Etc::ErrorMetric::RGBA;
default:
return Etc::ErrorMetric::ERROR_METRICS;
}
}
//Convert to sRGB format
static Etc::Image::Format FindGammaEtc2PixelFormat(Etc::Image::Format fmt)
{
switch (fmt)
{
case Etc::Image::Format::RGB8:
return Etc::Image::Format::SRGB8;
case Etc::Image::Format::RGBA8:
return Etc::Image::Format::SRGBA8;
case Etc::Image::Format::RGB8A1:
return Etc::Image::Format::SRGB8A1;
default:
return Etc::Image::Format::FORMATS;
}
}
bool ETC2Compressor::IsCompressedPixelFormatSupported(EPixelFormat fmt)
{
return (FindEtc2PixelFormat(fmt) != Etc::Image::Format::FORMATS);
}
bool ETC2Compressor::IsUncompressedPixelFormatSupported(EPixelFormat fmt)
{
//for uncompress format
if (fmt == ePixelFormat_R8G8B8A8)
{
return true;
}
return false;
}
EPixelFormat ETC2Compressor::GetSuggestedUncompressedFormat([[maybe_unused]] EPixelFormat compressedfmt, [[maybe_unused]] EPixelFormat uncompressedfmt) const
{
return ePixelFormat_R8G8B8A8;
}
bool ETC2Compressor::DoesSupportDecompress([[maybe_unused]] EPixelFormat fmtDst)
{
return false;
}
ColorSpace ETC2Compressor::GetSupportedColorSpace([[maybe_unused]] EPixelFormat compressFormat) const
{
return ColorSpace::autoSelect;
}
const char* ETC2Compressor::GetName() const
{
return "ETC2Compressor";
}
IImageObjectPtr ETC2Compressor::CompressImage(IImageObjectPtr srcImage, EPixelFormat fmtDst,
const CompressOption* compressOption) const
{
//validate input
EPixelFormat fmtSrc = srcImage->GetPixelFormat();
//src format need to be uncompressed and dst format need to compressed.
if (!IsUncompressedPixelFormatSupported(fmtSrc) || !IsCompressedPixelFormatSupported(fmtDst))
{
return nullptr;
}
IImageObjectPtr dstImage(srcImage->AllocateImage(fmtDst));
//determinate compression quality
ICompressor::EQuality quality = ICompressor::eQuality_Normal;
//get setting from compression option
if (compressOption)
{
quality = compressOption->compressQuality;
}
float qualityEffort = 0.0f;
switch (quality)
{
case eQuality_Preview:
case eQuality_Fast:
{
qualityEffort = ETC_LOW_EFFORT_LEVEL;
break;
}
case eQuality_Normal:
{
qualityEffort = ETC_MED_EFFORT_LEVEL;
break;
}
default:
{
qualityEffort = ETC_HIGH_EFFORT_LEVEL;
}
}
Etc::Image::Format dstEtc2Format = FindEtc2PixelFormat(fmtDst);
if (srcImage->GetImageFlags() & EIF_SRGBRead)
{
dstEtc2Format = FindGammaEtc2PixelFormat(dstEtc2Format);
}
//use to read pixel data from src image
IPixelOperationPtr pixelOp = CreatePixelOperation(fmtSrc);
//get count of bytes per pixel for images
AZ::u32 pixelBytes = CPixelFormats::GetInstance().GetPixelFormatInfo(fmtSrc)->bitsPerBlock / 8;
const AZ::u32 mipCount = dstImage->GetMipCount();
for (AZ::u32 mip = 0; mip < mipCount; ++mip)
{
const AZ::u32 width = srcImage->GetWidth(mip);
const AZ::u32 height = srcImage->GetHeight(mip);
// Prepare source data
AZ::u8* srcMem;
AZ::u32 srcPitch;
srcImage->GetImagePointer(mip, srcMem, srcPitch);
const AZ::u32 pixelCount = srcImage->GetPixelCount(mip);
Etc::ColorFloatRGBA* rgbaPixels = new Etc::ColorFloatRGBA[pixelCount];
Etc::ColorFloatRGBA* rgbaPixelPtr = rgbaPixels;
float r, g, b, a;
for (AZ::u32 pixelIdx = 0; pixelIdx < pixelCount; pixelIdx++, srcMem += pixelBytes, rgbaPixelPtr++)
{
pixelOp->GetRGBA(srcMem, r, g, b, a);
rgbaPixelPtr->fA = a;
rgbaPixelPtr->fR = r;
rgbaPixelPtr->fG = g;
rgbaPixelPtr->fB = b;
}
//Call into etc2Comp lib to compress. https://medium.com/@duhroach/building-a-blazing-fast-etc2-compressor-307f3e9aad99
Etc::ErrorMetric errMetric = FindErrMetric(dstEtc2Format);
unsigned char* paucEncodingBits;
unsigned int uiEncodingBitsBytes;
unsigned int uiExtendedWidth;
unsigned int uiExtendedHeight;
int iEncodingTime_ms;
Etc::Encode(reinterpret_cast<float*>(rgbaPixels),
width, height,
dstEtc2Format,
errMetric,
qualityEffort,
MIN_COMP_JOBS,
MAX_COMP_JOBS,
&paucEncodingBits, &uiEncodingBitsBytes,
&uiExtendedWidth, &uiExtendedHeight,
&iEncodingTime_ms);
AZ::u8* dstMem;
AZ::u32 dstPitch;
dstImage->GetImagePointer(mip, dstMem, dstPitch);
memcpy(dstMem, paucEncodingBits, uiEncodingBitsBytes);
delete[] rgbaPixels;
}
return dstImage;
}
IImageObjectPtr ETC2Compressor::DecompressImage(IImageObjectPtr srcImage, [[maybe_unused]] EPixelFormat fmtDst) const
{
//etc2Comp doesn't support decompression
//Since PVRTexLib support ETC formats too. It may take over the decompression.
return nullptr;
}
} // namespace ImageProcessingAtom

@ -1,31 +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
*
*/
#pragma once
#include <Compressors/Compressor.h>
namespace ImageProcessingAtom
{
class ETC2Compressor
: public ICompressor
{
public:
static bool IsCompressedPixelFormatSupported(EPixelFormat fmt);
static bool IsUncompressedPixelFormatSupported(EPixelFormat fmt);
static bool DoesSupportDecompress(EPixelFormat fmtDst);
IImageObjectPtr CompressImage(IImageObjectPtr srcImage, EPixelFormat fmtDst, const CompressOption* compressOption) const override;
IImageObjectPtr DecompressImage(IImageObjectPtr srcImage, EPixelFormat fmtDst) const override;
EPixelFormat GetSuggestedUncompressedFormat(EPixelFormat compressedfmt, EPixelFormat uncompressedfmt) const override;
ColorSpace GetSupportedColorSpace(EPixelFormat compressFormat) const final;
const char* GetName() const final;
};
} // namespace ImageProcessingAtom

@ -1,338 +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
*
*/
#include <ImageProcessing_Traits_Platform.h>
#include <AzCore/PlatformIncl.h>
#include <Atom/ImageProcessing/ImageObject.h>
#include <Processing/ImageFlags.h>
#include <Processing/PixelFormatInfo.h>
#include <Compressors/PVRTC.h>
#include <PVRTexture.h>
#include <PVRTextureUtilities.h>
namespace ImageProcessingAtom
{
// Note: PVRTexLib supports ETC formats, PVRTC formats and BC formats
// We haven't tested the performace to compress BC formats compare to CTSquisher
// For PVRTC formats, we only added PVRTC 1 support for now
// The compression for ePVRTPF_EAC_R11 and ePVRTPF_EAC_RG11 are very slow. It takes 7 and 14 minutes for a 2048x2048 texture.
EPVRTPixelFormat FindPvrPixelFormat(EPixelFormat fmt)
{
switch (fmt)
{
case ePixelFormat_PVRTC2:
return ePVRTPF_PVRTCI_2bpp_RGBA;
case ePixelFormat_PVRTC4:
return ePVRTPF_PVRTCI_4bpp_RGBA;
case ePixelFormat_EAC_R11:
return ePVRTPF_EAC_R11;
case ePixelFormat_EAC_RG11:
return ePVRTPF_EAC_RG11;
case ePixelFormat_ETC2:
return ePVRTPF_ETC2_RGB;
case ePixelFormat_ETC2a1:
return ePVRTPF_ETC2_RGB_A1;
case ePixelFormat_ETC2a:
return ePVRTPF_ETC2_RGBA;
default:
return ePVRTPF_NumCompressedPFs;
}
}
bool PVRTCCompressor::IsCompressedPixelFormatSupported(EPixelFormat fmt)
{
return (FindPvrPixelFormat(fmt) != ePVRTPF_NumCompressedPFs);
}
bool PVRTCCompressor::IsUncompressedPixelFormatSupported(EPixelFormat fmt)
{
//for uncompress format
if (fmt == ePixelFormat_R8G8B8A8)
{
return true;
}
return false;
}
EPixelFormat PVRTCCompressor::GetSuggestedUncompressedFormat([[maybe_unused]] EPixelFormat compressedfmt, [[maybe_unused]] EPixelFormat uncompressedfmt) const
{
return ePixelFormat_R8G8B8A8;
}
ColorSpace PVRTCCompressor::GetSupportedColorSpace([[maybe_unused]] EPixelFormat compressFormat) const
{
return ColorSpace::autoSelect;
}
const char* PVRTCCompressor::GetName() const
{
return "PVRTCCompressor";
}
bool PVRTCCompressor::DoesSupportDecompress([[maybe_unused]] EPixelFormat fmtDst)
{
return true;
}
IImageObjectPtr PVRTCCompressor::CompressImage(IImageObjectPtr srcImage, EPixelFormat fmtDst,
const CompressOption* compressOption) const
{
//validate input
EPixelFormat fmtSrc = srcImage->GetPixelFormat();
//src format need to be uncompressed and dst format need to compressed.
if (!IsUncompressedPixelFormatSupported(fmtSrc) || !IsCompressedPixelFormatSupported(fmtDst))
{
return nullptr;
}
IImageObjectPtr dstImage(srcImage->AllocateImage(fmtDst));
//determinate compression quality
pvrtexture::ECompressorQuality internalQuality = pvrtexture::eETCFast;
ICompressor::EQuality quality = ICompressor::eQuality_Normal;
AZ::Vector3 uniformWeights = AZ::Vector3(0.3333f, 0.3334f, 0.3333f);
AZ::Vector3 weights = uniformWeights;
bool isUniform = true;
//get setting from compression option
if (compressOption)
{
quality = compressOption->compressQuality;
weights = compressOption->rgbWeight;
isUniform = (weights == uniformWeights);
}
if (IsETCFormat(fmtDst))
{
if ((quality <= eQuality_Normal) && isUniform)
{
internalQuality = pvrtexture::eETCFast;
}
else if (quality <= eQuality_Normal)
{
internalQuality = pvrtexture::eETCNormal;
}
else if (isUniform)
{
internalQuality = pvrtexture::eETCSlow;
}
else
{
internalQuality = pvrtexture::eETCSlow;
}
}
else
{
if (quality == eQuality_Preview)
{
internalQuality = pvrtexture::ePVRTCFastest;
}
else if (quality == eQuality_Fast)
{
internalQuality = pvrtexture::ePVRTCFast;
}
else if (quality == eQuality_Normal)
{
internalQuality = pvrtexture::ePVRTCNormal;
}
else
{
internalQuality = pvrtexture::ePVRTCHigh;
}
}
// setup color space
EPVRTColourSpace cspace = ePVRTCSpacelRGB;
if (srcImage->GetImageFlags() & EIF_SRGBRead)
{
cspace = ePVRTCSpacesRGB;
}
//setup src texture for compression
const pvrtexture::PixelType srcPixelType('r', 'g', 'b', 'a', 8, 8, 8, 8);
const AZ::u32 dstMips = dstImage->GetMipCount();
for (AZ::u32 mip = 0; mip < dstMips; ++mip)
{
const AZ::u32 width = srcImage->GetWidth(mip);
const AZ::u32 height = srcImage->GetHeight(mip);
// Prepare source data
AZ::u8* srcMem;
uint32 srcPitch;
srcImage->GetImagePointer(mip, srcMem, srcPitch);
const pvrtexture::CPVRTextureHeader srcHeader(
srcPixelType.PixelTypeID, // AZ::u64 u64PixelFormat,
width, // uint32 u32Height=1,
height, // uint32 u32Width=1,
1, // uint32 u32Depth=1,
1, // uint32 u32NumMipMaps=1,
1, // uint32 u32NumArrayMembers=1,
1, // uint32 u32NumFaces=1,
cspace, // EPVRTColourSpace eColourSpace=ePVRTCSpacelRGB,
ePVRTVarTypeUnsignedByteNorm, // EPVRTVariableType eChannelType=ePVRTVarTypeUnsignedByteNorm,
false); // bool bPreMultiplied=false);
pvrtexture::CPVRTexture compressTexture(srcHeader, srcMem);
//compressing
bool isSuccess = false;
#if AZ_TRAIT_IMAGEPROCESSING_SUPPORT_TRY_CATCH
try
#endif // AZ_TRAIT_IMAGEPROCESSING_SUPPORT_TRY_CATCH
{
isSuccess = pvrtexture::Transcode(
compressTexture,
pvrtexture::PixelType(FindPvrPixelFormat(fmtDst)),
ePVRTVarTypeUnsignedByteNorm,
cspace,
internalQuality);
}
#if AZ_TRAIT_IMAGEPROCESSING_SUPPORT_TRY_CATCH
catch (...)
{
AZ_Error("Image Processing", false, "Unknown exception in PVRTexLib");
return nullptr;
}
#endif // AZ_TRAIT_IMAGEPROCESSING_SUPPORT_TRY_CATCH
if (!isSuccess)
{
AZ_Error("Image Processing", false, "Failed to compress image with PVRTexLib.");
return nullptr;
}
// Getting compressed data
const void* const compressedData = compressTexture.getDataPtr();
if (!compressedData)
{
AZ_Error("Image Processing", false, "Failed to obtain compressed image data by using PVRTexLib");
return nullptr;
}
const AZ::u32 compressedDataSize = compressTexture.getDataSize();
if (dstImage->GetMipBufSize(mip) != compressedDataSize)
{
AZ_Error("Image Processing", false, "Compressed image data size mismatch while using PVRTexLib");
return nullptr;
}
//save compressed data to dst image
AZ::u8* dstMem;
AZ::u32 dstPitch;
dstImage->GetImagePointer(mip, dstMem, dstPitch);
memcpy(dstMem, compressedData, compressedDataSize);
}
return dstImage;
}
IImageObjectPtr PVRTCCompressor::DecompressImage(IImageObjectPtr srcImage, EPixelFormat fmtDst) const
{
//validate input
EPixelFormat fmtSrc = srcImage->GetPixelFormat(); //compressed
if (!IsCompressedPixelFormatSupported(fmtSrc) || !IsUncompressedPixelFormatSupported(fmtDst))
{
return nullptr;
}
EPVRTColourSpace colorSpace = ePVRTCSpacelRGB;
if (srcImage->GetImageFlags() & EIF_SRGBRead)
{
colorSpace = ePVRTCSpacesRGB;
}
IImageObjectPtr dstImage(srcImage->AllocateImage(fmtDst));
const AZ::u32 mipCount = dstImage->GetMipCount();
for (AZ::u32 mip = 0; mip < mipCount; ++mip)
{
const AZ::u32 width = srcImage->GetWidth(mip);
const AZ::u32 height = srcImage->GetHeight(mip);
// Preparing source compressed data
const pvrtexture::CPVRTextureHeader compressedHeader(
FindPvrPixelFormat(fmtSrc), // AZ::u64 u64PixelFormat,
width, // uint32 u32Height=1,
height, // uint32 u32Width=1,
1, // uint32 u32Depth=1,
1, // uint32 u32NumMipMaps=1,
1, // uint32 u32NumArrayMembers=1,
1, // uint32 u32NumFaces=1,
colorSpace, // EPVRTColourSpace eColourSpace=ePVRTCSpacelRGB,
ePVRTVarTypeUnsignedByteNorm, // EPVRTVariableType eChannelType=ePVRTVarTypeUnsignedByteNorm,
false); // bool bPreMultiplied=false);
const AZ::u32 compressedDataSize = compressedHeader.getDataSize();
if (srcImage->GetMipBufSize(mip) != compressedDataSize)
{
AZ_Error("Image Processing", false, "Decompressed image data size mismatch while using PVRTexLib");
return nullptr;
}
AZ::u8* srcMem;
AZ::u32 srcPitch;
srcImage->GetImagePointer(mip, srcMem, srcPitch);
pvrtexture::CPVRTexture cTexture(compressedHeader, srcMem);
// Decompress
bool bOk = false;
#if AZ_TRAIT_IMAGEPROCESSING_SUPPORT_TRY_CATCH
try
{
#endif // AZ_TRAIT_IMAGEPROCESSING_SUPPORT_TRY_CATCH
bOk = pvrtexture::Transcode(
cTexture,
pvrtexture::PVRStandard8PixelType,
ePVRTVarTypeUnsignedByteNorm,
colorSpace,
pvrtexture::ePVRTCHigh);
#if AZ_TRAIT_IMAGEPROCESSING_SUPPORT_TRY_CATCH
}
catch (...)
{
AZ_Error("Image Processing", false, "Unknown exception in PVRTexLib when decompressing");
return nullptr;
}
#endif // AZ_TRAIT_IMAGEPROCESSING_SUPPORT_TRY_CATCH
if (!bOk)
{
AZ_Error("Image Processing", false, "Failed to decompress an image by using PVRTexLib");
return nullptr;
}
// Getting decompressed data
const void* const pDecompressedData = cTexture.getDataPtr();
if (!pDecompressedData)
{
AZ_Error("Image Processing", false, "Failed to obtain decompressed image data by using PVRTexLib");
return nullptr;
}
const AZ::u32 decompressedDataSize = cTexture.getDataSize();
if (dstImage->GetMipBufSize(mip) != decompressedDataSize)
{
AZ_Error("Image Processing", false, "Decompressed image data size mismatch while using PVRTexLib");
return nullptr;
}
//save decompressed image to dst image
AZ::u8* dstMem;
AZ::u32 dstPitch;
dstImage->GetImagePointer(mip, dstMem, dstPitch);
memcpy(dstMem, pDecompressedData, decompressedDataSize);
}
return dstImage;
}
} //namespace ImageProcessingAtom

@ -1,30 +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
*
*/
#pragma once
#include <Compressors/Compressor.h>
namespace ImageProcessingAtom
{
class PVRTCCompressor
: public ICompressor
{
public:
static bool IsCompressedPixelFormatSupported(EPixelFormat fmt);
static bool IsUncompressedPixelFormatSupported(EPixelFormat fmt);
static bool DoesSupportDecompress(EPixelFormat fmtDst);
IImageObjectPtr CompressImage(IImageObjectPtr srcImage, EPixelFormat fmtDst, const CompressOption* compressOption) const override;
IImageObjectPtr DecompressImage(IImageObjectPtr srcImage, EPixelFormat fmtDst) const override;
EPixelFormat GetSuggestedUncompressedFormat(EPixelFormat compressedfmt, EPixelFormat uncompressedfmt) const override;
ColorSpace GetSupportedColorSpace(EPixelFormat compressFormat) const final;
const char* GetName() const final;
};
} // namespace ImageProcessingAtom

@ -82,7 +82,6 @@ namespace ImageProcessingAtomEditor
presetInfoText += "\n"; presetInfoText += "\n";
presetInfoText += QString("Suppress Engine Reduce: %1\n").arg(presetSettings->m_suppressEngineReduce ? "True" : "False"); presetInfoText += QString("Suppress Engine Reduce: %1\n").arg(presetSettings->m_suppressEngineReduce ? "True" : "False");
presetInfoText += QString("Discard Alpha: %1\n").arg(presetSettings->m_discardAlpha ? "True" : "False"); presetInfoText += QString("Discard Alpha: %1\n").arg(presetSettings->m_discardAlpha ? "True" : "False");
presetInfoText += QString("Is Power Of 2: %1\n").arg(presetSettings->m_isPowerOf2 ? "True" : "False");
presetInfoText += QString("Is Color Chart: %1\n").arg(presetSettings->m_isColorChart ? "True" : "False"); presetInfoText += QString("Is Color Chart: %1\n").arg(presetSettings->m_isColorChart ? "True" : "False");
presetInfoText += QString("High Pass Mip: %1\n").arg(presetSettings->m_highPassMip); presetInfoText += QString("High Pass Mip: %1\n").arg(presetSettings->m_highPassMip);
presetInfoText += QString("Gloss From Normal: %1\n").arg(presetSettings->m_glossFromNormals); presetInfoText += QString("Gloss From Normal: %1\n").arg(presetSettings->m_glossFromNormals);

@ -24,201 +24,6 @@ namespace ImageProcessingAtom
{ {
namespace DdsLoader namespace DdsLoader
{ {
IImageObject* CreateImageFromHeaderLegacy(DDS_HEADER_LEGACY& header, DDS_HEADER_DXT10& exthead)
{
EPixelFormat eFormat = ePixelFormat_Unknown;
AZ::u32 dwWidth, dwMips, dwHeight;
AZ::u32 imageFlags = header.dwReserved1;
AZ::Color colMinARGB, colMaxARGB;
dwWidth = header.dwWidth;
dwHeight = header.dwHeight;
dwMips = 1;
if (header.dwHeaderFlags & DDS_HEADER_FLAGS_MIPMAP)
{
dwMips = header.dwMipMapCount;
}
if ((header.dwSurfaceFlags & DDS_SURFACE_FLAGS_CUBEMAP) && (header.dwCubemapFlags & DDS_CUBEMAP_ALLFACES))
{
AZ_Assert(header.dwReserved1 & EIF_Cubemap, "Image flag should have cubemap flag");
dwHeight *= 6;
}
colMinARGB = AZ::Color(header.cMinColor[0], header.cMinColor[1], header.cMinColor[2], header.cMinColor[3]);
colMaxARGB = AZ::Color(header.cMaxColor[0], header.cMaxColor[1], header.cMaxColor[2], header.cMaxColor[3]);
//get pixel format
{
// DX10 formats
if (header.ddspf.dwFourCC == FOURCC_DX10)
{
AZ::u32 dxgiFormat = exthead.dxgiFormat;
//remove the SRGB from dxgi format and add sRGB to image flag
if (dxgiFormat == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB)
{
dxgiFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
}
else if (dxgiFormat == DXGI_FORMAT_BC1_UNORM_SRGB)
{
dxgiFormat = DXGI_FORMAT_BC1_UNORM;
}
else if (dxgiFormat == DXGI_FORMAT_BC2_UNORM_SRGB)
{
dxgiFormat = DXGI_FORMAT_BC2_UNORM;
}
else if (dxgiFormat == DXGI_FORMAT_BC3_UNORM_SRGB)
{
dxgiFormat = DXGI_FORMAT_BC3_UNORM;
}
else if (dxgiFormat == DXGI_FORMAT_BC7_UNORM_SRGB)
{
dxgiFormat = DXGI_FORMAT_BC7_UNORM;
}
//add rgb flag if the dxgiformat was changed (which means it was sRGB format) above
if (dxgiFormat != exthead.dxgiFormat)
{
AZ_Assert(imageFlags & EIF_SRGBRead, "Image flags should have SRGBRead flag");
imageFlags |= EIF_SRGBRead;
}
//check all the pixel formats and find matching one
if (dxgiFormat != DXGI_FORMAT_UNKNOWN)
{
int i = 0;
for (; i < ePixelFormat_Count; i++)
{
const PixelFormatInfo* info = CPixelFormats::GetInstance().GetPixelFormatInfo((EPixelFormat)i);
if (static_cast<AZ::u32>(info->d3d10Format) == dxgiFormat)
{
eFormat = (EPixelFormat)i;
break;
}
}
if (i == ePixelFormat_Count)
{
AZ_Error("Image Processing", false, "Unhandled d3d10 format: %d", dxgiFormat);
return nullptr;
}
}
}
else
{
//for non-dx10 formats, use fourCC to find out its pixel formats
//go through all pixel formats and find a match with the fourcc
for (AZ::u32 formatIdx = 0; formatIdx < ePixelFormat_Count; formatIdx++)
{
const PixelFormatInfo* info = CPixelFormats::GetInstance().GetPixelFormatInfo((EPixelFormat)formatIdx);
if (header.ddspf.dwFourCC == info->fourCC)
{
eFormat = (EPixelFormat)formatIdx;
break;
}
}
//legacy formats. This section is only used for load dds files converted by RC.exe
//our save to dds file function won't use any of these fourcc
if (eFormat == ePixelFormat_Unknown)
{
if (header.ddspf.dwFourCC == FOURCC_DXT1)
{
eFormat = ePixelFormat_BC1;
}
else if (header.ddspf.dwFourCC == FOURCC_DXT5)
{
eFormat = ePixelFormat_BC3;
}
else if (header.ddspf.dwFourCC == FOURCC_3DCP)
{
eFormat = ePixelFormat_BC4;
}
else if (header.ddspf.dwFourCC == FOURCC_3DC)
{
eFormat = ePixelFormat_BC5;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_R32F)
{
eFormat = ePixelFormat_R32F;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_G32R32F)
{
eFormat = ePixelFormat_R32G32F;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_A32B32G32R32F)
{
eFormat = ePixelFormat_R32G32B32A32F;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_R16F)
{
eFormat = ePixelFormat_R16F;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_G16R16F)
{
eFormat = ePixelFormat_R16G16F;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_A16B16G16R16F)
{
eFormat = ePixelFormat_R16G16B16A16F;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_A16B16G16R16)
{
eFormat = ePixelFormat_R16G16B16A16;
}
else if ((header.ddspf.dwFlags == DDS_RGBA || header.ddspf.dwFlags == DDS_RGB)
&& header.ddspf.dwRGBBitCount == 32)
{
if (header.ddspf.dwRBitMask == 0x00ff0000)
{
eFormat = ePixelFormat_B8G8R8A8;
}
else
{
eFormat = ePixelFormat_R8G8B8A8;
}
}
else if (header.ddspf.dwFlags == DDS_LUMINANCEA && header.ddspf.dwRGBBitCount == 8)
{
eFormat = ePixelFormat_R8G8;
}
else if (header.ddspf.dwFlags == DDS_LUMINANCE && header.ddspf.dwRGBBitCount == 8)
{
eFormat = ePixelFormat_A8;
}
else if ((header.ddspf.dwFlags == DDS_A || header.ddspf.dwFlags == DDS_A_ONLY || header.ddspf.dwFlags == (DDS_A | DDS_A_ONLY)) && header.ddspf.dwRGBBitCount == 8)
{
eFormat = ePixelFormat_A8;
}
}
}
}
if (eFormat == ePixelFormat_Unknown)
{
AZ_Error("Image Processing", false, "Unhandled dds pixel format fourCC: %d, flags: %d",
header.ddspf.dwFourCC, header.ddspf.dwFlags);
return nullptr;
}
IImageObject* newImage = IImageObject::CreateImage(dwWidth, dwHeight, dwMips, eFormat);
if (dwMips != newImage->GetMipCount())
{
AZ_Error("Image Processing", false, "Mipcount from image data doesn't match image size and pixelformat");
delete newImage;
return nullptr;
}
//set properties
newImage->SetImageFlags(imageFlags);
newImage->SetAverageBrightness(header.fAvgBrightness);
newImage->SetColorRange(colMinARGB, colMaxARGB);
newImage->SetNumPersistentMips(header.bNumPersistentMips);
return newImage;
}
bool IsExtensionSupported(const char* extension) bool IsExtensionSupported(const char* extension)
{ {
QString ext = QString(extension).toLower(); QString ext = QString(extension).toLower();
@ -226,215 +31,6 @@ namespace ImageProcessingAtom
return ext == "dds"; return ext == "dds";
} }
IImageObject* LoadImageFromFileLegacy(const AZStd::string& filename)
{
AZ::IO::SystemFile file;
file.Open(filename.c_str(), AZ::IO::SystemFile::SF_OPEN_READ_ONLY);
AZ::IO::SystemFileStream fileLoadStream(&file, true);
if (!fileLoadStream.IsOpen())
{
AZ_Warning("Image Processing", false, "%s: failed to open file %s", __FUNCTION__, filename.c_str());
return nullptr;
}
AZStd::string ext = "";
AzFramework::StringFunc::Path::GetExtension(filename.c_str(), ext, false);
bool isAlphaImage = (ext == "a");
IImageObject* imageObj = LoadImageFromFileStreamLegacy(fileLoadStream);
//load mips from seperated files if it's splitted
if (imageObj && imageObj->HasImageFlags(EIF_Splitted))
{
AZStd::string baseName;
if (isAlphaImage)
{
baseName = filename.substr(0, filename.size() - 2);
}
else
{
baseName = filename;
}
AZ::u32 externalMipCount = 0;
if (imageObj->GetNumPersistentMips() < imageObj->GetMipCount())
{
externalMipCount = imageObj->GetMipCount() - imageObj->GetNumPersistentMips();
}
//load other mips from files with number extensions
for (AZ::u32 mipIdx = 1; mipIdx <= externalMipCount; mipIdx++)
{
AZ::u32 mip = externalMipCount - mipIdx;
AZStd::string mipFileName = AZStd::string::format("%s.%d%s", baseName.c_str(), mipIdx, isAlphaImage ? "a" : "");
AZ::IO::SystemFile mipFile;
mipFile.Open(mipFileName.c_str(), AZ::IO::SystemFile::SF_OPEN_READ_ONLY);
AZ::IO::SystemFileStream mipFileLoadStream(&mipFile, true);
if (!mipFileLoadStream.IsOpen())
{
AZ_Warning("Image Processing", false, "%s: failed to open mip file %s", __FUNCTION__, mipFileName.c_str());
break;
}
AZ::u32 pitch;
AZ::u8* mem;
imageObj->GetImagePointer(mip, mem, pitch);
AZ::u32 bufSize = imageObj->GetMipBufSize(mip);
mipFileLoadStream.Read(bufSize, mem);
}
}
return imageObj;
}
IImageObject* LoadImageFromFileStreamLegacy(AZ::IO::SystemFileStream& fileLoadStream)
{
if (fileLoadStream.GetLength() - fileLoadStream.GetCurPos() < sizeof(DDS_FILE_DESC_LEGACY))
{
AZ_Error("Image Processing", false, "%s: Trying to load a none-DDS file", __FUNCTION__);
return nullptr;
}
DDS_FILE_DESC_LEGACY desc;
DDS_HEADER_DXT10 exthead;
AZ::IO::SizeType startPos = fileLoadStream.GetCurPos();
fileLoadStream.Read(sizeof(desc.dwMagic), &desc.dwMagic);
if (desc.dwMagic != FOURCC_DDS)
{
desc.dwMagic = FOURCC_DDS;
//the old cry .a file doesn't have "DDS " in the beginning of the file.
//so reset to previous position
fileLoadStream.Seek(startPos, AZ::IO::GenericStream::ST_SEEK_BEGIN);
}
fileLoadStream.Read(sizeof(desc.header), &desc.header);
if (!desc.IsValid())
{
AZ_Error("Image Processing", false, "%s: Trying to load a none-DDS file", __FUNCTION__);
return nullptr;
}
if (desc.header.IsDX10Ext())
{
fileLoadStream.Read(sizeof(exthead), &exthead);
}
IImageObject* outImage = CreateImageFromHeaderLegacy(desc.header, exthead);
if (outImage == nullptr)
{
return nullptr;
}
//load mip data
AZ::u32 mipStart = 0;
//There are at least three lowest mips are in the file if it was splitted. This is to load splitted dds file exported by legacy rc.exe
int numPersistentMips = outImage->GetNumPersistentMips();
if (numPersistentMips == 0 && outImage->HasImageFlags(EIF_Splitted))
{
outImage->SetNumPersistentMips(3);
}
if (outImage->HasImageFlags(EIF_Splitted)
&& outImage->GetMipCount() > outImage->GetNumPersistentMips())
{
mipStart = outImage->GetMipCount() - outImage->GetNumPersistentMips();
}
AZ::u32 faces = 1;
if (outImage->HasImageFlags(EIF_Cubemap))
{
faces = 6;
}
for (AZ::u32 face = 0; face < faces; face++)
{
for (AZ::u32 mip = mipStart; mip < outImage->GetMipCount(); ++mip)
{
AZ::u32 pitch;
AZ::u8* mem;
outImage->GetImagePointer(mip, mem, pitch);
AZ::u32 faceBufSize = outImage->GetMipBufSize(mip) / faces;
fileLoadStream.Read(faceBufSize, mem + faceBufSize * face);
}
}
return outImage;
}
IImageObject* LoadAttachedImageFromDdsFileLegacy(const AZStd::string& filename, IImageObjectPtr originImage)
{
if (originImage == nullptr)
{
return nullptr;
}
AZ_Assert(originImage->HasImageFlags(EIF_AttachedAlpha),
"this function should only be called for origin image loaded from same file with attached alpha flag");
AZ::IO::SystemFile file;
file.Open(filename.c_str(), AZ::IO::SystemFile::SF_OPEN_READ_ONLY);
AZ::IO::SystemFileStream fileLoadStream(&file, true);
if (!fileLoadStream.IsOpen())
{
AZ_Warning("Image Processing", false, "%s: failed to open file %s", __FUNCTION__, filename.c_str());
return nullptr;
}
DDS_FILE_DESC_LEGACY desc;
DDS_HEADER_DXT10 exthead;
fileLoadStream.Read(sizeof(desc), &desc);
if (desc.dwMagic != FOURCC_DDS)
{
AZ_Error("Image Processing", false, "%s:Trying to load a none-DDS file", __FUNCTION__);
return nullptr;
}
if (desc.header.IsDX10Ext())
{
fileLoadStream.Read(sizeof(exthead), &exthead);
}
//skip size for originImage's mip data
for (AZ::u32 mip = 0; mip < originImage->GetMipCount(); ++mip)
{
AZ::u32 bufSize = originImage->GetMipBufSize(mip);
fileLoadStream.Seek(bufSize, AZ::IO::GenericStream::ST_SEEK_CUR);
}
IImageObject* alphaImage = nullptr;
AZ::u32 marker = 0;
fileLoadStream.Read(4, &marker);
if (marker == FOURCC_CExt) // marker for the start of O3DE Extended data
{
fileLoadStream.Read(4, &marker);
if (FOURCC_AttC == marker) // Attached Channel chunk
{
AZ::u32 size = 0;
fileLoadStream.Read(4, &size);
alphaImage = LoadImageFromFileStreamLegacy(fileLoadStream);
fileLoadStream.Read(4, &marker);
}
if (FOURCC_CEnd == marker) // marker for the end of O3DE Extended data
{
fileLoadStream.Read(4, &marker);
}
}
return alphaImage;
}
// Create an image object from standard dds header // Create an image object from standard dds header
IImageObject* CreateImageFromHeader(DDS_HEADER& header, DDS_HEADER_DXT10& exthead) IImageObject* CreateImageFromHeader(DDS_HEADER& header, DDS_HEADER_DXT10& exthead)
{ {
@ -526,45 +122,14 @@ namespace ImageProcessingAtom
{ {
format = ePixelFormat_BC1; format = ePixelFormat_BC1;
} }
else if (header.ddspf.dwFourCC == FOURCC_DXT5) else if (header.ddspf.dwFourCC == FOURCC_DXT5 || header.ddspf.dwFourCC == FOURCC_DXT4)
{ {
format = ePixelFormat_BC3; format = ePixelFormat_BC3;
} }
else if (header.ddspf.dwFourCC == FOURCC_3DCP) else
{
format = ePixelFormat_BC4;
}
else if (header.ddspf.dwFourCC == FOURCC_3DC)
{
format = ePixelFormat_BC5;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_R32F)
{
format = ePixelFormat_R32F;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_G32R32F)
{
format = ePixelFormat_R32G32F;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_A32B32G32R32F)
{
format = ePixelFormat_R32G32B32A32F;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_R16F)
{
format = ePixelFormat_R16F;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_G16R16F)
{
format = ePixelFormat_R16G16F;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_A16B16G16R16F)
{
format = ePixelFormat_R16G16B16A16F;
}
else if (header.ddspf.dwFourCC == DDS_FOURCC_A16B16G16R16)
{ {
format = ePixelFormat_R16G16B16A16; AZ_Error("Image Processing", false, "unsupported fourCC format: 0x%x", header.ddspf.dwFourCC);
return nullptr;
} }
} }
else else

@ -44,11 +44,6 @@ namespace ImageProcessingAtom
{ {
bool IsExtensionSupported(const char* extension); bool IsExtensionSupported(const char* extension);
IImageObject* LoadImageFromFile(const AZStd::string& filename); IImageObject* LoadImageFromFile(const AZStd::string& filename);
// These functions are for loading legacy O3DE dds files
IImageObject* LoadImageFromFileLegacy(const AZStd::string& filename);
IImageObject* LoadImageFromFileStreamLegacy(AZ::IO::SystemFileStream& fileLoadStream);
IImageObject* LoadAttachedImageFromDdsFileLegacy(const AZStd::string& filename, IImageObjectPtr originImage);
};// namespace DdsLoader };// namespace DdsLoader
// Load .exr files to an image object // Load .exr files to an image object

@ -5,8 +5,3 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT # SPDX-License-Identifier: Apache-2.0 OR MIT
# #
# #
set(LY_COMPILE_OPTIONS
PRIVATE
-fexceptions #ImageLoader/ExrLoader.cpp and PVRTC.cpp uses exceptions
)

@ -237,14 +237,8 @@ namespace ImageProcessingAtom
const static AZ::u32 FOURCC_CEnd = IMAGE_BUIDER_MAKEFOURCC('C', 'E', 'n', 'd'); // O3DE extension end const static AZ::u32 FOURCC_CEnd = IMAGE_BUIDER_MAKEFOURCC('C', 'E', 'n', 'd'); // O3DE extension end
const static AZ::u32 FOURCC_AttC = IMAGE_BUIDER_MAKEFOURCC('A', 't', 't', 'C'); // Chunk Attached Channel const static AZ::u32 FOURCC_AttC = IMAGE_BUIDER_MAKEFOURCC('A', 't', 't', 'C'); // Chunk Attached Channel
//Fourcc for pixel formats which aren't supported by dx10, such as astc formats, etc formats, pvrtc formats //Fourcc for pixel formats which aren't supported by dx10, such as astc formats
//They are used for dwFourCC of dds header's DDS_PIXELFORMAT to identify non-dx10 pixel formats //They are used for dwFourCC of dds header's DDS_PIXELFORMAT to identify non-dx10 pixel formats
const static AZ::u32 FOURCC_EAC_R11 = IMAGE_BUIDER_MAKEFOURCC('E', 'A', 'R', ' ');
const static AZ::u32 FOURCC_EAC_RG11 = IMAGE_BUIDER_MAKEFOURCC('E', 'A', 'R', 'G');
const static AZ::u32 FOURCC_ETC2 = IMAGE_BUIDER_MAKEFOURCC('E', 'T', '2', ' ');
const static AZ::u32 FOURCC_ETC2A = IMAGE_BUIDER_MAKEFOURCC('E', 'T', '2', 'A');
const static AZ::u32 FOURCC_PVRTC2 = IMAGE_BUIDER_MAKEFOURCC('P', 'V', 'R', '2');
const static AZ::u32 FOURCC_PVRTC4 = IMAGE_BUIDER_MAKEFOURCC('P', 'V', 'R', '4');
const static AZ::u32 FOURCC_ASTC_4x4 = IMAGE_BUIDER_MAKEFOURCC('A', 'S', '4', '4'); const static AZ::u32 FOURCC_ASTC_4x4 = IMAGE_BUIDER_MAKEFOURCC('A', 'S', '4', '4');
const static AZ::u32 FOURCC_ASTC_5x4 = IMAGE_BUIDER_MAKEFOURCC('A', 'S', '5', '4'); const static AZ::u32 FOURCC_ASTC_5x4 = IMAGE_BUIDER_MAKEFOURCC('A', 'S', '5', '4');
const static AZ::u32 FOURCC_ASTC_5x5 = IMAGE_BUIDER_MAKEFOURCC('A', 'S', '5', '5'); const static AZ::u32 FOURCC_ASTC_5x5 = IMAGE_BUIDER_MAKEFOURCC('A', 'S', '5', '5');
@ -260,10 +254,10 @@ namespace ImageProcessingAtom
const static AZ::u32 FOURCC_ASTC_12x10 = IMAGE_BUIDER_MAKEFOURCC('A', 'S', 'C', 'A'); const static AZ::u32 FOURCC_ASTC_12x10 = IMAGE_BUIDER_MAKEFOURCC('A', 'S', 'C', 'A');
const static AZ::u32 FOURCC_ASTC_12x12 = IMAGE_BUIDER_MAKEFOURCC('A', 'S', 'C', 'C'); const static AZ::u32 FOURCC_ASTC_12x12 = IMAGE_BUIDER_MAKEFOURCC('A', 'S', 'C', 'C');
//legacy formats names. they are only used for load rc.exe's dds formats //legacy formats names. they are only used for load old dds formats.
const static AZ::u32 FOURCC_DXT1 = IMAGE_BUIDER_MAKEFOURCC('D', 'X', 'T', '1'); const static AZ::u32 FOURCC_DXT1 = IMAGE_BUIDER_MAKEFOURCC('D', 'X', 'T', '1');
const static AZ::u32 FOURCC_DXT2 = IMAGE_BUIDER_MAKEFOURCC('D', 'X', 'T', '2');
const static AZ::u32 FOURCC_DXT3 = IMAGE_BUIDER_MAKEFOURCC('D', 'X', 'T', '3'); const static AZ::u32 FOURCC_DXT3 = IMAGE_BUIDER_MAKEFOURCC('D', 'X', 'T', '3');
const static AZ::u32 FOURCC_DXT4 = IMAGE_BUIDER_MAKEFOURCC('D', 'X', 'T', '4');
const static AZ::u32 FOURCC_DXT5 = IMAGE_BUIDER_MAKEFOURCC('D', 'X', 'T', '5'); const static AZ::u32 FOURCC_DXT5 = IMAGE_BUIDER_MAKEFOURCC('D', 'X', 'T', '5');
const static AZ::u32 FOURCC_3DCP = IMAGE_BUIDER_MAKEFOURCC('A', 'T', 'I', '1');
const static AZ::u32 FOURCC_3DC = IMAGE_BUIDER_MAKEFOURCC('A', 'T', 'I', '2');
} }

@ -52,19 +52,6 @@ namespace ImageProcessingAtom
return false; return false;
} }
bool IsETCFormat(EPixelFormat fmt)
{
if (fmt == ePixelFormat_ETC2
|| fmt == ePixelFormat_ETC2a
|| fmt == ePixelFormat_ETC2a1
|| fmt == ePixelFormat_EAC_R11
|| fmt == ePixelFormat_EAC_RG11)
{
return true;
}
return false;
}
PixelFormatInfo::PixelFormatInfo( PixelFormatInfo::PixelFormatInfo(
uint32_t a_bitsPerPixel, uint32_t a_bitsPerPixel,
uint32_t a_Channels, uint32_t a_Channels,
@ -96,7 +83,6 @@ namespace ImageProcessingAtom
, fourCC(a_fourCC) , fourCC(a_fourCC)
, eSampleType(a_eSampleType) , eSampleType(a_eSampleType)
, szName(a_szName) , szName(a_szName)
, szLegacyName(a_szName)
, szDescription(a_szDescription) , szDescription(a_szDescription)
, bCompressed(a_bCompressed) , bCompressed(a_bCompressed)
, bSelectable(a_bSelectable) , bSelectable(a_bSelectable)
@ -122,15 +108,6 @@ namespace ImageProcessingAtom
CPixelFormats::CPixelFormats() CPixelFormats::CPixelFormats()
{ {
InitPixelFormats(); InitPixelFormats();
m_removedLegacyFormats["DXT1"] = ePixelFormat_BC1;
m_removedLegacyFormats["DXT1a"] = ePixelFormat_BC1a;
m_removedLegacyFormats["DXT3"] = ePixelFormat_BC3;
m_removedLegacyFormats["DXT3t"] = ePixelFormat_BC3t;
m_removedLegacyFormats["DXT5"] = ePixelFormat_BC3;
m_removedLegacyFormats["DXT5t"] = ePixelFormat_BC3t;
m_removedLegacyFormats["3DCp"] = ePixelFormat_BC4;
m_removedLegacyFormats["3DC"] = ePixelFormat_BC5;
} }
void CPixelFormats::InitPixelFormat(EPixelFormat format, const PixelFormatInfo& formatInfo) void CPixelFormats::InitPixelFormat(EPixelFormat format, const PixelFormatInfo& formatInfo)
@ -176,13 +153,6 @@ namespace ImageProcessingAtom
InitPixelFormat(ePixelFormat_ASTC_10x10, PixelFormatInfo(0, 4, true, "?", 16, 16, 10, 10, 128, false, DXGI_FORMAT_UNKNOWN, FOURCC_ASTC_10x10, ESampleType::eSampleType_Compressed, "ASTC_10x10", "ASTC 10x10 compressed texture format", true, false)); InitPixelFormat(ePixelFormat_ASTC_10x10, PixelFormatInfo(0, 4, true, "?", 16, 16, 10, 10, 128, false, DXGI_FORMAT_UNKNOWN, FOURCC_ASTC_10x10, ESampleType::eSampleType_Compressed, "ASTC_10x10", "ASTC 10x10 compressed texture format", true, false));
InitPixelFormat(ePixelFormat_ASTC_12x10, PixelFormatInfo(0, 4, true, "?", 16, 16, 12, 10, 128, false, DXGI_FORMAT_UNKNOWN, FOURCC_ASTC_12x10, ESampleType::eSampleType_Compressed, "ASTC_12x10", "ASTC 12x10 compressed texture format", true, false)); InitPixelFormat(ePixelFormat_ASTC_12x10, PixelFormatInfo(0, 4, true, "?", 16, 16, 12, 10, 128, false, DXGI_FORMAT_UNKNOWN, FOURCC_ASTC_12x10, ESampleType::eSampleType_Compressed, "ASTC_12x10", "ASTC 12x10 compressed texture format", true, false));
InitPixelFormat(ePixelFormat_ASTC_12x12, PixelFormatInfo(0, 4, true, "?", 16, 16, 12, 12, 128, false, DXGI_FORMAT_UNKNOWN, FOURCC_ASTC_12x12, ESampleType::eSampleType_Compressed, "ASTC_12x12", "ASTC 12x12 compressed texture format", true, false)); InitPixelFormat(ePixelFormat_ASTC_12x12, PixelFormatInfo(0, 4, true, "?", 16, 16, 12, 12, 128, false, DXGI_FORMAT_UNKNOWN, FOURCC_ASTC_12x12, ESampleType::eSampleType_Compressed, "ASTC_12x12", "ASTC 12x12 compressed texture format", true, false));
InitPixelFormat(ePixelFormat_PVRTC2, PixelFormatInfo(2, 4, true, "2", 16, 16, 8, 4, 64, true, DXGI_FORMAT_UNKNOWN, FOURCC_PVRTC2, ESampleType::eSampleType_Compressed, "PVRTC2", "POWERVR 2 bpp compressed texture format", true, false));
InitPixelFormat(ePixelFormat_PVRTC4, PixelFormatInfo(4, 4, true, "2", 8, 8, 4, 4, 64, true, DXGI_FORMAT_UNKNOWN, FOURCC_PVRTC4, ESampleType::eSampleType_Compressed, "PVRTC4", "POWERVR 4 bpp compressed texture format", true, false));
InitPixelFormat(ePixelFormat_EAC_R11, PixelFormatInfo(4, 1, true, "4", 4, 4, 4, 4, 64, false, DXGI_FORMAT_UNKNOWN, FOURCC_EAC_R11, ESampleType::eSampleType_Compressed, "EAC_R11", "EAC 4 bpp single channel texture format", true, false));
InitPixelFormat(ePixelFormat_EAC_RG11, PixelFormatInfo(8, 2, false, "0", 4, 4, 4, 4, 128, false, DXGI_FORMAT_UNKNOWN, FOURCC_EAC_RG11, ESampleType::eSampleType_Compressed, "EAC_RG11", "EAC 8 bpp dual channel texture format", true, false));
InitPixelFormat(ePixelFormat_ETC2, PixelFormatInfo(4, 3, false, "0", 4, 4, 4, 4, 64, false, DXGI_FORMAT_UNKNOWN, FOURCC_ETC2, ESampleType::eSampleType_Compressed, "ETC2", "ETC2 RGB 4 bpp compressed texture format", true, false));
InitPixelFormat(ePixelFormat_ETC2a, PixelFormatInfo(8, 4, true, "4", 4, 4, 4, 4, 128, false, DXGI_FORMAT_UNKNOWN, FOURCC_ETC2A, ESampleType::eSampleType_Compressed, "ETC2a", "ETC2 RGBA 8 bpp compressed texture format", true, false));
InitPixelFormat(ePixelFormat_ETC2a1, PixelFormatInfo(4, 4, true, "1", 4, 4, 4, 4, 64, false, DXGI_FORMAT_UNKNOWN, FOURCC_ETC2A, ESampleType::eSampleType_Compressed, "ETC2a1", "ETC2 RGBA1 8 bpp compressed texture format", true, false));
// Standardized Compressed DXGI Formats (DX10+) // Standardized Compressed DXGI Formats (DX10+)
// Data in these compressed formats is hardware decodable on all DX10 chips, and manageable with the DX10-API. // Data in these compressed formats is hardware decodable on all DX10 chips, and manageable with the DX10-API.
@ -216,17 +186,6 @@ namespace ImageProcessingAtom
InitPixelFormat(ePixelFormat_R32, PixelFormatInfo(32, 1, false, "0", 1, 1, 1, 1, 32, false, DXGI_FORMAT_FORCE_UINT, FOURCC_DX10, ESampleType::eSampleType_Uint32, "R32", "32-bit red only", false, false)); InitPixelFormat(ePixelFormat_R32, PixelFormatInfo(32, 1, false, "0", 1, 1, 1, 1, 32, false, DXGI_FORMAT_FORCE_UINT, FOURCC_DX10, ESampleType::eSampleType_Uint32, "R32", "32-bit red only", false, false));
//Set legacy name it can be used for convertion
m_pixelFormatInfo[ePixelFormat_R8G8B8A8].szLegacyName = "A8R8G8B8";
m_pixelFormatInfo[ePixelFormat_R8G8B8X8].szLegacyName = "X8R8G8B8";
m_pixelFormatInfo[ePixelFormat_R8G8].szLegacyName = "G8R8";
m_pixelFormatInfo[ePixelFormat_R16G16B16A16].szLegacyName = "A16B16G16R16";
m_pixelFormatInfo[ePixelFormat_R16G16].szLegacyName = "G16R16";
m_pixelFormatInfo[ePixelFormat_R32G32B32A32F].szLegacyName = "A32B32G32R32F";
m_pixelFormatInfo[ePixelFormat_R32G32F].szLegacyName = "G32R32F";
m_pixelFormatInfo[ePixelFormat_R16G16B16A16F].szLegacyName = "A16B16G16R16F";
m_pixelFormatInfo[ePixelFormat_R16G16F].szLegacyName = "G16R16F";
//validate all pixel formats are proper initialized //validate all pixel formats are proper initialized
for (int i = 0; i < ePixelFormat_Count; ++i) for (int i = 0; i < ePixelFormat_Count; ++i)
{ {
@ -249,23 +208,6 @@ namespace ImageProcessingAtom
return ePixelFormat_Unknown; return ePixelFormat_Unknown;
} }
EPixelFormat CPixelFormats::FindPixelFormatByLegacyName(const char* name)
{
if (m_removedLegacyFormats.find(name) != m_removedLegacyFormats.end())
{
return m_removedLegacyFormats[name];
}
for (int i = 0; i < ePixelFormat_Count; ++i)
{
if (azstricmp(m_pixelFormatInfo[i].szLegacyName, name) == 0)
{
return (EPixelFormat)i;
}
}
return ePixelFormat_Unknown;
}
const PixelFormatInfo* CPixelFormats::GetPixelFormatInfo(EPixelFormat format) const PixelFormatInfo* CPixelFormats::GetPixelFormatInfo(EPixelFormat format)
{ {
AZ_Assert((format >= 0) && (format < ePixelFormat_Count), "Unsupport pixel format: %d", format); AZ_Assert((format >= 0) && (format < ePixelFormat_Count), "Unsupport pixel format: %d", format);

@ -119,7 +119,6 @@ namespace ImageProcessingAtom
bool bSquarePow2; // whether the pixel format requires image size be square and power of 2. bool bSquarePow2; // whether the pixel format requires image size be square and power of 2.
DXGI_FORMAT d3d10Format; // the mapping d3d10 pixel format DXGI_FORMAT d3d10Format; // the mapping d3d10 pixel format
ESampleType eSampleType; // the data type used to present pixel ESampleType eSampleType; // the data type used to present pixel
const char* szLegacyName; // name used for cryEngine
const char* szName; // name for showing in editors const char* szName; // name for showing in editors
const char* szDescription; // description for showing in editors const char* szDescription; // description for showing in editors
bool bCompressed; // if it's a compressed format bool bCompressed; // if it's a compressed format
@ -173,10 +172,6 @@ namespace ImageProcessingAtom
bool IsFormatSigned(EPixelFormat fmt); bool IsFormatSigned(EPixelFormat fmt);
bool IsFormatFloatingPoint(EPixelFormat fmt, bool bFullPrecision); bool IsFormatFloatingPoint(EPixelFormat fmt, bool bFullPrecision);
//find the pixel format for name used by Cry's RC.ini
//returns ePixelFormat_Unknown if the name was not found in registed format list
EPixelFormat FindPixelFormatByLegacyName(const char* name);
//find pixel format by its name //find pixel format by its name
EPixelFormat FindPixelFormatByName(const char* name); EPixelFormat FindPixelFormatByName(const char* name);
@ -208,9 +203,6 @@ namespace ImageProcessingAtom
//pixel format name to pixel format enum //pixel format name to pixel format enum
AZStd::map<AZStd::string, EPixelFormat> m_pixelFormatNameMap; AZStd::map<AZStd::string, EPixelFormat> m_pixelFormatNameMap;
// some formats from cryEngine were removed. using this name-pixelFormat mapping to look for new format
AZStd::map<AZStd::string, EPixelFormat> m_removedLegacyFormats;
}; };
template <class TInteger> template <class TInteger>

@ -102,32 +102,6 @@ namespace ImageProcessingAtom
case AZ::RHI::Format::ASTC_12x12_UNORM: case AZ::RHI::Format::ASTC_12x12_UNORM:
return ePixelFormat_ASTC_12x12; return ePixelFormat_ASTC_12x12;
case AZ::RHI::Format::PVRTC2_UNORM_SRGB:
isSRGB = true;
case AZ::RHI::Format::PVRTC2_UNORM:
return ePixelFormat_PVRTC2;
case AZ::RHI::Format::PVRTC4_UNORM_SRGB:
isSRGB = true;
case AZ::RHI::Format::PVRTC4_UNORM:
return ePixelFormat_PVRTC4;
case AZ::RHI::Format::EAC_R11_UNORM:
return ePixelFormat_EAC_R11;
case AZ::RHI::Format::EAC_RG11_UNORM:
return ePixelFormat_EAC_RG11;
case AZ::RHI::Format::ETC2_UNORM_SRGB:
isSRGB = true;
case AZ::RHI::Format::ETC2_UNORM:
return ePixelFormat_ETC2;
case AZ::RHI::Format::ETC2A_UNORM_SRGB:
isSRGB = true;
case AZ::RHI::Format::ETC2A_UNORM:
return ePixelFormat_ETC2a;
case AZ::RHI::Format::ETC2A1_UNORM_SRGB:
isSRGB = true;
case AZ::RHI::Format::ETC2A1_UNORM:
return ePixelFormat_ETC2a1;
case AZ::RHI::Format::BC1_UNORM_SRGB: case AZ::RHI::Format::BC1_UNORM_SRGB:
isSRGB = true; isSRGB = true;
case AZ::RHI::Format::BC1_UNORM: case AZ::RHI::Format::BC1_UNORM:
@ -225,22 +199,6 @@ namespace ImageProcessingAtom
case ePixelFormat_ASTC_12x12: case ePixelFormat_ASTC_12x12:
return isSrgb ? RHI::Format::ASTC_12x12_UNORM_SRGB : RHI::Format::ASTC_12x12_UNORM; return isSrgb ? RHI::Format::ASTC_12x12_UNORM_SRGB : RHI::Format::ASTC_12x12_UNORM;
case ePixelFormat_PVRTC2:
return isSrgb ? RHI::Format::PVRTC2_UNORM_SRGB : RHI::Format::PVRTC2_UNORM;
case ePixelFormat_PVRTC4:
return isSrgb ? RHI::Format::PVRTC4_UNORM_SRGB : RHI::Format::PVRTC4_UNORM;
case ePixelFormat_EAC_R11:
return RHI::Format::EAC_R11_UNORM;
case ePixelFormat_EAC_RG11:
return RHI::Format::EAC_RG11_UNORM;
case ePixelFormat_ETC2:
return isSrgb ? RHI::Format::ETC2_UNORM_SRGB : RHI::Format::ETC2_UNORM;
case ePixelFormat_ETC2a:
return isSrgb ? RHI::Format::ETC2A_UNORM_SRGB : RHI::Format::ETC2A_UNORM;
case ePixelFormat_ETC2a1:
return isSrgb ? RHI::Format::ETC2A1_UNORM_SRGB : RHI::Format::ETC2A1_UNORM;
case ePixelFormat_BC1: case ePixelFormat_BC1:
case ePixelFormat_BC1a: case ePixelFormat_BC1a:
return isSrgb ? RHI::Format::BC1_UNORM_SRGB : RHI::Format::BC1_UNORM; return isSrgb ? RHI::Format::BC1_UNORM_SRGB : RHI::Format::BC1_UNORM;

@ -426,60 +426,6 @@ namespace UnitTest
return isDifferent; return isDifferent;
} }
bool CompareDDSImage(const QString& imagePath1, const QString& imagePath2, QString& output)
{
IImageObjectPtr image1, alphaImage1, image2, alphaImage2;
image1 = IImageObjectPtr(DdsLoader::LoadImageFromFileLegacy(imagePath1.toUtf8().constData()));
if (image1 && image1->HasImageFlags(EIF_AttachedAlpha))
{
if (image1->HasImageFlags(EIF_Splitted))
{
alphaImage1 = IImageObjectPtr(DdsLoader::LoadImageFromFileLegacy(QString(imagePath1 + ".a").toUtf8().constData()));
}
else
{
alphaImage1 = IImageObjectPtr(DdsLoader::LoadAttachedImageFromDdsFileLegacy(imagePath1.toUtf8().constData(), image1));
}
}
image2 = IImageObjectPtr(DdsLoader::LoadImageFromFileLegacy(imagePath2.toUtf8().constData()));
if (image2 && image2->HasImageFlags(EIF_AttachedAlpha))
{
if (image2->HasImageFlags(EIF_Splitted))
{
alphaImage2 = IImageObjectPtr(DdsLoader::LoadImageFromFileLegacy(QString(imagePath2 + ".a").toUtf8().constData()));
}
else
{
alphaImage2 = IImageObjectPtr(DdsLoader::LoadAttachedImageFromDdsFileLegacy(imagePath2.toUtf8().constData(), image2));
}
}
if (!image1 && !image2)
{
output += "Cannot load both image file! ";
return false;
}
bool isDifferent = false;
isDifferent = GetComparisonResult(image1, image2, output);
QFileInfo fi(imagePath1);
AZStd::string imageName = fi.baseName().toUtf8().constData();
SaveImageToFile(image1, imageName + "_new");
SaveImageToFile(image2, imageName + "_old");
if (alphaImage1 || alphaImage2)
{
isDifferent |= GetComparisonResult(alphaImage1, alphaImage2, output);
}
return isDifferent;
}
}; };
// test CPixelFormats related functions // test CPixelFormats related functions
@ -487,34 +433,6 @@ namespace UnitTest
{ {
CPixelFormats& pixelFormats = CPixelFormats::GetInstance(); CPixelFormats& pixelFormats = CPixelFormats::GetInstance();
//verify names which was used for legacy rc.ini
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("BC7t") == ePixelFormat_BC7t);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("ETC2A") == ePixelFormat_ETC2a);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("PVRTC4") == ePixelFormat_PVRTC4);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("BC1") == ePixelFormat_BC1);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("ETC2") == ePixelFormat_ETC2);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("BC1a") == ePixelFormat_BC1a);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("BC3") == ePixelFormat_BC3);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("BC7") == ePixelFormat_BC7);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("BC5s") == ePixelFormat_BC5s);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("EAC_RG11") == ePixelFormat_EAC_RG11);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("BC4") == ePixelFormat_BC4);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("EAC_R11") == ePixelFormat_EAC_R11);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("A8R8G8B8") == ePixelFormat_R8G8B8A8);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("BC6UH") == ePixelFormat_BC6UH);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("R9G9B9E5") == ePixelFormat_R9G9B9E5);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("X8R8G8B8") == ePixelFormat_R8G8B8X8);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("A16B16G16R16F") == ePixelFormat_R16G16B16A16F);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("G8R8") == ePixelFormat_R8G8);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("G16R16") == ePixelFormat_R16G16);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("G16R16F") == ePixelFormat_R16G16F);
//some legacy format need to be mapping to new format.
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("DXT1") == ePixelFormat_BC1);
ASSERT_TRUE(pixelFormats.FindPixelFormatByLegacyName("DXT5") == ePixelFormat_BC3);
//calculate mipmap count. no cubemap support at this moment
//for all the non-compressed textures, if there minimum required texture size is 1x1 //for all the non-compressed textures, if there minimum required texture size is 1x1
for (uint32 i = 0; i < ePixelFormat_Count; i++) for (uint32 i = 0; i < ePixelFormat_Count; i++)
{ {
@ -543,13 +461,6 @@ namespace UnitTest
} }
//check function IsImageSizeValid && EvaluateImageDataSize function //check function IsImageSizeValid && EvaluateImageDataSize function
ASSERT_TRUE(pixelFormats.IsImageSizeValid(ePixelFormat_PVRTC4, 2, 1, false) == false);
ASSERT_TRUE(pixelFormats.IsImageSizeValid(ePixelFormat_PVRTC4, 4, 4, false) == false);
ASSERT_TRUE(pixelFormats.IsImageSizeValid(ePixelFormat_PVRTC4, 16, 16, false) == true);
ASSERT_TRUE(pixelFormats.IsImageSizeValid(ePixelFormat_PVRTC4, 16, 32, false) == false);
ASSERT_TRUE(pixelFormats.IsImageSizeValid(ePixelFormat_PVRTC4, 34, 34, false) == false);
ASSERT_TRUE(pixelFormats.IsImageSizeValid(ePixelFormat_PVRTC4, 256, 256, false) == true);
ASSERT_TRUE(pixelFormats.IsImageSizeValid(ePixelFormat_BC1, 2, 1, false) == false); ASSERT_TRUE(pixelFormats.IsImageSizeValid(ePixelFormat_BC1, 2, 1, false) == false);
ASSERT_TRUE(pixelFormats.IsImageSizeValid(ePixelFormat_BC1, 16, 16, false) == true); ASSERT_TRUE(pixelFormats.IsImageSizeValid(ePixelFormat_BC1, 16, 16, false) == true);
ASSERT_TRUE(pixelFormats.IsImageSizeValid(ePixelFormat_BC1, 16, 32, false) == true); ASSERT_TRUE(pixelFormats.IsImageSizeValid(ePixelFormat_BC1, 16, 32, false) == true);
@ -834,9 +745,7 @@ namespace UnitTest
if (formatInfo->bCompressed) if (formatInfo->bCompressed)
{ {
// skip ASTC formats which are tested in TestConvertASTCCompressor // skip ASTC formats which are tested in TestConvertASTCCompressor
if (!IsASTCFormat(pixelFormat) if (!IsASTCFormat(pixelFormat))
&& pixelFormat != ePixelFormat_PVRTC2 && pixelFormat != ePixelFormat_PVRTC4
&& !IsETCFormat(pixelFormat)) // skip ETC since it's very slow
{ {
compressedFormats.push_back(pixelFormat); compressedFormats.push_back(pixelFormat);
} }
@ -1112,55 +1021,6 @@ namespace UnitTest
} }
} }
TEST_F(ImageProcessingTest, DISABLED_CompareOutputImage)
{
AZStd::string curretTextureFolder = "../TestAssets/TextureAssets/assets_new/textures";
AZStd::string oldTextureFolder = "../TestAssets/TextureAssets/assets_old/textures";
bool outputOnlyDifferent = false;
QDirIterator it(curretTextureFolder.c_str(), QStringList() << "*.dds", QDir::Files, QDirIterator::Subdirectories);
QFile f("../texture_comparison_output.csv");
f.open(QIODevice::ReadWrite | QIODevice::Truncate);
// Write a header for csv file
f.write("Texture Name, Path, Mip new/old, MipDiff, Format new/old, Flag new/old, MemSize new/old, MemDiff, Error, AlphaMip new/old, AlphaMipDiff, AlphaFormat new/old, AlphaFlag new/old, AlphaMemSize new/old, AlphaMemDiff, AlphaError\r\n");
int i = 0;
while (it.hasNext())
{
i++;
it.next();
QString fileName = it.fileName();
QString newFilePath = it.filePath();
QString sharedPath = QString(newFilePath).remove(curretTextureFolder.c_str());
QString oldFilePath = QString(oldTextureFolder.c_str()) + sharedPath;
QString output;
if (QFile::exists(oldFilePath))
{
bool isDifferent = CompareDDSImage(newFilePath, oldFilePath, output);
if (outputOnlyDifferent && !isDifferent)
{
continue;
}
else
{
f.write(fileName.toUtf8().constData());
f.write(",");
f.write(sharedPath.toUtf8().constData());
f.write(output.toUtf8().constData());
}
}
else
{
f.write(fileName.toUtf8().constData());
f.write(",");
f.write(sharedPath.toUtf8().constData());
output += ",No old file for comparison!";
f.write(output.toUtf8().constData());
}
f.write("\r\n");
}
f.close();
}
TEST_F(ImageProcessingTest, TextureSettingReflect_SerializingModernDataInAndOut_WritesAndParsesFileAccurately) TEST_F(ImageProcessingTest, TextureSettingReflect_SerializingModernDataInAndOut_WritesAndParsesFileAccurately)
{ {
AZStd::string filepath = "test.xml"; AZStd::string filepath = "test.xml";

@ -120,10 +120,6 @@ set(FILES
Source/Compressors/Compressor.cpp Source/Compressors/Compressor.cpp
Source/Compressors/CTSquisher.h Source/Compressors/CTSquisher.h
Source/Compressors/CTSquisher.cpp Source/Compressors/CTSquisher.cpp
Source/Compressors/PVRTC.cpp
Source/Compressors/PVRTC.h
Source/Compressors/ETC2.cpp
Source/Compressors/ETC2.h
Source/Compressors/CryTextureSquisher/ColorBlockRGBA4x4f.cpp Source/Compressors/CryTextureSquisher/ColorBlockRGBA4x4f.cpp
Source/Compressors/CryTextureSquisher/ColorBlockRGBA4x4s.cpp Source/Compressors/CryTextureSquisher/ColorBlockRGBA4x4s.cpp
Source/Compressors/CryTextureSquisher/ColorBlockRGBA4x4c.cpp Source/Compressors/CryTextureSquisher/ColorBlockRGBA4x4c.cpp

@ -757,9 +757,7 @@ namespace TextureAtlasBuilder
if (input.m_presetName.empty()) if (input.m_presetName.empty())
{ {
// Default to the TextureAtlas preset which is currently set to use compression for all platforms except for iOS. // Default to the TextureAtlas preset which is currently set to use compression
// Currently the only fully supported compression for iOS is PVRTC which requires the texture to be square and a power of 2.
// Due to this limitation, we default to using no compression for iOS until ASTC is fully supported
const AZStd::string defaultPresetName = "UserInterface_Compressed"; const AZStd::string defaultPresetName = "UserInterface_Compressed";
input.m_presetName = defaultPresetName; input.m_presetName = defaultPresetName;
} }

@ -20,7 +20,6 @@ ly_associate_package(PACKAGE_NAME SQLite-3.32.2-rev3-multiplatform
ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee) ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee)
ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5) ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5)
ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e) ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e)
ly_associate_package(PACKAGE_NAME PVRTexTool-4.24.0-rev4-multiplatform TARGETS PVRTexTool PACKAGE_HASH d0d6da61c7557de0d2c71fc35ba56c3be49555b703f0e853d4c58225537acf1e)
# platform-specific: # platform-specific:
ly_associate_package(PACKAGE_NAME AWSGameLiftServerSDK-3.4.1-rev1-linux TARGETS AWSGameLiftServerSDK PACKAGE_HASH a8149a95bd100384af6ade97e2b21a56173740d921e6c3da8188cd51554d39af) ly_associate_package(PACKAGE_NAME AWSGameLiftServerSDK-3.4.1-rev1-linux TARGETS AWSGameLiftServerSDK PACKAGE_HASH a8149a95bd100384af6ade97e2b21a56173740d921e6c3da8188cd51554d39af)
@ -29,7 +28,6 @@ ly_associate_package(PACKAGE_NAME freetype-2.10.4.16-linux
ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.7.167-rev6-linux TARGETS AWSNativeSDK PACKAGE_HASH 490291e4c8057975c3ab86feb971b8a38871c58bac5e5d86abdd1aeb7141eec4) ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.7.167-rev6-linux TARGETS AWSNativeSDK PACKAGE_HASH 490291e4c8057975c3ab86feb971b8a38871c58bac5e5d86abdd1aeb7141eec4)
ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev5-linux TARGETS Lua PACKAGE_HASH 1adc812abe3dd0dbb2ca9756f81d8f0e0ba45779ac85bf1d8455b25c531a38b0) ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev5-linux TARGETS Lua PACKAGE_HASH 1adc812abe3dd0dbb2ca9756f81d8f0e0ba45779ac85bf1d8455b25c531a38b0)
ly_associate_package(PACKAGE_NAME PhysX-4.1.2.29882248-rev3-linux TARGETS PhysX PACKAGE_HASH a110249cbef4f266b0002c4ee9a71f59f373040cefbe6b82f1e1510c811edde6) ly_associate_package(PACKAGE_NAME PhysX-4.1.2.29882248-rev3-linux TARGETS PhysX PACKAGE_HASH a110249cbef4f266b0002c4ee9a71f59f373040cefbe6b82f1e1510c811edde6)
ly_associate_package(PACKAGE_NAME etc2comp-9cd0f9cae0-rev1-linux TARGETS etc2comp PACKAGE_HASH 9283aa5db5bb7fb90a0ddb7a9f3895317c8ebe8044943124bbb3673a41407430)
ly_associate_package(PACKAGE_NAME mcpp-2.7.2_az.2-rev1-linux TARGETS mcpp PACKAGE_HASH df7a998d0bc3fedf44b5bdebaf69ddad6033355b71a590e8642445ec77bc6c41) ly_associate_package(PACKAGE_NAME mcpp-2.7.2_az.2-rev1-linux TARGETS mcpp PACKAGE_HASH df7a998d0bc3fedf44b5bdebaf69ddad6033355b71a590e8642445ec77bc6c41)
ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-linux TARGETS mikkelsen PACKAGE_HASH 5973b1e71a64633588eecdb5b5c06ca0081f7be97230f6ef64365cbda315b9c8) ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-linux TARGETS mikkelsen PACKAGE_HASH 5973b1e71a64633588eecdb5b5c06ca0081f7be97230f6ef64365cbda315b9c8)
ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-linux TARGETS googletest PACKAGE_HASH 7b7ad330f369450c316a4c4592d17fbb4c14c731c95bd8f37757203e8c2bbc1b) ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-linux TARGETS googletest PACKAGE_HASH 7b7ad330f369450c316a4c4592d17fbb4c14c731c95bd8f37757203e8c2bbc1b)

@ -21,7 +21,6 @@ ly_associate_package(PACKAGE_NAME azslc-1.7.23-rev1-multiplatform
ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee) ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee)
ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5) ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5)
ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e) ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e)
ly_associate_package(PACKAGE_NAME PVRTexTool-4.24.0-rev4-multiplatform TARGETS PVRTexTool PACKAGE_HASH d0d6da61c7557de0d2c71fc35ba56c3be49555b703f0e853d4c58225537acf1e)
# platform-specific: # platform-specific:
ly_associate_package(PACKAGE_NAME DirectXShaderCompilerDxc-1.6.2104-o3de-rev3-mac TARGETS DirectXShaderCompilerDxc PACKAGE_HASH 3f77367dbb0342136ec4ebbd44bc1fedf7198089a0f83c5631248530769b2be6) ly_associate_package(PACKAGE_NAME DirectXShaderCompilerDxc-1.6.2104-o3de-rev3-mac TARGETS DirectXShaderCompilerDxc PACKAGE_HASH 3f77367dbb0342136ec4ebbd44bc1fedf7198089a0f83c5631248530769b2be6)
@ -31,7 +30,6 @@ ly_associate_package(PACKAGE_NAME freetype-2.10.4.16-mac
ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.7.167-rev5-mac TARGETS AWSNativeSDK PACKAGE_HASH ffb890bd9cf23afb429b9214ad9bac1bf04696f07a0ebb93c42058c482ab2f01) ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.7.167-rev5-mac TARGETS AWSNativeSDK PACKAGE_HASH ffb890bd9cf23afb429b9214ad9bac1bf04696f07a0ebb93c42058c482ab2f01)
ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev6-mac TARGETS Lua PACKAGE_HASH b9079fd35634774c9269028447562c6b712dbc83b9c64975c095fd423ff04c08) ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev6-mac TARGETS Lua PACKAGE_HASH b9079fd35634774c9269028447562c6b712dbc83b9c64975c095fd423ff04c08)
ly_associate_package(PACKAGE_NAME PhysX-4.1.2.29882248-rev3-mac TARGETS PhysX PACKAGE_HASH 5e092a11d5c0a50c4dd99bb681a04b566a4f6f29aa08443d9bffc8dc12c27c8e) ly_associate_package(PACKAGE_NAME PhysX-4.1.2.29882248-rev3-mac TARGETS PhysX PACKAGE_HASH 5e092a11d5c0a50c4dd99bb681a04b566a4f6f29aa08443d9bffc8dc12c27c8e)
ly_associate_package(PACKAGE_NAME etc2comp-9cd0f9cae0-rev1-mac TARGETS etc2comp PACKAGE_HASH 1966ab101c89db7ecf30984917e0a48c0d02ee0e4d65b798743842b9469c0818)
ly_associate_package(PACKAGE_NAME mcpp-2.7.2_az.2-rev1-mac TARGETS mcpp PACKAGE_HASH be9558905c9c49179ef3d7d84f0a5472415acdf7fe2d76eb060d9431723ddf2e) ly_associate_package(PACKAGE_NAME mcpp-2.7.2_az.2-rev1-mac TARGETS mcpp PACKAGE_HASH be9558905c9c49179ef3d7d84f0a5472415acdf7fe2d76eb060d9431723ddf2e)
ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-mac TARGETS mikkelsen PACKAGE_HASH 83af99ca8bee123684ad254263add556f0cf49486c0b3e32e6d303535714e505) ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-mac TARGETS mikkelsen PACKAGE_HASH 83af99ca8bee123684ad254263add556f0cf49486c0b3e32e6d303535714e505)
ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-mac TARGETS googletest PACKAGE_HASH cbf020d5ef976c5db8b6e894c6c63151ade85ed98e7c502729dd20172acae5a8) ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-mac TARGETS googletest PACKAGE_HASH cbf020d5ef976c5db8b6e894c6c63151ade85ed98e7c502729dd20172acae5a8)

@ -21,7 +21,6 @@ ly_associate_package(PACKAGE_NAME azslc-1.7.23-rev1-multiplatform
ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee) ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee)
ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5) ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5)
ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e) ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e)
ly_associate_package(PACKAGE_NAME PVRTexTool-4.24.0-rev4-multiplatform TARGETS PVRTexTool PACKAGE_HASH d0d6da61c7557de0d2c71fc35ba56c3be49555b703f0e853d4c58225537acf1e)
# platform-specific: # platform-specific:
ly_associate_package(PACKAGE_NAME AWSGameLiftServerSDK-3.4.1-rev1-windows TARGETS AWSGameLiftServerSDK PACKAGE_HASH a0586b006e4def65cc25f388de17dc475e417dc1e6f9d96749777c88aa8271b0) ly_associate_package(PACKAGE_NAME AWSGameLiftServerSDK-3.4.1-rev1-windows TARGETS AWSGameLiftServerSDK PACKAGE_HASH a0586b006e4def65cc25f388de17dc475e417dc1e6f9d96749777c88aa8271b0)
@ -32,7 +31,6 @@ ly_associate_package(PACKAGE_NAME freetype-2.10.4.16-windows
ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.7.167-rev4-windows TARGETS AWSNativeSDK PACKAGE_HASH a900e80f7259e43aed5c847afee2599ada37f29db70505481397675bcbb6c76c) ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.7.167-rev4-windows TARGETS AWSNativeSDK PACKAGE_HASH a900e80f7259e43aed5c847afee2599ada37f29db70505481397675bcbb6c76c)
ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev5-windows TARGETS Lua PACKAGE_HASH 136faccf1f73891e3fa3b95f908523187792e56f5b92c63c6a6d7e72d1158d40) ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev5-windows TARGETS Lua PACKAGE_HASH 136faccf1f73891e3fa3b95f908523187792e56f5b92c63c6a6d7e72d1158d40)
ly_associate_package(PACKAGE_NAME PhysX-4.1.2.29882248-rev3-windows TARGETS PhysX PACKAGE_HASH 0c5ffbd9fa588e5cf7643721a7cfe74d0fe448bf82252d39b3a96d06dfca2298) ly_associate_package(PACKAGE_NAME PhysX-4.1.2.29882248-rev3-windows TARGETS PhysX PACKAGE_HASH 0c5ffbd9fa588e5cf7643721a7cfe74d0fe448bf82252d39b3a96d06dfca2298)
ly_associate_package(PACKAGE_NAME etc2comp-9cd0f9cae0-rev1-windows TARGETS etc2comp PACKAGE_HASH fc9ae937b2ec0d42d5e7d0e9e8c80e5e4d257673fb33bc9b7d6db76002117123)
ly_associate_package(PACKAGE_NAME mcpp-2.7.2_az.2-rev1-windows TARGETS mcpp PACKAGE_HASH 794789aba639bfe2f4e8fcb4424d679933dd6290e523084aa0a4e287ac44acb2) ly_associate_package(PACKAGE_NAME mcpp-2.7.2_az.2-rev1-windows TARGETS mcpp PACKAGE_HASH 794789aba639bfe2f4e8fcb4424d679933dd6290e523084aa0a4e287ac44acb2)
ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-windows TARGETS mikkelsen PACKAGE_HASH 872c4d245a1c86139aa929f2b465b63ea4ea55b04ced50309135dd4597457a4e) ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-windows TARGETS mikkelsen PACKAGE_HASH 872c4d245a1c86139aa929f2b465b63ea4ea55b04ced50309135dd4597457a4e)
ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-windows TARGETS googletest PACKAGE_HASH 7e8f03ae8a01563124e3daa06386f25a2b311c10bb95bff05cae6c41eff83837) ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-windows TARGETS googletest PACKAGE_HASH 7e8f03ae8a01563124e3daa06386f25a2b311c10bb95bff05cae6c41eff83837)

Loading…
Cancel
Save