Add more ASTC texture formats with larger block sizes
This commit is contained in:
@@ -29,6 +29,21 @@ void PixelFormatExtensions::Init()
|
||||
PixelFormat::R8_Typeless,
|
||||
PixelFormat::R8_UInt,
|
||||
PixelFormat::R8_UNorm,
|
||||
PixelFormat::BC2_Typeless,
|
||||
PixelFormat::BC2_UNorm,
|
||||
PixelFormat::BC2_UNorm_sRGB,
|
||||
PixelFormat::BC3_Typeless,
|
||||
PixelFormat::BC3_UNorm,
|
||||
PixelFormat::BC3_UNorm_sRGB,
|
||||
PixelFormat::BC5_SNorm,
|
||||
PixelFormat::BC5_Typeless,
|
||||
PixelFormat::BC5_UNorm,
|
||||
PixelFormat::BC6H_Sf16,
|
||||
PixelFormat::BC6H_Typeless,
|
||||
PixelFormat::BC6H_Uf16,
|
||||
PixelFormat::BC7_Typeless,
|
||||
PixelFormat::BC7_UNorm,
|
||||
PixelFormat::BC7_UNorm_sRGB,
|
||||
PixelFormat::ASTC_4x4_UNorm,
|
||||
PixelFormat::ASTC_4x4_UNorm_sRGB,
|
||||
};
|
||||
@@ -134,25 +149,6 @@ void PixelFormatExtensions::Init()
|
||||
PixelFormat::BC4_UNorm,
|
||||
};
|
||||
InitFormat(formats8, 4);
|
||||
|
||||
PixelFormat formats9[] = {
|
||||
PixelFormat::BC2_Typeless,
|
||||
PixelFormat::BC2_UNorm,
|
||||
PixelFormat::BC2_UNorm_sRGB,
|
||||
PixelFormat::BC3_Typeless,
|
||||
PixelFormat::BC3_UNorm,
|
||||
PixelFormat::BC3_UNorm_sRGB,
|
||||
PixelFormat::BC5_SNorm,
|
||||
PixelFormat::BC5_Typeless,
|
||||
PixelFormat::BC5_UNorm,
|
||||
PixelFormat::BC6H_Sf16,
|
||||
PixelFormat::BC6H_Typeless,
|
||||
PixelFormat::BC6H_Uf16,
|
||||
PixelFormat::BC7_Typeless,
|
||||
PixelFormat::BC7_UNorm,
|
||||
PixelFormat::BC7_UNorm_sRGB,
|
||||
};
|
||||
InitFormat(formats9, 8);
|
||||
}
|
||||
|
||||
int32 PixelFormatExtensions::SizeInBits(PixelFormat format)
|
||||
@@ -315,6 +311,12 @@ bool PixelFormatExtensions::IsCompressed(const PixelFormat format)
|
||||
case PixelFormat::BC7_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_4x4_UNorm:
|
||||
case PixelFormat::ASTC_4x4_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_6x6_UNorm:
|
||||
case PixelFormat::ASTC_6x6_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_8x8_UNorm:
|
||||
case PixelFormat::ASTC_8x8_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_10x10_UNorm:
|
||||
case PixelFormat::ASTC_10x10_UNorm_sRGB:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -358,6 +360,12 @@ bool PixelFormatExtensions::IsCompressedASTC(PixelFormat format)
|
||||
{
|
||||
case PixelFormat::ASTC_4x4_UNorm:
|
||||
case PixelFormat::ASTC_4x4_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_6x6_UNorm:
|
||||
case PixelFormat::ASTC_6x6_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_8x8_UNorm:
|
||||
case PixelFormat::ASTC_8x8_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_10x10_UNorm:
|
||||
case PixelFormat::ASTC_10x10_UNorm_sRGB:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -391,6 +399,9 @@ bool PixelFormatExtensions::IsSRGB(const PixelFormat format)
|
||||
case PixelFormat::B8G8R8X8_UNorm_sRGB:
|
||||
case PixelFormat::BC7_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_4x4_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_6x6_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_8x8_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_10x10_UNorm_sRGB:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -580,6 +591,12 @@ int32 PixelFormatExtensions::ComputeComponentsCount(const PixelFormat format)
|
||||
case PixelFormat::B8G8R8X8_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_4x4_UNorm:
|
||||
case PixelFormat::ASTC_4x4_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_6x6_UNorm:
|
||||
case PixelFormat::ASTC_6x6_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_8x8_UNorm:
|
||||
case PixelFormat::ASTC_8x8_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_10x10_UNorm:
|
||||
case PixelFormat::ASTC_10x10_UNorm_sRGB:
|
||||
return 4;
|
||||
case PixelFormat::R32G32B32_Typeless:
|
||||
case PixelFormat::R32G32B32_Float:
|
||||
@@ -669,6 +686,15 @@ int32 PixelFormatExtensions::ComputeBlockSize(PixelFormat format)
|
||||
case PixelFormat::ASTC_4x4_UNorm:
|
||||
case PixelFormat::ASTC_4x4_UNorm_sRGB:
|
||||
return 4;
|
||||
case PixelFormat::ASTC_6x6_UNorm:
|
||||
case PixelFormat::ASTC_6x6_UNorm_sRGB:
|
||||
return 6;
|
||||
case PixelFormat::ASTC_8x8_UNorm:
|
||||
case PixelFormat::ASTC_8x8_UNorm_sRGB:
|
||||
return 8;
|
||||
case PixelFormat::ASTC_10x10_UNorm:
|
||||
case PixelFormat::ASTC_10x10_UNorm_sRGB:
|
||||
return 10;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
@@ -694,6 +720,12 @@ PixelFormat PixelFormatExtensions::TosRGB(const PixelFormat format)
|
||||
return PixelFormat::BC7_UNorm_sRGB;
|
||||
case PixelFormat::ASTC_4x4_UNorm:
|
||||
return PixelFormat::ASTC_4x4_UNorm_sRGB;
|
||||
case PixelFormat::ASTC_6x6_UNorm:
|
||||
return PixelFormat::ASTC_6x6_UNorm_sRGB;
|
||||
case PixelFormat::ASTC_8x8_UNorm:
|
||||
return PixelFormat::ASTC_8x8_UNorm_sRGB;
|
||||
case PixelFormat::ASTC_10x10_UNorm:
|
||||
return PixelFormat::ASTC_10x10_UNorm_sRGB;
|
||||
default:
|
||||
return format;
|
||||
}
|
||||
@@ -719,6 +751,12 @@ PixelFormat PixelFormatExtensions::ToNonsRGB(const PixelFormat format)
|
||||
return PixelFormat::BC7_UNorm;
|
||||
case PixelFormat::ASTC_4x4_UNorm_sRGB:
|
||||
return PixelFormat::ASTC_4x4_UNorm;
|
||||
case PixelFormat::ASTC_6x6_UNorm_sRGB:
|
||||
return PixelFormat::ASTC_6x6_UNorm;
|
||||
case PixelFormat::ASTC_8x8_UNorm_sRGB:
|
||||
return PixelFormat::ASTC_8x8_UNorm;
|
||||
case PixelFormat::ASTC_10x10_UNorm_sRGB:
|
||||
return PixelFormat::ASTC_10x10_UNorm;
|
||||
default:
|
||||
return format;
|
||||
}
|
||||
|
||||
@@ -331,6 +331,12 @@ void RenderTools::ComputePitch(PixelFormat format, int32 width, int32 height, ui
|
||||
break;
|
||||
case PixelFormat::ASTC_4x4_UNorm:
|
||||
case PixelFormat::ASTC_4x4_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_6x6_UNorm:
|
||||
case PixelFormat::ASTC_6x6_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_8x8_UNorm:
|
||||
case PixelFormat::ASTC_8x8_UNorm_sRGB:
|
||||
case PixelFormat::ASTC_10x10_UNorm:
|
||||
case PixelFormat::ASTC_10x10_UNorm_sRGB:
|
||||
{
|
||||
const int32 blockSize = PixelFormatExtensions::ComputeBlockSize(format);
|
||||
uint32 nbw = Math::Max<uint32>(1, Math::DivideAndRoundUp(width, blockSize));
|
||||
|
||||
@@ -337,14 +337,12 @@ int32 GPUTexture::ComputeBufferOffset(int32 subresource, int32 rowAlign, int32 s
|
||||
int32 GPUTexture::ComputeBufferTotalSize(int32 rowAlign, int32 sliceAlign) const
|
||||
{
|
||||
int32 result = 0;
|
||||
|
||||
for (int32 mipLevel = 0; mipLevel < MipLevels(); mipLevel++)
|
||||
{
|
||||
const int32 slicePitch = ComputeSlicePitch(mipLevel, rowAlign);
|
||||
const int32 depth = CalculateMipSize(Depth(), mipLevel);
|
||||
result += Math::AlignUp<int32>(slicePitch * depth, sliceAlign);
|
||||
}
|
||||
|
||||
return result * ArraySize();
|
||||
}
|
||||
|
||||
@@ -355,8 +353,11 @@ int32 GPUTexture::ComputeSlicePitch(int32 mipLevel, int32 rowAlign) const
|
||||
|
||||
int32 GPUTexture::ComputeRowPitch(int32 mipLevel, int32 rowAlign) const
|
||||
{
|
||||
const int32 formatSize = PixelFormatExtensions::SizeInBytes(Format());
|
||||
return Math::AlignUp<int32>(CalculateMipSize(Width(), mipLevel) * formatSize, rowAlign);
|
||||
int32 mipWidth = CalculateMipSize(Width(), mipLevel);
|
||||
int32 mipHeight = CalculateMipSize(Height(), mipLevel);
|
||||
uint32 rowPitch, slicePitch;
|
||||
RenderTools::ComputePitch(Format(), mipWidth, mipHeight, rowPitch, slicePitch);
|
||||
return Math::AlignUp<int32>(rowPitch, rowAlign);
|
||||
}
|
||||
|
||||
bool GPUTexture::Init(const GPUTextureDescription& desc)
|
||||
|
||||
Reference in New Issue
Block a user