summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/RenderBase.cpp
diff options
context:
space:
mode:
authorTechjar <tecknojar@gmail.com>2021-05-31 16:31:27 -0400
committerTechjar <tecknojar@gmail.com>2021-05-31 19:56:24 -0400
commit8cfe49295f105506a270ff350a9ea717e8af2172 (patch)
treeda7bc8b5e6d18502964e124e6570c668da8fb890 /Source/Core/VideoCommon/RenderBase.cpp
parent2f1b639f0ad191a977bfaabdeff24ccef4914099 (diff)
VideoCommon: Add fallback handling for bounding box when disabled or unsupported
The SDK seems to write "default" bounding box values before every draw (1023 0 1023 0 are the only values encountered so far, which happen to be the extents allowed by the BP registers) to reset the registers for comparison in the pixel engine, and presumably to detect whether GX has updated the registers with real values. Handling these writes and returning them on read when bounding box emulation is disabled or unsupported, even without computing real values from rendering, seems to prevent games from corrupting memory or crashing. This obviously does not fix any effects that rely on bounding box emulation, but having the game not clobber its own code/data or just outright crash is a definite improvement.
Diffstat (limited to 'Source/Core/VideoCommon/RenderBase.cpp')
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp
index f93d498fc6..5422d26e94 100644
--- a/Source/Core/VideoCommon/RenderBase.cpp
+++ b/Source/Core/VideoCommon/RenderBase.cpp
@@ -187,11 +187,20 @@ void Renderer::ReinterpretPixelData(EFBReinterpretType convtype)
u16 Renderer::BBoxRead(int index)
{
+ if (!g_ActiveConfig.bBBoxEnable || !g_ActiveConfig.backend_info.bSupportsBBox)
+ return m_bounding_box_fallback[index];
+
return BBoxReadImpl(index);
}
void Renderer::BBoxWrite(int index, u16 value)
{
+ if (!g_ActiveConfig.bBBoxEnable || !g_ActiveConfig.backend_info.bSupportsBBox)
+ {
+ m_bounding_box_fallback[index] = value;
+ return;
+ }
+
BBoxWriteImpl(index, value);
}
@@ -1748,6 +1757,7 @@ void Renderer::DoState(PointerWrap& p)
p.Do(m_last_xfb_width);
p.Do(m_last_xfb_stride);
p.Do(m_last_xfb_height);
+ p.DoArray(m_bounding_box_fallback);
if (p.GetMode() == PointerWrap::MODE_READ)
{