mirror of https://github.com/PCSX2/pcsx2.git
GSdx:SW: Prevent thread ping-pong in software renderer sync
This commit is contained in:
parent
85f1acb7b7
commit
c3e5b4225b
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "GS.h"
|
||||
#include "common/boost_spsc_queue.hpp"
|
||||
#include "common/General.h"
|
||||
|
||||
template <class T, int CAPACITY>
|
||||
class GSJobQueue final
|
||||
|
@ -49,13 +50,24 @@ private:
|
|||
|
||||
l.unlock();
|
||||
|
||||
while (m_queue.consume_one(*this))
|
||||
;
|
||||
|
||||
uint32 waited = 0;
|
||||
while (true)
|
||||
{
|
||||
std::lock_guard<std::mutex> wait_guard(m_wait_lock);
|
||||
while (m_queue.consume_one(*this))
|
||||
waited = 0;
|
||||
|
||||
if (waited == 0)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> 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<std::mutex> l(m_wait_lock);
|
||||
while (!IsEmpty())
|
||||
|
|
Loading…
Reference in New Issue