1
0
Fork 0
forked from suyu/suyu

Merge pull request #627 from Subv/bc7u

GPU: Implemented the BC7U texture format.
This commit is contained in:
bunnei 2018-07-07 19:33:18 -07:00 committed by GitHub
commit d990f2355b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 7 deletions

View file

@ -102,6 +102,8 @@ 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_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
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
// DepthStencil formats // DepthStencil formats
@ -191,8 +193,9 @@ 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::ASTC_2D_4X4>, MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>,
MortonCopy<true, PixelFormat::Z32F>,
}; };
static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
@ -206,7 +209,8 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
MortonCopy<false, PixelFormat::RGBA16F>, MortonCopy<false, PixelFormat::RGBA16F>,
MortonCopy<false, PixelFormat::R11FG11FB10F>, MortonCopy<false, PixelFormat::R11FG11FB10F>,
MortonCopy<false, PixelFormat::RGBA32UI>, MortonCopy<false, PixelFormat::RGBA32UI>,
// TODO(Subv): Swizzling the DXT1/DXT23/DXT45/DXN1 formats is not yet supported // TODO(Subv): Swizzling the DXT1/DXT23/DXT45/DXN1/BC7U formats is not yet supported
nullptr,
nullptr, nullptr,
nullptr, nullptr,
nullptr, nullptr,

View file

@ -35,14 +35,15 @@ 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
ASTC_2D_4X4 = 12, BC7U = 12,
ASTC_2D_4X4 = 13,
MaxColorFormat, MaxColorFormat,
// DepthStencil formats // DepthStencil formats
Z24S8 = 13, Z24S8 = 14,
S8Z24 = 14, S8Z24 = 15,
Z32F = 15, Z32F = 16,
MaxDepthStencilFormat, MaxDepthStencilFormat,
@ -92,6 +93,7 @@ struct SurfaceParams {
4, // DXT23 4, // DXT23
4, // DXT45 4, // DXT45
4, // DXN1 4, // DXN1
4, // BC7U
4, // ASTC_2D_4X4 4, // ASTC_2D_4X4
1, // Z24S8 1, // Z24S8
1, // S8Z24 1, // S8Z24
@ -119,6 +121,7 @@ struct SurfaceParams {
128, // DXT23 128, // DXT23
128, // DXT45 128, // DXT45
64, // DXN1 64, // DXN1
128, // BC7U
32, // ASTC_2D_4X4 32, // ASTC_2D_4X4
32, // Z24S8 32, // Z24S8
32, // S8Z24 32, // S8Z24
@ -192,6 +195,8 @@ struct SurfaceParams {
return PixelFormat::DXT45; return PixelFormat::DXT45;
case Tegra::Texture::TextureFormat::DXN1: case Tegra::Texture::TextureFormat::DXN1:
return PixelFormat::DXN1; return PixelFormat::DXN1;
case Tegra::Texture::TextureFormat::BC7U:
return PixelFormat::BC7U;
case Tegra::Texture::TextureFormat::ASTC_2D_4X4: case Tegra::Texture::TextureFormat::ASTC_2D_4X4:
return PixelFormat::ASTC_2D_4X4; return PixelFormat::ASTC_2D_4X4;
default: default:
@ -227,6 +232,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::BC7U:
return Tegra::Texture::TextureFormat::BC7U;
case PixelFormat::ASTC_2D_4X4: case PixelFormat::ASTC_2D_4X4:
return Tegra::Texture::TextureFormat::ASTC_2D_4X4; return Tegra::Texture::TextureFormat::ASTC_2D_4X4;
default: default:

View file

@ -52,6 +52,7 @@ u32 BytesPerPixel(TextureFormat format) {
return 8; return 8;
case TextureFormat::DXT23: case TextureFormat::DXT23:
case TextureFormat::DXT45: case TextureFormat::DXT45:
case TextureFormat::BC7U:
// In this case a 'pixel' actually refers to a 4x4 tile. // In this case a 'pixel' actually refers to a 4x4 tile.
return 16; return 16;
case TextureFormat::ASTC_2D_4X4: case TextureFormat::ASTC_2D_4X4:
@ -98,6 +99,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
case TextureFormat::DXT23: case TextureFormat::DXT23:
case TextureFormat::DXT45: case TextureFormat::DXT45:
case TextureFormat::DXN1: case TextureFormat::DXN1:
case TextureFormat::BC7U:
// In the DXT and DXN formats, each 4x4 tile is swizzled instead of just individual pixel // In the DXT and DXN formats, each 4x4 tile is swizzled instead of just individual pixel
// values. // values.
CopySwizzledData(width / 4, height / 4, bytes_per_pixel, bytes_per_pixel, data, CopySwizzledData(width / 4, height / 4, bytes_per_pixel, bytes_per_pixel, data,
@ -155,6 +157,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
case TextureFormat::DXT23: case TextureFormat::DXT23:
case TextureFormat::DXT45: case TextureFormat::DXT45:
case TextureFormat::DXN1: case TextureFormat::DXN1:
case TextureFormat::BC7U:
case TextureFormat::ASTC_2D_4X4: case TextureFormat::ASTC_2D_4X4:
case TextureFormat::A8R8G8B8: case TextureFormat::A8R8G8B8:
case TextureFormat::A2B10G10R10: case TextureFormat::A2B10G10R10: