forked from suyu/suyu
Implement SNORM for BC5/DXN2 (#998)
* Implement BC5/DXN2 (#996) - Used by Kirby Star Allies. * Implement BC5/DXN2 SNORM UNORM for Kirby Star Allies SNORM for Super Mario Odyssey
This commit is contained in:
parent
e58f7ff843
commit
75e12a33ae
2 changed files with 55 additions and 38 deletions
|
@ -109,7 +109,9 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
|
||||||
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
|
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
|
||||||
true}, // DXT45
|
true}, // DXT45
|
||||||
{GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1
|
{GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1
|
||||||
{GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN2
|
{GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
|
||||||
|
true}, // DXN2UNORM
|
||||||
|
{GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RG, GL_INT, ComponentType::SNorm, true}, // DXN2SNORM
|
||||||
{GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
|
{GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
|
||||||
true}, // BC7U
|
true}, // BC7U
|
||||||
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4
|
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4
|
||||||
|
@ -219,17 +221,18 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
|
||||||
MortonCopy<true, PixelFormat::R11FG11FB10F>, MortonCopy<true, PixelFormat::RGBA32UI>,
|
MortonCopy<true, PixelFormat::R11FG11FB10F>, MortonCopy<true, PixelFormat::RGBA32UI>,
|
||||||
MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
|
MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
|
||||||
MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>,
|
MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>,
|
||||||
MortonCopy<true, PixelFormat::DXN2>, MortonCopy<true, PixelFormat::BC7U>,
|
MortonCopy<true, PixelFormat::DXN2UNORM>, MortonCopy<true, PixelFormat::DXN2SNORM>,
|
||||||
MortonCopy<true, PixelFormat::ASTC_2D_4X4>, MortonCopy<true, PixelFormat::G8R8>,
|
MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
|
||||||
MortonCopy<true, PixelFormat::BGRA8>, MortonCopy<true, PixelFormat::RGBA32F>,
|
MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>,
|
||||||
MortonCopy<true, PixelFormat::RG32F>, MortonCopy<true, PixelFormat::R32F>,
|
MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>,
|
||||||
MortonCopy<true, PixelFormat::R16F>, MortonCopy<true, PixelFormat::R16UNORM>,
|
MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::R16F>,
|
||||||
MortonCopy<true, PixelFormat::RG16>, MortonCopy<true, PixelFormat::RG16F>,
|
MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::RG16>,
|
||||||
MortonCopy<true, PixelFormat::RG16UI>, MortonCopy<true, PixelFormat::RG16I>,
|
MortonCopy<true, PixelFormat::RG16F>, MortonCopy<true, PixelFormat::RG16UI>,
|
||||||
MortonCopy<true, PixelFormat::RG16S>, MortonCopy<true, PixelFormat::RGB32F>,
|
MortonCopy<true, PixelFormat::RG16I>, MortonCopy<true, PixelFormat::RG16S>,
|
||||||
MortonCopy<true, PixelFormat::SRGBA8>, MortonCopy<true, PixelFormat::Z24S8>,
|
MortonCopy<true, PixelFormat::RGB32F>, MortonCopy<true, PixelFormat::SRGBA8>,
|
||||||
MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>,
|
MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>,
|
||||||
MortonCopy<true, PixelFormat::Z16>, MortonCopy<true, PixelFormat::Z32FS8>,
|
MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>,
|
||||||
|
MortonCopy<true, PixelFormat::Z32FS8>,
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
|
static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
|
||||||
|
@ -251,6 +254,8 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
MortonCopy<false, PixelFormat::G8R8>,
|
MortonCopy<false, PixelFormat::G8R8>,
|
||||||
MortonCopy<false, PixelFormat::BGRA8>,
|
MortonCopy<false, PixelFormat::BGRA8>,
|
||||||
MortonCopy<false, PixelFormat::RGBA32F>,
|
MortonCopy<false, PixelFormat::RGBA32F>,
|
||||||
|
|
|
@ -35,32 +35,33 @@ struct SurfaceParams {
|
||||||
DXT23 = 9,
|
DXT23 = 9,
|
||||||
DXT45 = 10,
|
DXT45 = 10,
|
||||||
DXN1 = 11, // This is also known as BC4
|
DXN1 = 11, // This is also known as BC4
|
||||||
DXN2 = 12, // This is also known as BC5
|
DXN2UNORM = 12,
|
||||||
BC7U = 13,
|
DXN2SNORM = 13,
|
||||||
ASTC_2D_4X4 = 14,
|
BC7U = 14,
|
||||||
G8R8 = 15,
|
ASTC_2D_4X4 = 15,
|
||||||
BGRA8 = 16,
|
G8R8 = 16,
|
||||||
RGBA32F = 17,
|
BGRA8 = 17,
|
||||||
RG32F = 18,
|
RGBA32F = 18,
|
||||||
R32F = 19,
|
RG32F = 19,
|
||||||
R16F = 20,
|
R32F = 20,
|
||||||
R16UNORM = 21,
|
R16F = 21,
|
||||||
RG16 = 22,
|
R16UNORM = 22,
|
||||||
RG16F = 23,
|
RG16 = 23,
|
||||||
RG16UI = 24,
|
RG16F = 24,
|
||||||
RG16I = 25,
|
RG16UI = 25,
|
||||||
RG16S = 26,
|
RG16I = 26,
|
||||||
RGB32F = 27,
|
RG16S = 27,
|
||||||
SRGBA8 = 28,
|
RGB32F = 28,
|
||||||
|
SRGBA8 = 29,
|
||||||
|
|
||||||
MaxColorFormat,
|
MaxColorFormat,
|
||||||
|
|
||||||
// DepthStencil formats
|
// DepthStencil formats
|
||||||
Z24S8 = 29,
|
Z24S8 = 30,
|
||||||
S8Z24 = 30,
|
S8Z24 = 31,
|
||||||
Z32F = 31,
|
Z32F = 32,
|
||||||
Z16 = 32,
|
Z16 = 33,
|
||||||
Z32FS8 = 33,
|
Z32FS8 = 34,
|
||||||
|
|
||||||
MaxDepthStencilFormat,
|
MaxDepthStencilFormat,
|
||||||
|
|
||||||
|
@ -110,7 +111,8 @@ struct SurfaceParams {
|
||||||
4, // DXT23
|
4, // DXT23
|
||||||
4, // DXT45
|
4, // DXT45
|
||||||
4, // DXN1
|
4, // DXN1
|
||||||
4, // DXN2
|
4, // DXN2UNORM
|
||||||
|
4, // DXN2SNORM
|
||||||
4, // BC7U
|
4, // BC7U
|
||||||
4, // ASTC_2D_4X4
|
4, // ASTC_2D_4X4
|
||||||
1, // G8R8
|
1, // G8R8
|
||||||
|
@ -155,7 +157,8 @@ struct SurfaceParams {
|
||||||
128, // DXT23
|
128, // DXT23
|
||||||
128, // DXT45
|
128, // DXT45
|
||||||
64, // DXN1
|
64, // DXN1
|
||||||
128, // DXN2
|
128, // DXN2UNORM
|
||||||
|
128, // DXN2SNORM
|
||||||
128, // BC7U
|
128, // BC7U
|
||||||
32, // ASTC_2D_4X4
|
32, // ASTC_2D_4X4
|
||||||
16, // G8R8
|
16, // G8R8
|
||||||
|
@ -309,7 +312,15 @@ struct SurfaceParams {
|
||||||
case Tegra::Texture::TextureFormat::DXN1:
|
case Tegra::Texture::TextureFormat::DXN1:
|
||||||
return PixelFormat::DXN1;
|
return PixelFormat::DXN1;
|
||||||
case Tegra::Texture::TextureFormat::DXN2:
|
case Tegra::Texture::TextureFormat::DXN2:
|
||||||
return PixelFormat::DXN2;
|
switch (component_type) {
|
||||||
|
case Tegra::Texture::ComponentType::UNORM:
|
||||||
|
return PixelFormat::DXN2UNORM;
|
||||||
|
case Tegra::Texture::ComponentType::SNORM:
|
||||||
|
return PixelFormat::DXN2SNORM;
|
||||||
|
}
|
||||||
|
LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
|
||||||
|
static_cast<u32>(component_type));
|
||||||
|
UNREACHABLE();
|
||||||
case Tegra::Texture::TextureFormat::BC7U:
|
case Tegra::Texture::TextureFormat::BC7U:
|
||||||
return PixelFormat::BC7U;
|
return PixelFormat::BC7U;
|
||||||
case Tegra::Texture::TextureFormat::ASTC_2D_4X4:
|
case Tegra::Texture::TextureFormat::ASTC_2D_4X4:
|
||||||
|
@ -367,7 +378,8 @@ struct SurfaceParams {
|
||||||
return Tegra::Texture::TextureFormat::DXT45;
|
return Tegra::Texture::TextureFormat::DXT45;
|
||||||
case PixelFormat::DXN1:
|
case PixelFormat::DXN1:
|
||||||
return Tegra::Texture::TextureFormat::DXN1;
|
return Tegra::Texture::TextureFormat::DXN1;
|
||||||
case PixelFormat::DXN2:
|
case PixelFormat::DXN2UNORM:
|
||||||
|
case PixelFormat::DXN2SNORM:
|
||||||
return Tegra::Texture::TextureFormat::DXN2;
|
return Tegra::Texture::TextureFormat::DXN2;
|
||||||
case PixelFormat::BC7U:
|
case PixelFormat::BC7U:
|
||||||
return Tegra::Texture::TextureFormat::BC7U;
|
return Tegra::Texture::TextureFormat::BC7U;
|
||||||
|
|
Loading…
Reference in a new issue