Improvements for astc format

This commit is contained in:
Wojtek Figat
2023-12-18 09:59:29 +01:00
parent 5958b2f4ea
commit c6c53baff2
3 changed files with 7 additions and 14 deletions

View File

@@ -666,6 +666,8 @@ int32 PixelFormatExtensions::ComputeBlockSize(PixelFormat format)
case PixelFormat::BC7_Typeless:
case PixelFormat::BC7_UNorm:
case PixelFormat::BC7_UNorm_sRGB:
case PixelFormat::ASTC_4x4_UNorm:
case PixelFormat::ASTC_4x4_UNorm_sRGB:
return 4;
default:
return 1;

View File

@@ -332,10 +332,10 @@ void RenderTools::ComputePitch(PixelFormat format, int32 width, int32 height, ui
case PixelFormat::ASTC_4x4_UNorm:
case PixelFormat::ASTC_4x4_UNorm_sRGB:
{
const int32 blockSize = 4; // TODO: use PixelFormatExtensions to get block size for a format and handle different astc
const int32 blockSize = PixelFormatExtensions::ComputeBlockSize(format);
uint32 nbw = Math::Max<uint32>(1, Math::DivideAndRoundUp(width, blockSize));
uint32 nbh = Math::Max<uint32>(1, Math::DivideAndRoundUp(height, blockSize));
rowPitch = nbw * 16;
rowPitch = nbw * 16; // All ASTC blocks use 128 bits
slicePitch = rowPitch * nbh;
}
break;

View File

@@ -12,18 +12,9 @@
bool TextureTool::ConvertAstc(TextureData& dst, const TextureData& src, const PixelFormat dstFormat)
{
int32 blockSize, bytesPerBlock = 16;
// TODO: use block size from PixelFormatExtensions
switch (dstFormat)
{
case PixelFormat::ASTC_4x4_UNorm:
case PixelFormat::ASTC_4x4_UNorm_sRGB:
blockSize = 4;
break;
default:
LOG(Warning, "Cannot compress image. Unsupported format {0}", static_cast<int32>(dstFormat));
return true;
}
ASSERT(PixelFormatExtensions::IsCompressedASTC(dstFormat));
const int32 blockSize = PixelFormatExtensions::ComputeBlockSize(dstFormat);
const int32 bytesPerBlock = 16; // All ASTC blocks use 128 bits
// Configure the compressor run
const bool isSRGB = PixelFormatExtensions::IsSRGB(dstFormat);