summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/RenderBase.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-10-08 22:24:38 +0200
committerGitHub <noreply@github.com>2021-10-08 22:24:38 +0200
commitff1cb5a1c08d5a4a2a0449b8b23a4977ccc20f8a (patch)
treea584d167e0c71c08d4d885f60aa071f5a577692e /Source/Core/VideoCommon/RenderBase.cpp
parentd90b30ca251146c478759190d9b206f38c3b70d3 (diff)
parent1161af80594c403233e3d21589af004ee2d75594 (diff)
Merge pull request #9803 from Techjar/bbox-videocommon
VideoCommon: Abstract bounding box
Diffstat (limited to 'Source/Core/VideoCommon/RenderBase.cpp')
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp39
1 files changed, 34 insertions, 5 deletions
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp
index 6771df83a3..45e42e7931 100644
--- a/Source/Core/VideoCommon/RenderBase.cpp
+++ b/Source/Core/VideoCommon/RenderBase.cpp
@@ -57,6 +57,7 @@
#include "VideoCommon/AbstractTexture.h"
#include "VideoCommon/BPFunctions.h"
#include "VideoCommon/BPMemory.h"
+#include "VideoCommon/BoundingBox.h"
#include "VideoCommon/CPMemory.h"
#include "VideoCommon/CommandProcessor.h"
#include "VideoCommon/FPSCounter.h"
@@ -124,6 +125,13 @@ bool Renderer::Initialize()
if (!m_post_processor->Initialize(m_backbuffer_format))
return false;
+ m_bounding_box = CreateBoundingBox();
+ if (g_ActiveConfig.backend_info.bSupportsBBox && !m_bounding_box->Initialize())
+ {
+ PanicAlertFmt("Failed to initialize bounding box.");
+ return false;
+ }
+
return true;
}
@@ -137,6 +145,7 @@ void Renderer::Shutdown()
ShutdownFrameDumping();
ShutdownImGui();
m_post_processor.reset();
+ m_bounding_box.reset();
}
void Renderer::BeginUtilityDrawing()
@@ -184,15 +193,30 @@ void Renderer::ReinterpretPixelData(EFBReinterpretType convtype)
g_framebuffer_manager->ReinterpretPixelData(convtype);
}
-u16 Renderer::BBoxRead(int index)
+bool Renderer::IsBBoxEnabled() const
+{
+ return m_bounding_box->IsEnabled();
+}
+
+void Renderer::BBoxEnable()
+{
+ m_bounding_box->Enable();
+}
+
+void Renderer::BBoxDisable()
+{
+ m_bounding_box->Disable();
+}
+
+u16 Renderer::BBoxRead(u32 index)
{
if (!g_ActiveConfig.bBBoxEnable || !g_ActiveConfig.backend_info.bSupportsBBox)
return m_bounding_box_fallback[index];
- return BBoxReadImpl(index);
+ return m_bounding_box->Get(index);
}
-void Renderer::BBoxWrite(int index, u16 value)
+void Renderer::BBoxWrite(u32 index, u16 value)
{
if (!g_ActiveConfig.bBBoxEnable || !g_ActiveConfig.backend_info.bSupportsBBox)
{
@@ -200,12 +224,15 @@ void Renderer::BBoxWrite(int index, u16 value)
return;
}
- BBoxWriteImpl(index, value);
+ m_bounding_box->Set(index, value);
}
void Renderer::BBoxFlush()
{
- BBoxFlushImpl();
+ if (!g_ActiveConfig.bBBoxEnable || !g_ActiveConfig.backend_info.bSupportsBBox)
+ return;
+
+ m_bounding_box->Flush();
}
u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
@@ -1761,6 +1788,8 @@ void Renderer::DoState(PointerWrap& p)
p.Do(m_last_xfb_height);
p.DoArray(m_bounding_box_fallback);
+ m_bounding_box->DoState(p);
+
if (p.GetMode() == PointerWrap::MODE_READ)
{
// Force the next xfb to be displayed.