From bcc184acfa81aee7ad33d9c82f5f4496731a1d1f Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 23 Jul 2018 16:56:52 -0400 Subject: gl_rasterizer_cache: Implement RenderTargetFormat BGRA8_UNORM. --- src/video_core/gpu.cpp | 1 + src/video_core/gpu.h | 1 + src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 10 ++++++---- src/video_core/renderer_opengl/gl_rasterizer_cache.h | 18 ++++++++++++++---- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index a003bc9e3..b094d48c3 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -38,6 +38,7 @@ u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { return 8; case RenderTargetFormat::RGBA8_UNORM: case RenderTargetFormat::RGB10_A2_UNORM: + case RenderTargetFormat::BGRA8_UNORM: return 4; default: UNIMPLEMENTED_MSG("Unimplemented render target format {}", static_cast(format)); diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index a32148ecd..9c74cfac3 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -18,6 +18,7 @@ enum class RenderTargetFormat : u32 { RGBA32_FLOAT = 0xC0, RGBA32_UINT = 0xC2, RGBA16_FLOAT = 0xCA, + BGRA8_UNORM = 0xCF, RGB10_A2_UNORM = 0xD1, RGBA8_UNORM = 0xD5, RGBA8_SRGB = 0xD6, diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 28f0bc379..02bd0fa7b 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -106,6 +106,7 @@ static constexpr std::array tex_form true}, // BC7U {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_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8 // DepthStencil formats {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, @@ -197,9 +198,9 @@ static constexpr std::array, MortonCopy, MortonCopy, MortonCopy, MortonCopy, MortonCopy, - MortonCopy, MortonCopy, - MortonCopy, MortonCopy, - MortonCopy, + MortonCopy, MortonCopy, + MortonCopy, MortonCopy, + MortonCopy, MortonCopy, }; static constexpr std::array, MortonCopy, MortonCopy, - // 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, @@ -221,6 +222,7 @@ static constexpr std::array, + MortonCopy, MortonCopy, MortonCopy, MortonCopy, diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index fbdab58be..c0f94936e 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -37,14 +37,15 @@ struct SurfaceParams { BC7U = 12, ASTC_2D_4X4 = 13, G8R8 = 14, + BGRA8 = 15, MaxColorFormat, // DepthStencil formats - Z24S8 = 15, - S8Z24 = 16, - Z32F = 17, - Z16 = 18, + Z24S8 = 16, + S8Z24 = 17, + Z32F = 18, + Z16 = 19, MaxDepthStencilFormat, @@ -97,6 +98,7 @@ struct SurfaceParams { 4, // BC7U 4, // ASTC_2D_4X4 1, // G8R8 + 1, // BGRA8 1, // Z24S8 1, // S8Z24 1, // Z32F @@ -127,6 +129,7 @@ struct SurfaceParams { 128, // BC7U 32, // ASTC_2D_4X4 16, // G8R8 + 32, // BGRA8 32, // Z24S8 32, // S8Z24 32, // Z32F @@ -162,6 +165,8 @@ struct SurfaceParams { case Tegra::RenderTargetFormat::RGBA8_UNORM: case Tegra::RenderTargetFormat::RGBA8_SRGB: return PixelFormat::ABGR8; + case Tegra::RenderTargetFormat::BGRA8_UNORM: + return PixelFormat::BGRA8; case Tegra::RenderTargetFormat::RGB10_A2_UNORM: return PixelFormat::A2B10G10R10; case Tegra::RenderTargetFormat::RGBA16_FLOAT: @@ -248,6 +253,10 @@ struct SurfaceParams { return Tegra::Texture::TextureFormat::BC7U; case PixelFormat::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: LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast(format)); UNREACHABLE(); @@ -286,6 +295,7 @@ struct SurfaceParams { switch (format) { case Tegra::RenderTargetFormat::RGBA8_UNORM: case Tegra::RenderTargetFormat::RGBA8_SRGB: + case Tegra::RenderTargetFormat::BGRA8_UNORM: case Tegra::RenderTargetFormat::RGB10_A2_UNORM: return ComponentType::UNorm; case Tegra::RenderTargetFormat::RGBA16_FLOAT: -- cgit v1.2.3