Implement RGB565 Framebuffer format

This commit is contained in:
greggameplayer
2019-01-12 16:45:18 +01:00
parent f6e998f6ad
commit 865387f3c3
5 changed files with 28 additions and 17 deletions

View File

@@ -18,6 +18,8 @@ u32 FramebufferConfig::BytesPerPixel(PixelFormat format) {
case PixelFormat::ABGR8:
case PixelFormat::BGRA8:
return 4;
case PixelFormat::RGB565:
return 2;
default:
return 4;
}

View File

@@ -80,6 +80,7 @@ class DebugContext;
struct FramebufferConfig {
enum class PixelFormat : u32 {
ABGR8 = 1,
RGB565 = 4,
BGRA8 = 5,
};

View File

@@ -324,6 +324,7 @@ static constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X5
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X4
{GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8
{GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, ComponentType::UNorm, false}, // RGB565U
// Compressed sRGB formats
{GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
true}, // DXT1_SRGB

View File

@@ -410,6 +410,8 @@ PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat
return PixelFormat::ABGR8U;
case Tegra::FramebufferConfig::PixelFormat::BGRA8:
return PixelFormat::BGRA8;
case Tegra::FramebufferConfig::PixelFormat::RGB565:
return PixelFormat::RGB565U;
default:
LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
UNREACHABLE();

View File

@@ -62,31 +62,32 @@ enum class PixelFormat {
ASTC_2D_8X5 = 44,
ASTC_2D_5X4 = 45,
BGRA8_SRGB = 46,
DXT1_SRGB = 47,
DXT23_SRGB = 48,
DXT45_SRGB = 49,
BC7U_SRGB = 50,
ASTC_2D_4X4_SRGB = 51,
ASTC_2D_8X8_SRGB = 52,
ASTC_2D_8X5_SRGB = 53,
ASTC_2D_5X4_SRGB = 54,
ASTC_2D_5X5 = 55,
ASTC_2D_5X5_SRGB = 56,
ASTC_2D_10X8 = 57,
ASTC_2D_10X8_SRGB = 58,
RGB565U = 47,
DXT1_SRGB = 48,
DXT23_SRGB = 49,
DXT45_SRGB = 50,
BC7U_SRGB = 51,
ASTC_2D_4X4_SRGB = 52,
ASTC_2D_8X8_SRGB = 53,
ASTC_2D_8X5_SRGB = 54,
ASTC_2D_5X4_SRGB = 55,
ASTC_2D_5X5 = 56,
ASTC_2D_5X5_SRGB = 57,
ASTC_2D_10X8 = 58,
ASTC_2D_10X8_SRGB = 59,
MaxColorFormat,
// Depth formats
Z32F = 59,
Z16 = 60,
Z32F = 60,
Z16 = 61,
MaxDepthFormat,
// DepthStencil formats
Z24S8 = 61,
S8Z24 = 62,
Z32FS8 = 63,
Z24S8 = 62,
S8Z24 = 63,
Z32FS8 = 64,
MaxDepthStencilFormat,
@@ -171,6 +172,7 @@ constexpr std::array<u32, MaxPixelFormat> compression_factor_table = {{
4, // ASTC_2D_8X5
4, // ASTC_2D_5X4
1, // BGRA8_SRGB
1, // RGB565U
4, // DXT1_SRGB
4, // DXT23_SRGB
4, // DXT45_SRGB
@@ -252,6 +254,7 @@ constexpr std::array<u32, MaxPixelFormat> block_width_table = {{
8, // ASTC_2D_8X5
5, // ASTC_2D_5X4
1, // BGRA8_SRGB
1, // RGB565U
4, // DXT1_SRGB
4, // DXT23_SRGB
4, // DXT45_SRGB
@@ -327,6 +330,7 @@ constexpr std::array<u32, MaxPixelFormat> block_height_table = {{
5, // ASTC_2D_8X5
4, // ASTC_2D_5X4
1, // BGRA8_SRGB
1, // RGB565U
4, // DXT1_SRGB
4, // DXT23_SRGB
4, // DXT45_SRGB
@@ -402,6 +406,7 @@ constexpr std::array<u32, MaxPixelFormat> bpp_table = {{
128, // ASTC_2D_8X5
128, // ASTC_2D_5X4
32, // BGRA8_SRGB
16, // RGB565U
64, // DXT1_SRGB
128, // DXT23_SRGB
128, // DXT45_SRGB