GPU: Implemented the A1B5G5R5 texture format (0x14)

This commit is contained in:
Subv 2018-05-27 09:02:05 -05:00
parent b16e5c6a81
commit 7ddc872b52
4 changed files with 21 additions and 5 deletions

View File

@ -47,6 +47,7 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // ABGR8 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // ABGR8
{GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false}, // B5G6R5 {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false}, // B5G6R5
{GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, false}, // A2B10G10R10 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, false}, // A2B10G10R10
{GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, false}, // A1B5G5R5
{GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1
{GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45
@ -107,8 +108,9 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra:
SurfaceParams::MaxPixelFormat> SurfaceParams::MaxPixelFormat>
morton_to_gl_fns = { morton_to_gl_fns = {
MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>, MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>,
MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::A1B5G5R5>,
MortonCopy<true, PixelFormat::DXT23>, MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
MortonCopy<true, PixelFormat::DXT45>,
}; };
static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra::GPUVAddr, static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra::GPUVAddr,
@ -118,6 +120,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra:
MortonCopy<false, PixelFormat::ABGR8>, MortonCopy<false, PixelFormat::ABGR8>,
MortonCopy<false, PixelFormat::B5G6R5>, MortonCopy<false, PixelFormat::B5G6R5>,
MortonCopy<false, PixelFormat::A2B10G10R10>, MortonCopy<false, PixelFormat::A2B10G10R10>,
MortonCopy<false, PixelFormat::A1B5G5R5>,
// TODO(Subv): Swizzling the DXT1/DXT23/DXT45 formats is not yet supported // TODO(Subv): Swizzling the DXT1/DXT23/DXT45 formats is not yet supported
nullptr, nullptr,
nullptr, nullptr,

View File

@ -57,9 +57,10 @@ struct SurfaceParams {
ABGR8 = 0, ABGR8 = 0,
B5G6R5 = 1, B5G6R5 = 1,
A2B10G10R10 = 2, A2B10G10R10 = 2,
DXT1 = 3, A1B5G5R5 = 3,
DXT23 = 4, DXT1 = 4,
DXT45 = 5, DXT23 = 5,
DXT45 = 6,
Max, Max,
Invalid = 255, Invalid = 255,
@ -98,6 +99,7 @@ struct SurfaceParams {
1, // ABGR8 1, // ABGR8
1, // B5G6R5 1, // B5G6R5
1, // A2B10G10R10 1, // A2B10G10R10
1, // A1B5G5R5
4, // DXT1 4, // DXT1
4, // DXT23 4, // DXT23
4, // DXT45 4, // DXT45
@ -118,6 +120,7 @@ struct SurfaceParams {
32, // ABGR8 32, // ABGR8
16, // B5G6R5 16, // B5G6R5
32, // A2B10G10R10 32, // A2B10G10R10
16, // A1B5G5R5
64, // DXT1 64, // DXT1
128, // DXT23 128, // DXT23
128, // DXT45 128, // DXT45
@ -133,6 +136,7 @@ struct SurfaceParams {
static PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) { static PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) {
switch (format) { switch (format) {
case Tegra::RenderTargetFormat::RGBA8_UNORM: case Tegra::RenderTargetFormat::RGBA8_UNORM:
case Tegra::RenderTargetFormat::RGBA8_SRGB:
return PixelFormat::ABGR8; return PixelFormat::ABGR8;
case Tegra::RenderTargetFormat::RGB10_A2_UNORM: case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
return PixelFormat::A2B10G10R10; return PixelFormat::A2B10G10R10;
@ -161,6 +165,8 @@ struct SurfaceParams {
return PixelFormat::B5G6R5; return PixelFormat::B5G6R5;
case Tegra::Texture::TextureFormat::A2B10G10R10: case Tegra::Texture::TextureFormat::A2B10G10R10:
return PixelFormat::A2B10G10R10; return PixelFormat::A2B10G10R10;
case Tegra::Texture::TextureFormat::A1B5G5R5:
return PixelFormat::A1B5G5R5;
case Tegra::Texture::TextureFormat::DXT1: case Tegra::Texture::TextureFormat::DXT1:
return PixelFormat::DXT1; return PixelFormat::DXT1;
case Tegra::Texture::TextureFormat::DXT23: case Tegra::Texture::TextureFormat::DXT23:
@ -182,6 +188,8 @@ struct SurfaceParams {
return Tegra::Texture::TextureFormat::B5G6R5; return Tegra::Texture::TextureFormat::B5G6R5;
case PixelFormat::A2B10G10R10: case PixelFormat::A2B10G10R10:
return Tegra::Texture::TextureFormat::A2B10G10R10; return Tegra::Texture::TextureFormat::A2B10G10R10;
case PixelFormat::A1B5G5R5:
return Tegra::Texture::TextureFormat::A1B5G5R5;
case PixelFormat::DXT1: case PixelFormat::DXT1:
return Tegra::Texture::TextureFormat::DXT1; return Tegra::Texture::TextureFormat::DXT1;
case PixelFormat::DXT23: case PixelFormat::DXT23:
@ -208,6 +216,7 @@ struct SurfaceParams {
// TODO(Subv): Implement more render targets // TODO(Subv): Implement more render targets
switch (format) { switch (format) {
case Tegra::RenderTargetFormat::RGBA8_UNORM: case Tegra::RenderTargetFormat::RGBA8_UNORM:
case Tegra::RenderTargetFormat::RGBA8_SRGB:
case Tegra::RenderTargetFormat::RGB10_A2_UNORM: case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
return ComponentType::UNorm; return ComponentType::UNorm;
default: default:

View File

@ -55,6 +55,7 @@ u32 BytesPerPixel(TextureFormat format) {
case TextureFormat::A8R8G8B8: case TextureFormat::A8R8G8B8:
case TextureFormat::A2B10G10R10: case TextureFormat::A2B10G10R10:
return 4; return 4;
case TextureFormat::A1B5G5R5:
case TextureFormat::B5G6R5: case TextureFormat::B5G6R5:
return 2; return 2;
default: default:
@ -80,6 +81,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
break; break;
case TextureFormat::A8R8G8B8: case TextureFormat::A8R8G8B8:
case TextureFormat::A2B10G10R10: case TextureFormat::A2B10G10R10:
case TextureFormat::A1B5G5R5:
case TextureFormat::B5G6R5: case TextureFormat::B5G6R5:
CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data,
unswizzled_data.data(), true, block_height); unswizzled_data.data(), true, block_height);
@ -103,6 +105,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
case TextureFormat::DXT45: case TextureFormat::DXT45:
case TextureFormat::A8R8G8B8: case TextureFormat::A8R8G8B8:
case TextureFormat::A2B10G10R10: case TextureFormat::A2B10G10R10:
case TextureFormat::A1B5G5R5:
case TextureFormat::B5G6R5: case TextureFormat::B5G6R5:
// TODO(Subv): For the time being just forward the same data without any decoding. // TODO(Subv): For the time being just forward the same data without any decoding.
rgba_data = texture_data; rgba_data = texture_data;

View File

@ -16,6 +16,7 @@ namespace Texture {
enum class TextureFormat : u32 { enum class TextureFormat : u32 {
A8R8G8B8 = 0x8, A8R8G8B8 = 0x8,
A2B10G10R10 = 0x9, A2B10G10R10 = 0x9,
A1B5G5R5 = 0x14,
B5G6R5 = 0x15, B5G6R5 = 0x15,
DXT1 = 0x24, DXT1 = 0x24,
DXT23 = 0x25, DXT23 = 0x25,