forked from ShuriZma/suyu
1
0
Fork 0

Merge pull request #1955 from bunnei/g8r8-fix

gpu: Remove PixelFormat G8R8U and G8R8S, as they do not seem to exist.
This commit is contained in:
bunnei 2018-12-28 20:23:57 -05:00 committed by GitHub
commit 8495f1df2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 79 deletions

View File

@ -66,8 +66,6 @@ static constexpr ConversionArray morton_to_linear_fns = {
MortonCopy<true, PixelFormat::BC6H_UF16>, MortonCopy<true, PixelFormat::BC6H_UF16>,
MortonCopy<true, PixelFormat::BC6H_SF16>, MortonCopy<true, PixelFormat::BC6H_SF16>,
MortonCopy<true, PixelFormat::ASTC_2D_4X4>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
MortonCopy<true, PixelFormat::G8R8U>,
MortonCopy<true, PixelFormat::G8R8S>,
MortonCopy<true, PixelFormat::BGRA8>, MortonCopy<true, PixelFormat::BGRA8>,
MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RGBA32F>,
MortonCopy<true, PixelFormat::RG32F>, MortonCopy<true, PixelFormat::RG32F>,
@ -138,8 +136,6 @@ static constexpr ConversionArray linear_to_morton_fns = {
MortonCopy<false, PixelFormat::BC6H_SF16>, MortonCopy<false, PixelFormat::BC6H_SF16>,
// TODO(Subv): Swizzling ASTC formats are not supported // TODO(Subv): Swizzling ASTC formats are not supported
nullptr, nullptr,
MortonCopy<false, PixelFormat::G8R8U>,
MortonCopy<false, PixelFormat::G8R8S>,
MortonCopy<false, PixelFormat::BGRA8>, MortonCopy<false, PixelFormat::BGRA8>,
MortonCopy<false, PixelFormat::RGBA32F>, MortonCopy<false, PixelFormat::RGBA32F>,
MortonCopy<false, PixelFormat::RG32F>, MortonCopy<false, PixelFormat::RG32F>,

View File

@ -288,8 +288,6 @@ static constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex
{GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::Float, {GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::Float,
true}, // BC6H_SF16 true}, // BC6H_SF16
{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
{GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8U
{GL_RG8, GL_RG, GL_BYTE, ComponentType::SNorm, false}, // G8R8S
{GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8 {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8
{GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F
{GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F
@ -620,18 +618,6 @@ static void ConvertS8Z24ToZ24S8(std::vector<u8>& data, u32 width, u32 height, bo
} }
} }
static void ConvertG8R8ToR8G8(std::vector<u8>& data, u32 width, u32 height) {
constexpr auto bpp{GetBytesPerPixel(PixelFormat::G8R8U)};
for (std::size_t y = 0; y < height; ++y) {
for (std::size_t x = 0; x < width; ++x) {
const std::size_t offset{bpp * (y * width + x)};
const u8 temp{data[offset]};
data[offset] = data[offset + 1];
data[offset + 1] = temp;
}
}
}
/** /**
* Helper function to perform software conversion (as needed) when loading a buffer from Switch * Helper function to perform software conversion (as needed) when loading a buffer from Switch
* memory. This is for Maxwell pixel formats that cannot be represented as-is in OpenGL or with * memory. This is for Maxwell pixel formats that cannot be represented as-is in OpenGL or with
@ -664,12 +650,6 @@ static void ConvertFormatAsNeeded_LoadGLBuffer(std::vector<u8>& data, PixelForma
// Convert the S8Z24 depth format to Z24S8, as OpenGL does not support S8Z24. // Convert the S8Z24 depth format to Z24S8, as OpenGL does not support S8Z24.
ConvertS8Z24ToZ24S8(data, width, height, false); ConvertS8Z24ToZ24S8(data, width, height, false);
break; break;
case PixelFormat::G8R8U:
case PixelFormat::G8R8S:
// Convert the G8R8 color format to R8G8, as OpenGL does not support G8R8.
ConvertG8R8ToR8G8(data, width, height);
break;
} }
} }
@ -681,8 +661,6 @@ static void ConvertFormatAsNeeded_LoadGLBuffer(std::vector<u8>& data, PixelForma
static void ConvertFormatAsNeeded_FlushGLBuffer(std::vector<u8>& data, PixelFormat pixel_format, static void ConvertFormatAsNeeded_FlushGLBuffer(std::vector<u8>& data, PixelFormat pixel_format,
u32 width, u32 height) { u32 width, u32 height) {
switch (pixel_format) { switch (pixel_format) {
case PixelFormat::G8R8U:
case PixelFormat::G8R8S:
case PixelFormat::ASTC_2D_4X4: case PixelFormat::ASTC_2D_4X4:
case PixelFormat::ASTC_2D_8X8: case PixelFormat::ASTC_2D_8X8:
case PixelFormat::ASTC_2D_4X4_SRGB: case PixelFormat::ASTC_2D_4X4_SRGB:

View File

@ -196,11 +196,14 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,
LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));
UNREACHABLE(); UNREACHABLE();
case Tegra::Texture::TextureFormat::G8R8: case Tegra::Texture::TextureFormat::G8R8:
// TextureFormat::G8R8 is actually ordered red then green, as such we can use
// PixelFormat::RG8U and PixelFormat::RG8S. This was tested with The Legend of Zelda: Breath
// of the Wild, which uses this format to render the hearts on the UI.
switch (component_type) { switch (component_type) {
case Tegra::Texture::ComponentType::UNORM: case Tegra::Texture::ComponentType::UNORM:
return PixelFormat::G8R8U; return PixelFormat::RG8U;
case Tegra::Texture::ComponentType::SNORM: case Tegra::Texture::ComponentType::SNORM:
return PixelFormat::G8R8S; return PixelFormat::RG8S;
} }
LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type)); LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", static_cast<u32>(component_type));
UNREACHABLE(); UNREACHABLE();

View File

@ -38,57 +38,55 @@ enum class PixelFormat {
BC6H_UF16 = 20, BC6H_UF16 = 20,
BC6H_SF16 = 21, BC6H_SF16 = 21,
ASTC_2D_4X4 = 22, ASTC_2D_4X4 = 22,
G8R8U = 23, BGRA8 = 23,
G8R8S = 24, RGBA32F = 24,
BGRA8 = 25, RG32F = 25,
RGBA32F = 26, R32F = 26,
RG32F = 27, R16F = 27,
R32F = 28, R16U = 28,
R16F = 29, R16S = 29,
R16U = 30, R16UI = 30,
R16S = 31, R16I = 31,
R16UI = 32, RG16 = 32,
R16I = 33, RG16F = 33,
RG16 = 34, RG16UI = 34,
RG16F = 35, RG16I = 35,
RG16UI = 36, RG16S = 36,
RG16I = 37, RGB32F = 37,
RG16S = 38, RGBA8_SRGB = 38,
RGB32F = 39, RG8U = 39,
RGBA8_SRGB = 40, RG8S = 40,
RG8U = 41, RG32UI = 41,
RG8S = 42, R32UI = 42,
RG32UI = 43, ASTC_2D_8X8 = 43,
R32UI = 44, ASTC_2D_8X5 = 44,
ASTC_2D_8X8 = 45, ASTC_2D_5X4 = 45,
ASTC_2D_8X5 = 46, BGRA8_SRGB = 46,
ASTC_2D_5X4 = 47, DXT1_SRGB = 47,
BGRA8_SRGB = 48, DXT23_SRGB = 48,
DXT1_SRGB = 49, DXT45_SRGB = 49,
DXT23_SRGB = 50, BC7U_SRGB = 50,
DXT45_SRGB = 51, ASTC_2D_4X4_SRGB = 51,
BC7U_SRGB = 52, ASTC_2D_8X8_SRGB = 52,
ASTC_2D_4X4_SRGB = 53, ASTC_2D_8X5_SRGB = 53,
ASTC_2D_8X8_SRGB = 54, ASTC_2D_5X4_SRGB = 54,
ASTC_2D_8X5_SRGB = 55, ASTC_2D_5X5 = 55,
ASTC_2D_5X4_SRGB = 56, ASTC_2D_5X5_SRGB = 56,
ASTC_2D_5X5 = 57, ASTC_2D_10X8 = 57,
ASTC_2D_5X5_SRGB = 58, ASTC_2D_10X8_SRGB = 58,
ASTC_2D_10X8 = 59,
ASTC_2D_10X8_SRGB = 60,
MaxColorFormat, MaxColorFormat,
// Depth formats // Depth formats
Z32F = 61, Z32F = 59,
Z16 = 62, Z16 = 60,
MaxDepthFormat, MaxDepthFormat,
// DepthStencil formats // DepthStencil formats
Z24S8 = 63, Z24S8 = 61,
S8Z24 = 64, S8Z24 = 62,
Z32FS8 = 65, Z32FS8 = 63,
MaxDepthStencilFormat, MaxDepthStencilFormat,
@ -149,8 +147,6 @@ constexpr std::array<u32, MaxPixelFormat> compression_factor_table = {{
4, // BC6H_UF16 4, // BC6H_UF16
4, // BC6H_SF16 4, // BC6H_SF16
4, // ASTC_2D_4X4 4, // ASTC_2D_4X4
1, // G8R8U
1, // G8R8S
1, // BGRA8 1, // BGRA8
1, // RGBA32F 1, // RGBA32F
1, // RG32F 1, // RG32F
@ -232,8 +228,6 @@ constexpr std::array<u32, MaxPixelFormat> block_width_table = {{
4, // BC6H_UF16 4, // BC6H_UF16
4, // BC6H_SF16 4, // BC6H_SF16
4, // ASTC_2D_4X4 4, // ASTC_2D_4X4
1, // G8R8U
1, // G8R8S
1, // BGRA8 1, // BGRA8
1, // RGBA32F 1, // RGBA32F
1, // RG32F 1, // RG32F
@ -309,8 +303,6 @@ constexpr std::array<u32, MaxPixelFormat> block_height_table = {{
4, // BC6H_UF16 4, // BC6H_UF16
4, // BC6H_SF16 4, // BC6H_SF16
4, // ASTC_2D_4X4 4, // ASTC_2D_4X4
1, // G8R8U
1, // G8R8S
1, // BGRA8 1, // BGRA8
1, // RGBA32F 1, // RGBA32F
1, // RG32F 1, // RG32F
@ -386,8 +378,6 @@ constexpr std::array<u32, MaxPixelFormat> bpp_table = {{
128, // BC6H_UF16 128, // BC6H_UF16
128, // BC6H_SF16 128, // BC6H_SF16
128, // ASTC_2D_4X4 128, // ASTC_2D_4X4
16, // G8R8U
16, // G8R8S
32, // BGRA8 32, // BGRA8
128, // RGBA32F 128, // RGBA32F
64, // RG32F 64, // RG32F