mirror of https://github.com/PCSX2/pcsx2.git
MTVU: Use WorkSema
This commit is contained in:
parent
d733730950
commit
481c92c1c8
|
@ -400,7 +400,6 @@ void SysMtgsThread::ExecuteTaskInThread()
|
||||||
case GS_RINGTYPE_MTVU_GSPACKET:
|
case GS_RINGTYPE_MTVU_GSPACKET:
|
||||||
{
|
{
|
||||||
MTVU_LOG("MTGS - Waiting on semaXGkick!");
|
MTVU_LOG("MTGS - Waiting on semaXGkick!");
|
||||||
vu1Thread.KickStart(true);
|
|
||||||
if (!vu1Thread.semaXGkick.TryWait())
|
if (!vu1Thread.semaXGkick.TryWait())
|
||||||
{
|
{
|
||||||
busy.PartialRelease();
|
busy.PartialRelease();
|
||||||
|
|
|
@ -105,10 +105,7 @@ VU_Thread::~VU_Thread()
|
||||||
|
|
||||||
void VU_Thread::Reset()
|
void VU_Thread::Reset()
|
||||||
{
|
{
|
||||||
ScopedLock lock(mtxBusy);
|
|
||||||
|
|
||||||
vuCycleIdx = 0;
|
vuCycleIdx = 0;
|
||||||
isBusy = false;
|
|
||||||
m_ato_write_pos = 0;
|
m_ato_write_pos = 0;
|
||||||
m_write_pos = 0;
|
m_write_pos = 0;
|
||||||
m_ato_read_pos = 0;
|
m_ato_read_pos = 0;
|
||||||
|
@ -133,8 +130,7 @@ void VU_Thread::ExecuteRingBuffer()
|
||||||
{
|
{
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
semaEvent.WaitWithoutYield();
|
semaEvent.WaitForWork();
|
||||||
ScopedLockBool lock(mtxBusy, isBusy);
|
|
||||||
while (m_ato_read_pos.load(std::memory_order_relaxed) != GetWritePos())
|
while (m_ato_read_pos.load(std::memory_order_relaxed) != GetWritePos())
|
||||||
{
|
{
|
||||||
u32 tag = Read();
|
u32 tag = Read();
|
||||||
|
@ -419,10 +415,9 @@ void VU_Thread::Get_MTVUChanges()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VU_Thread::KickStart(bool forceKick)
|
void VU_Thread::KickStart()
|
||||||
{
|
{
|
||||||
if ((forceKick && !semaEvent.Count()) || (!isBusy.load(std::memory_order_acquire) && GetReadPos() != m_ato_write_pos.load(std::memory_order_relaxed)))
|
semaEvent.NotifyOfWork();
|
||||||
semaEvent.Post();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VU_Thread::IsDone()
|
bool VU_Thread::IsDone()
|
||||||
|
@ -433,16 +428,7 @@ bool VU_Thread::IsDone()
|
||||||
void VU_Thread::WaitVU()
|
void VU_Thread::WaitVU()
|
||||||
{
|
{
|
||||||
MTVU_LOG("MTVU - WaitVU!");
|
MTVU_LOG("MTVU - WaitVU!");
|
||||||
for (;;)
|
semaEvent.WaitForEmpty();
|
||||||
{
|
|
||||||
if (IsDone())
|
|
||||||
break;
|
|
||||||
//DevCon.WriteLn("WaitVU()");
|
|
||||||
//pxAssert(THREAD_VU1);
|
|
||||||
KickStart();
|
|
||||||
std::this_thread::yield(); // Give a chance to the MTVU thread to actually start
|
|
||||||
ScopedLock lock(mtxBusy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VU_Thread::ExecuteVU(u32 vu_addr, u32 vif_top, u32 vif_itop, u32 fbrst)
|
void VU_Thread::ExecuteVU(u32 vu_addr, u32 vif_top, u32 vif_itop, u32 fbrst)
|
||||||
|
|
|
@ -31,13 +31,11 @@ class VU_Thread : public pxThread {
|
||||||
|
|
||||||
u32 buffer[buffer_size];
|
u32 buffer[buffer_size];
|
||||||
// Note: keep atomic on separate cache line to avoid CPU conflict
|
// Note: keep atomic on separate cache line to avoid CPU conflict
|
||||||
alignas(64) std::atomic<bool> isBusy; // Is thread processing data?
|
|
||||||
alignas(64) std::atomic<int> m_ato_read_pos; // Only modified by VU thread
|
alignas(64) std::atomic<int> m_ato_read_pos; // Only modified by VU thread
|
||||||
alignas(64) std::atomic<int> m_ato_write_pos; // Only modified by EE thread
|
alignas(64) std::atomic<int> m_ato_write_pos; // Only modified by EE thread
|
||||||
alignas(64) int m_read_pos; // temporary read pos (local to the VU thread)
|
alignas(64) int m_read_pos; // temporary read pos (local to the VU thread)
|
||||||
int m_write_pos; // temporary write pos (local to the EE thread)
|
int m_write_pos; // temporary write pos (local to the EE thread)
|
||||||
Mutex mtxBusy;
|
WorkSema semaEvent;
|
||||||
Semaphore semaEvent;
|
|
||||||
BaseVUmicroCPU*& vuCPU;
|
BaseVUmicroCPU*& vuCPU;
|
||||||
VURegs& vuRegs;
|
VURegs& vuRegs;
|
||||||
|
|
||||||
|
@ -67,7 +65,7 @@ public:
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
// Get MTVU to start processing its packets if it isn't already
|
// Get MTVU to start processing its packets if it isn't already
|
||||||
void KickStart(bool forceKick = false);
|
void KickStart();
|
||||||
|
|
||||||
// Used for assertions...
|
// Used for assertions...
|
||||||
bool IsDone();
|
bool IsDone();
|
||||||
|
|
Loading…
Reference in New Issue