Add ASTC texture compression on Android

This commit is contained in:
Wojtek Figat
2024-01-03 23:01:33 +01:00
parent 85afde43af
commit df33de7176
9 changed files with 173 additions and 60 deletions

View File

@@ -915,9 +915,9 @@ PixelFormat PixelFormatExtensions::MakeTypelessUNorm(const PixelFormat format)
}
}
PixelFormat PixelFormatExtensions::FindShaderResourceFormat(const PixelFormat format, bool isSRGB)
PixelFormat PixelFormatExtensions::FindShaderResourceFormat(const PixelFormat format, bool sRGB)
{
if (isSRGB)
if (sRGB)
{
switch (format)
{
@@ -1000,3 +1000,55 @@ PixelFormat PixelFormatExtensions::FindDepthStencilFormat(const PixelFormat form
}
return format;
}
PixelFormat PixelFormatExtensions::FindUncompressedFormat(PixelFormat format)
{
switch (format)
{
case PixelFormat::BC1_Typeless:
case PixelFormat::BC2_Typeless:
case PixelFormat::BC3_Typeless:
return PixelFormat::R8G8B8A8_Typeless;
case PixelFormat::BC1_UNorm:
case PixelFormat::BC2_UNorm:
case PixelFormat::BC3_UNorm:
return PixelFormat::R8G8B8A8_UNorm;
case PixelFormat::BC1_UNorm_sRGB:
case PixelFormat::BC2_UNorm_sRGB:
case PixelFormat::BC3_UNorm_sRGB:
return PixelFormat::R8G8B8A8_UNorm_sRGB;
case PixelFormat::BC4_Typeless:
return PixelFormat::R8_Typeless;
case PixelFormat::BC4_UNorm:
return PixelFormat::R8_UNorm;
case PixelFormat::BC4_SNorm:
return PixelFormat::R8_SNorm;
case PixelFormat::BC5_Typeless:
return PixelFormat::R16G16_Typeless;
case PixelFormat::BC5_UNorm:
return PixelFormat::R16G16_UNorm;
case PixelFormat::BC5_SNorm:
return PixelFormat::R16G16_SNorm;
case PixelFormat::BC7_Typeless:
case PixelFormat::BC6H_Typeless:
return PixelFormat::R16G16B16A16_Typeless;
case PixelFormat::BC7_UNorm:
case PixelFormat::BC6H_Uf16:
case PixelFormat::BC6H_Sf16:
return PixelFormat::R16G16B16A16_Float;
case PixelFormat::BC7_UNorm_sRGB:
return PixelFormat::R16G16B16A16_UNorm;
case PixelFormat::ASTC_4x4_UNorm:
case PixelFormat::ASTC_6x6_UNorm:
case PixelFormat::ASTC_8x8_UNorm:
case PixelFormat::ASTC_10x10_UNorm:
return PixelFormat::R8G8B8A8_UNorm;
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 PixelFormat::R8G8B8A8_UNorm_sRGB;
default:
return format;
}
}

View File

@@ -72,7 +72,7 @@ public:
/// <param name="format">The <see cref="PixelFormat"/>.</param>
/// <param name="partialTypeless">Enable/disable partially typeless formats.</param>
/// <returns><c>true</c> if the specified <see cref="PixelFormat"/> is Typeless; otherwise, <c>false</c>.</returns>
API_FUNCTION() static bool IsTypeless(PixelFormat format, bool partialTypeless);
API_FUNCTION() static bool IsTypeless(PixelFormat format, bool partialTypeless = true);
/// <summary>
/// Returns true if the <see cref="PixelFormat"/> is valid.
@@ -215,7 +215,8 @@ public:
API_FUNCTION() static PixelFormat MakeTypelessUNorm(PixelFormat format);
public:
static PixelFormat FindShaderResourceFormat(PixelFormat format, bool bSRGB);
static PixelFormat FindShaderResourceFormat(PixelFormat format, bool sRGB);
static PixelFormat FindUnorderedAccessFormat(PixelFormat format);
static PixelFormat FindDepthStencilFormat(PixelFormat format);
static PixelFormat FindUncompressedFormat(PixelFormat format);
};

View File

@@ -297,7 +297,7 @@ Task* StreamingTexture::UpdateAllocation(int32 residency)
if (texture->Init(desc))
{
Streaming.Error = true;
LOG(Error, "Cannot allocate texture {0}.", ToString());
LOG(Error, "Cannot allocate texture {0}.", texture->GetName());
}
if (allocatedResidency != 0)
{