summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/RenderBase.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2021-05-04 21:07:21 -0400
committerGitHub <noreply@github.com>2021-05-04 21:07:21 -0400
commit4b827f3ae9c0931aea3f0cb759aae8f182e05945 (patch)
treef6c6057db7c72bc581aa138862e8af8cfaf33ef4 /Source/Core/VideoCommon/RenderBase.cpp
parenta8c40eb510df2bb26c9baf54bbafafc4262feabb (diff)
parentab55c948a133bf204a62e847aeafe7bd1e2ef1bd (diff)
Merge pull request #9673 from phire/z16peeks
Implement EFB Peeks for compressed z16 formats
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;
}
}