summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/RenderBase.cpp
diff options
context:
space:
mode:
authorScott Mansell <phiren@gmail.com>2021-04-26 21:55:38 +1200
committerScott Mansell <phiren@gmail.com>2021-05-05 11:32:29 +1200
commita4796e512a614b69caa2976d732a865d8d07189b (patch)
tree9e629e99cae8697f2b843ce17f9dc003c4acda28 /Source/Core/VideoCommon/RenderBase.cpp
parent0f563ffd59857424fd6281e4630d5564c9a7164e (diff)
Implement EFB Peeks for compressed z16 formats
This fixes an issue in RS3 where engine lens flares would shine though ships during cutscenes
Diffstat (limited to 'Source/Core/VideoCommon/RenderBase.cpp')
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp22
1 files changed, 14 insertions, 8 deletions
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<u32>(static_cast<u32>(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<u32>(static_cast<u32>(depth * 65536.0f), 0, 0xFFFF);
- }
- else
- {
- ret = std::clamp<u32>(static_cast<u32>(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;
}
}