diff --git a/pcsx2/GS/GSThread_CXX11.h b/pcsx2/GS/GSThread_CXX11.h index 904912e5ac..497c8c69f7 100644 --- a/pcsx2/GS/GSThread_CXX11.h +++ b/pcsx2/GS/GSThread_CXX11.h @@ -17,6 +17,7 @@ #include "GS.h" #include "common/boost_spsc_queue.hpp" +#include "common/General.h" template class GSJobQueue final @@ -49,13 +50,24 @@ private: l.unlock(); - while (m_queue.consume_one(*this)) - ; - + uint32 waited = 0; + while (true) { - std::lock_guard wait_guard(m_wait_lock); + while (m_queue.consume_one(*this)) + waited = 0; + + if (waited == 0) + { + { + std::lock_guard wait_guard(m_wait_lock); + } + m_empty.notify_one(); + } + + if (waited >= SPIN_TIME_NS) + break; + waited += ShortSpin(); } - m_empty.notify_one(); l.lock(); } @@ -98,8 +110,15 @@ public: void Wait() { - if (IsEmpty()) - return; + uint32 waited = 0; + while (true) + { + if (IsEmpty()) + return; + if (waited >= SPIN_TIME_NS) + break; + waited += ShortSpin(); + } std::unique_lock l(m_wait_lock); while (!IsEmpty())