Improvements for astc format
This commit is contained in:
@@ -666,6 +666,8 @@ int32 PixelFormatExtensions::ComputeBlockSize(PixelFormat format)
|
|||||||
case PixelFormat::BC7_Typeless:
|
case PixelFormat::BC7_Typeless:
|
||||||
case PixelFormat::BC7_UNorm:
|
case PixelFormat::BC7_UNorm:
|
||||||
case PixelFormat::BC7_UNorm_sRGB:
|
case PixelFormat::BC7_UNorm_sRGB:
|
||||||
|
case PixelFormat::ASTC_4x4_UNorm:
|
||||||
|
case PixelFormat::ASTC_4x4_UNorm_sRGB:
|
||||||
return 4;
|
return 4;
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -332,10 +332,10 @@ void RenderTools::ComputePitch(PixelFormat format, int32 width, int32 height, ui
|
|||||||
case PixelFormat::ASTC_4x4_UNorm:
|
case PixelFormat::ASTC_4x4_UNorm:
|
||||||
case PixelFormat::ASTC_4x4_UNorm_sRGB:
|
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 nbw = Math::Max<uint32>(1, Math::DivideAndRoundUp(width, blockSize));
|
||||||
uint32 nbh = Math::Max<uint32>(1, Math::DivideAndRoundUp(height, 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;
|
slicePitch = rowPitch * nbh;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -12,18 +12,9 @@
|
|||||||
|
|
||||||
bool TextureTool::ConvertAstc(TextureData& dst, const TextureData& src, const PixelFormat dstFormat)
|
bool TextureTool::ConvertAstc(TextureData& dst, const TextureData& src, const PixelFormat dstFormat)
|
||||||
{
|
{
|
||||||
int32 blockSize, bytesPerBlock = 16;
|
ASSERT(PixelFormatExtensions::IsCompressedASTC(dstFormat));
|
||||||
// TODO: use block size from PixelFormatExtensions
|
const int32 blockSize = PixelFormatExtensions::ComputeBlockSize(dstFormat);
|
||||||
switch (dstFormat)
|
const int32 bytesPerBlock = 16; // All ASTC blocks use 128 bits
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure the compressor run
|
// Configure the compressor run
|
||||||
const bool isSRGB = PixelFormatExtensions::IsSRGB(dstFormat);
|
const bool isSRGB = PixelFormatExtensions::IsSRGB(dstFormat);
|
||||||
|
|||||||
Reference in New Issue
Block a user