forked from ShuriZma/suyu
1
0
Fork 0

gl_rasterizer_cache: Implement RenderTargetFormat BGRA8_UNORM.

This commit is contained in:
bunnei 2018-07-23 16:56:52 -04:00
parent 89db8c2171
commit bcc184acfa
4 changed files with 22 additions and 8 deletions

View File

@ -38,6 +38,7 @@ u32 RenderTargetBytesPerPixel(RenderTargetFormat format) {
return 8; return 8;
case RenderTargetFormat::RGBA8_UNORM: case RenderTargetFormat::RGBA8_UNORM:
case RenderTargetFormat::RGB10_A2_UNORM: case RenderTargetFormat::RGB10_A2_UNORM:
case RenderTargetFormat::BGRA8_UNORM:
return 4; return 4;
default: default:
UNIMPLEMENTED_MSG("Unimplemented render target format {}", static_cast<u32>(format)); UNIMPLEMENTED_MSG("Unimplemented render target format {}", static_cast<u32>(format));

View File

@ -18,6 +18,7 @@ enum class RenderTargetFormat : u32 {
RGBA32_FLOAT = 0xC0, RGBA32_FLOAT = 0xC0,
RGBA32_UINT = 0xC2, RGBA32_UINT = 0xC2,
RGBA16_FLOAT = 0xCA, RGBA16_FLOAT = 0xCA,
BGRA8_UNORM = 0xCF,
RGB10_A2_UNORM = 0xD1, RGB10_A2_UNORM = 0xD1,
RGBA8_UNORM = 0xD5, RGBA8_UNORM = 0xD5,
RGBA8_SRGB = 0xD6, RGBA8_SRGB = 0xD6,

View File

@ -106,6 +106,7 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
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
{GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8
{GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8
// DepthStencil formats // DepthStencil formats
{GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm,
@ -197,9 +198,9 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
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::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>, MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>,
MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>,
MortonCopy<true, PixelFormat::Z16>, MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>,
}; };
static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
@ -213,7 +214,7 @@ 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/BC7U formats is not yet supported // TODO(Subv): Swizzling DXT1/DXT23/DXT45/DXN1/BC7U/ASTC_2D_4X4 formats is not supported
nullptr, nullptr,
nullptr, nullptr,
nullptr, nullptr,
@ -221,6 +222,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
nullptr, nullptr,
nullptr, nullptr,
MortonCopy<false, PixelFormat::G8R8>, MortonCopy<false, PixelFormat::G8R8>,
MortonCopy<false, PixelFormat::BGRA8>,
MortonCopy<false, PixelFormat::Z24S8>, MortonCopy<false, PixelFormat::Z24S8>,
MortonCopy<false, PixelFormat::S8Z24>, MortonCopy<false, PixelFormat::S8Z24>,
MortonCopy<false, PixelFormat::Z32F>, MortonCopy<false, PixelFormat::Z32F>,

View File

@ -37,14 +37,15 @@ struct SurfaceParams {
BC7U = 12, BC7U = 12,
ASTC_2D_4X4 = 13, ASTC_2D_4X4 = 13,
G8R8 = 14, G8R8 = 14,
BGRA8 = 15,
MaxColorFormat, MaxColorFormat,
// DepthStencil formats // DepthStencil formats
Z24S8 = 15, Z24S8 = 16,
S8Z24 = 16, S8Z24 = 17,
Z32F = 17, Z32F = 18,
Z16 = 18, Z16 = 19,
MaxDepthStencilFormat, MaxDepthStencilFormat,
@ -97,6 +98,7 @@ struct SurfaceParams {
4, // BC7U 4, // BC7U
4, // ASTC_2D_4X4 4, // ASTC_2D_4X4
1, // G8R8 1, // G8R8
1, // BGRA8
1, // Z24S8 1, // Z24S8
1, // S8Z24 1, // S8Z24
1, // Z32F 1, // Z32F
@ -127,6 +129,7 @@ struct SurfaceParams {
128, // BC7U 128, // BC7U
32, // ASTC_2D_4X4 32, // ASTC_2D_4X4
16, // G8R8 16, // G8R8
32, // BGRA8
32, // Z24S8 32, // Z24S8
32, // S8Z24 32, // S8Z24
32, // Z32F 32, // Z32F
@ -162,6 +165,8 @@ struct SurfaceParams {
case Tegra::RenderTargetFormat::RGBA8_UNORM: case Tegra::RenderTargetFormat::RGBA8_UNORM:
case Tegra::RenderTargetFormat::RGBA8_SRGB: case Tegra::RenderTargetFormat::RGBA8_SRGB:
return PixelFormat::ABGR8; return PixelFormat::ABGR8;
case Tegra::RenderTargetFormat::BGRA8_UNORM:
return PixelFormat::BGRA8;
case Tegra::RenderTargetFormat::RGB10_A2_UNORM: case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
return PixelFormat::A2B10G10R10; return PixelFormat::A2B10G10R10;
case Tegra::RenderTargetFormat::RGBA16_FLOAT: case Tegra::RenderTargetFormat::RGBA16_FLOAT:
@ -248,6 +253,10 @@ struct SurfaceParams {
return Tegra::Texture::TextureFormat::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;
case PixelFormat::BGRA8:
// TODO(bunnei): This is fine for unswizzling (since we just need the right component
// sizes), but could be a bug if we used this function in different ways.
return Tegra::Texture::TextureFormat::A8R8G8B8;
default: default:
LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
UNREACHABLE(); UNREACHABLE();
@ -286,6 +295,7 @@ struct SurfaceParams {
switch (format) { switch (format) {
case Tegra::RenderTargetFormat::RGBA8_UNORM: case Tegra::RenderTargetFormat::RGBA8_UNORM:
case Tegra::RenderTargetFormat::RGBA8_SRGB: case Tegra::RenderTargetFormat::RGBA8_SRGB:
case Tegra::RenderTargetFormat::BGRA8_UNORM:
case Tegra::RenderTargetFormat::RGB10_A2_UNORM: case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
return ComponentType::UNorm; return ComponentType::UNorm;
case Tegra::RenderTargetFormat::RGBA16_FLOAT: case Tegra::RenderTargetFormat::RGBA16_FLOAT: