summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/AsyncRequests.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2025-03-06 21:14:38 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2025-03-14 00:59:41 -0500
commit63b848ca9386a870151b8d6482f4ffceb0b41f5e (patch)
treeb242943549f4a777d17ec89e76dac0c6f77f021a /Source/Core/VideoCommon/AsyncRequests.cpp
parentca9b34a6d1e7ad03c4879239e9c5b79a6c47522e (diff)
VideoCommon: Eliminate EFBAccessType enum. Eliminate union and switch statement handler in AsyncRequests.
Diffstat (limited to 'Source/Core/VideoCommon/AsyncRequests.cpp')
-rw-r--r--Source/Core/VideoCommon/AsyncRequests.cpp87
1 files changed, 6 insertions, 81 deletions
diff --git a/Source/Core/VideoCommon/AsyncRequests.cpp b/Source/Core/VideoCommon/AsyncRequests.cpp
index 81b44ca042..0469d3ebb9 100644
--- a/Source/Core/VideoCommon/AsyncRequests.cpp
+++ b/Source/Core/VideoCommon/AsyncRequests.cpp
@@ -7,15 +7,10 @@
#include "Core/System.h"
-#include "VideoCommon/BoundingBox.h"
-#include "VideoCommon/EFBInterface.h"
#include "VideoCommon/Fifo.h"
-#include "VideoCommon/Present.h"
-#include "VideoCommon/Statistics.h"
#include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoEvents.h"
-#include "VideoCommon/VideoState.h"
AsyncRequests AsyncRequests::s_singleton;
@@ -32,46 +27,28 @@ void AsyncRequests::PullEventsInternal()
while (!m_queue.empty())
{
- Event e = m_queue.front();
-
+ Event e = std::move(m_queue.front());
lock.unlock();
- HandleEvent(e);
+ std::invoke(e);
lock.lock();
m_queue.pop();
}
- if (m_wake_me_up_again)
- {
- m_wake_me_up_again = false;
- m_cond.notify_all();
- }
+ m_cond.notify_one();
}
-void AsyncRequests::PushEvent(const AsyncRequests::Event& event, bool blocking)
+void AsyncRequests::QueueEvent(Event&& event)
{
- std::unique_lock<std::mutex> lock(m_mutex);
-
- if (m_passthrough)
- {
- HandleEvent(event);
- return;
- }
-
m_empty.Clear();
- m_wake_me_up_again |= blocking;
if (!m_enable)
return;
- m_queue.push(event);
+ m_queue.push(std::move(event));
auto& system = Core::System::GetInstance();
system.GetFifo().RunGpu();
- if (blocking)
- {
- m_cond.wait(lock, [this] { return m_queue.empty(); });
- }
}
void AsyncRequests::WaitForEmptyQueue()
@@ -90,59 +67,7 @@ void AsyncRequests::SetEnable(bool enable)
// flush the queue on disabling
while (!m_queue.empty())
m_queue.pop();
- if (m_wake_me_up_again)
- m_cond.notify_all();
- }
-}
-
-void AsyncRequests::HandleEvent(const AsyncRequests::Event& e)
-{
- switch (e.type)
- {
- case Event::EFB_POKE_COLOR:
- {
- INCSTAT(g_stats.this_frame.num_efb_pokes);
- g_efb_interface->PokeColor(e.efb_poke.x, e.efb_poke.y, e.efb_poke.data);
- }
- break;
-
- case Event::EFB_POKE_Z:
- {
- INCSTAT(g_stats.this_frame.num_efb_pokes);
- g_efb_interface->PokeDepth(e.efb_poke.x, e.efb_poke.y, e.efb_poke.data);
- }
- break;
-
- case Event::EFB_PEEK_COLOR:
- INCSTAT(g_stats.this_frame.num_efb_peeks);
- *e.efb_peek.data = g_efb_interface->PeekColor(e.efb_peek.x, e.efb_peek.y);
- break;
-
- case Event::EFB_PEEK_Z:
- INCSTAT(g_stats.this_frame.num_efb_peeks);
- *e.efb_peek.data = g_efb_interface->PeekDepth(e.efb_peek.x, e.efb_peek.y);
- break;
-
- case Event::SWAP_EVENT:
- g_presenter->ViSwap(e.swap_event.xfbAddr, e.swap_event.fbWidth, e.swap_event.fbStride,
- e.swap_event.fbHeight, e.time, e.swap_event.presentation_time);
- break;
-
- case Event::BBOX_READ:
- *e.bbox.data = g_bounding_box->Get(e.bbox.index);
- break;
-
- case Event::FIFO_RESET:
- Core::System::GetInstance().GetFifo().ResetVideoBuffer();
- break;
-
- case Event::PERF_QUERY:
- g_perf_query->FlushResults();
- break;
-
- case Event::DO_SAVE_STATE:
- VideoCommon_DoState(*e.do_save_state.p);
- break;
+ m_cond.notify_one();
}
}