VERY experimental Nintendo Switch 2 emulator
C++
GPU: Use the right texture format for sRGBA framebuffers.
Subva99c559c6967
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cppindex 91ce0357b6..f52ac23f10 100644--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp@@ -113,6 +113,7 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form{GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F{GL_R16F, GL_RED, GL_HALF_FLOAT, ComponentType::Float, false}, // R16F{GL_R16, GL_RED, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // R16UNORM+ {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // SRGBA8// DepthStencil formats{GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm,@@ -209,9 +210,10 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>,MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>,MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::R16F>,- MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::Z24S8>,- MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>,- MortonCopy<true, PixelFormat::Z16>, MortonCopy<true, PixelFormat::Z32FS8>,+ MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::SRGBA8>,+ MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>,+ MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>,+ MortonCopy<true, PixelFormat::Z32FS8>,};static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),@@ -239,6 +241,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),MortonCopy<false, PixelFormat::R32F>,MortonCopy<false, PixelFormat::R16F>,MortonCopy<false, PixelFormat::R16UNORM>,+ MortonCopy<false, PixelFormat::SRGBA8>,MortonCopy<false, PixelFormat::Z24S8>,MortonCopy<false, PixelFormat::S8Z24>,MortonCopy<false, PixelFormat::Z32F>,diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.hindex 0267dbac61..cdf4eae79b 100644--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h@@ -43,15 +43,16 @@ struct SurfaceParams {R32F = 18,R16F = 19,R16UNORM = 20,+ SRGBA8 = 21,MaxColorFormat,// DepthStencil formats- Z24S8 = 21,- S8Z24 = 22,- Z32F = 23,- Z16 = 24,- Z32FS8 = 25,+ Z24S8 = 22,+ S8Z24 = 23,+ Z32F = 24,+ Z16 = 25,+ Z32FS8 = 26,MaxDepthStencilFormat,@@ -110,6 +111,7 @@ struct SurfaceParams {1, // R32F1, // R16F1, // R16UNORM+ 1, // SRGBA81, // Z24S81, // S8Z241, // Z32F@@ -147,6 +149,7 @@ struct SurfaceParams {32, // R32F16, // R16F16, // R16UNORM+ 32, // SRGBA832, // Z24S832, // S8Z2432, // Z32F@@ -182,8 +185,9 @@ struct SurfaceParams {static PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) {switch (format) {- case Tegra::RenderTargetFormat::RGBA8_UNORM:case Tegra::RenderTargetFormat::RGBA8_SRGB:+ return PixelFormat::SRGBA8;+ case Tegra::RenderTargetFormat::RGBA8_UNORM:return PixelFormat::ABGR8;case Tegra::RenderTargetFormat::BGRA8_UNORM:return PixelFormat::BGRA8;@@ -276,6 +280,7 @@ struct SurfaceParams {// TODO(Subv): Properly implement thisswitch (format) {case PixelFormat::ABGR8:+ case PixelFormat::SRGBA8:return Tegra::Texture::TextureFormat::A8R8G8B8;case PixelFormat::B5G6R5:return Tegra::Texture::TextureFormat::B5G6R5;