From a4796e512a614b69caa2976d732a865d8d07189b Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Mon, 26 Apr 2021 21:55:38 +1200 Subject: Implement EFB Peeks for compressed z16 formats This fixes an issue in RS3 where engine lens flares would shine though ships during cutscenes --- Source/Core/VideoCommon/RenderBase.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'Source/Core/VideoCommon/RenderBase.cpp') diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index ba91c0551e..725b39911b 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -230,18 +230,24 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) if (!g_ActiveConfig.backend_info.bSupportsReversedDepthRange) depth = 1.0f - depth; - u32 ret = 0; + // Convert to 24bit depth + u32 z24depth = std::clamp(static_cast(depth * 16777216.0f), 0, 0xFFFFFF); + if (bpmem.zcontrol.pixel_format == PixelFormat::RGB565_Z16) { - // if Z is in 16 bit format you must return a 16 bit integer - ret = std::clamp(static_cast(depth * 65536.0f), 0, 0xFFFF); - } - else - { - ret = std::clamp(static_cast(depth * 16777216.0f), 0, 0xFFFFFF); + // When in RGB565_Z16 mode, EFB Z peeks return a 16bit value, which is presumably a + // resolved sample from the MSAA buffer. + // Dolphin doesn't currently emulate the 3 sample MSAA mode (and potentially never will) + // it just transparently upgrades the framebuffer to 24bit depth and color and whatever + // level of MSAA and higher Internal Resolution the user has configured. + + // This is mostly transparent, unless the game does an EFB read. + // But we can simply convert the 24bit depth on the fly to the 16bit depth the game expects. + + return CompressZ16(z24depth, bpmem.zcontrol.zformat); } - return ret; + return z24depth; } } -- cgit v1.2.3