Implement BC6H_UF16 & BC6H_SF16

Require by ARMS
This commit is contained in:
greggameplayer
2018-08-16 23:10:13 +02:00
parent 3fd78f4d24
commit 4a79f9a397
3 changed files with 54 additions and 30 deletions

View File

@@ -118,6 +118,10 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
{GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RG, GL_INT, ComponentType::SNorm, true}, // DXN2SNORM
{GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
true}, // BC7U
{GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
true}, // BC6H_UF16
{GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
true}, // BC6H_SF16
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4
{GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8U
{GL_RG8, GL_RG, GL_BYTE, ComponentType::SNorm, false}, // G8R8S
@@ -205,6 +209,8 @@ static bool IsFormatBCn(PixelFormat format) {
case PixelFormat::DXN2SNORM:
case PixelFormat::DXN2UNORM:
case PixelFormat::BC7U:
case PixelFormat::BC6H_UF16:
case PixelFormat::BC6H_SF16:
return true;
}
return false;
@@ -260,6 +266,8 @@ static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPU
MortonCopy<true, PixelFormat::DXN2UNORM>,
MortonCopy<true, PixelFormat::DXN2SNORM>,
MortonCopy<true, PixelFormat::BC7U>,
MortonCopy<true, PixelFormat::BC6H_UF16>,
MortonCopy<true, PixelFormat::BC6H_SF16>,
MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
MortonCopy<true, PixelFormat::G8R8U>,
MortonCopy<true, PixelFormat::G8R8S>,
@@ -307,8 +315,10 @@ static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPU
MortonCopy<false, PixelFormat::RGBA16UI>,
MortonCopy<false, PixelFormat::R11FG11FB10F>,
MortonCopy<false, PixelFormat::RGBA32UI>,
// TODO(Subv): Swizzling DXT1/DXT23/DXT45/DXN1/DXN2/BC7U/ASTC_2D_4X4 formats is not
// supported
// TODO(Subv): Swizzling DXT1/DXT23/DXT45/DXN1/DXN2/BC7U/BC6H_UF16/BC6H_SF16/ASTC_2D_4X4
// formats are not supported
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,

View File

@@ -42,38 +42,40 @@ struct SurfaceParams {
DXN2UNORM = 16,
DXN2SNORM = 17,
BC7U = 18,
ASTC_2D_4X4 = 19,
G8R8U = 20,
G8R8S = 21,
BGRA8 = 22,
RGBA32F = 23,
RG32F = 24,
R32F = 25,
R16F = 26,
R16U = 27,
R16S = 28,
R16UI = 29,
R16I = 30,
RG16 = 31,
RG16F = 32,
RG16UI = 33,
RG16I = 34,
RG16S = 35,
RGB32F = 36,
SRGBA8 = 37,
RG8U = 38,
RG8S = 39,
RG32UI = 40,
R32UI = 41,
BC6H_UF16 = 19,
BC6H_SF16 = 20,
ASTC_2D_4X4 = 21,
G8R8U = 22,
G8R8S = 23,
BGRA8 = 24,
RGBA32F = 25,
RG32F = 26,
R32F = 27,
R16F = 28,
R16U = 29,
R16S = 30,
R16UI = 31,
R16I = 32,
RG16 = 33,
RG16F = 34,
RG16UI = 35,
RG16I = 36,
RG16S = 37,
RGB32F = 38,
SRGBA8 = 39,
RG8U = 40,
RG8S = 41,
RG32UI = 42,
R32UI = 43,
MaxColorFormat,
// DepthStencil formats
Z24S8 = 42,
S8Z24 = 43,
Z32F = 44,
Z16 = 45,
Z32FS8 = 46,
Z24S8 = 44,
S8Z24 = 45,
Z32F = 46,
Z16 = 47,
Z32FS8 = 48,
MaxDepthStencilFormat,
@@ -130,6 +132,8 @@ struct SurfaceParams {
4, // DXN2UNORM
4, // DXN2SNORM
4, // BC7U
4, // BC6H_UF16
4, // BC6H_SF16
4, // ASTC_2D_4X4
1, // G8R8U
1, // G8R8S
@@ -188,6 +192,8 @@ struct SurfaceParams {
128, // DXN2UNORM
128, // DXN2SNORM
128, // BC7U
128, // BC6H_UF16
128, // BC6H_SF16
32, // ASTC_2D_4X4
16, // G8R8U
16, // G8R8S
@@ -469,6 +475,10 @@ struct SurfaceParams {
UNREACHABLE();
case Tegra::Texture::TextureFormat::BC7U:
return PixelFormat::BC7U;
case Tegra::Texture::TextureFormat::BC6H_UF16:
return PixelFormat::BC6H_UF16;
case Tegra::Texture::TextureFormat::BC6H_SF16:
return PixelFormat::BC6H_SF16;
case Tegra::Texture::TextureFormat::ASTC_2D_4X4:
return PixelFormat::ASTC_2D_4X4;
case Tegra::Texture::TextureFormat::R16_G16:

View File

@@ -56,6 +56,8 @@ u32 BytesPerPixel(TextureFormat format) {
case TextureFormat::DXT45:
case TextureFormat::DXN2:
case TextureFormat::BC7U:
case TextureFormat::BC6H_UF16:
case TextureFormat::BC6H_SF16:
// In this case a 'pixel' actually refers to a 4x4 tile.
return 16;
case TextureFormat::R32_G32_B32:
@@ -106,6 +108,8 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
case TextureFormat::DXN1:
case TextureFormat::DXN2:
case TextureFormat::BC7U:
case TextureFormat::BC6H_UF16:
case TextureFormat::BC6H_SF16:
case TextureFormat::ASTC_2D_4X4:
case TextureFormat::A8R8G8B8:
case TextureFormat::A2B10G10R10: