mirror of https://github.com/PCSX2/pcsx2.git
mtgs: fix threading woes
This commit is contained in:
parent
c73769607e
commit
db80ff5477
|
@ -595,14 +595,13 @@ void SysMtgsThread::CloseGS()
|
||||||
if (!m_Opened || GSDump::isRunning)
|
if (!m_Opened || GSDump::isRunning)
|
||||||
return;
|
return;
|
||||||
m_Opened = false;
|
m_Opened = false;
|
||||||
Suspend();
|
GSclose();
|
||||||
sApp.CloseGsPanel();
|
sApp.CloseGsPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysMtgsThread::OnSuspendInThread()
|
void SysMtgsThread::OnSuspendInThread()
|
||||||
{
|
{
|
||||||
GSclose();
|
CloseGS();
|
||||||
GetSysExecutorThread().PostEvent(new SysExecEvent_InvokeMtgsThreadMethod(&SysMtgsThread::CloseGS));
|
|
||||||
_parent::OnSuspendInThread();
|
_parent::OnSuspendInThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,7 +615,7 @@ void SysMtgsThread::OnResumeInThread(bool isSuspended)
|
||||||
|
|
||||||
void SysMtgsThread::OnCleanupInThread()
|
void SysMtgsThread::OnCleanupInThread()
|
||||||
{
|
{
|
||||||
GetSysExecutorThread().PostEvent(new SysExecEvent_InvokeMtgsThreadMethod(&SysMtgsThread::CloseGS));
|
CloseGS();
|
||||||
_parent::OnCleanupInThread();
|
_parent::OnCleanupInThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -925,8 +924,9 @@ void SysMtgsThread::WaitForOpen()
|
||||||
|
|
||||||
void SysMtgsThread::Freeze(int mode, MTGS_FreezeData& data)
|
void SysMtgsThread::Freeze(int mode, MTGS_FreezeData& data)
|
||||||
{
|
{
|
||||||
Resume();
|
pxAssertDev(!IsSelf(), "This method is only allowed from threads *not* named MTGS.");
|
||||||
SendPointerPacket(GS_RINGTYPE_FREEZE, mode, &data);
|
SendPointerPacket(GS_RINGTYPE_FREEZE, mode, &data);
|
||||||
|
// make sure MTGS is processing the packet we send it
|
||||||
Resume();
|
Resume();
|
||||||
// we are forced to wait for the semaphore to be released, otherwise
|
// we are forced to wait for the semaphore to be released, otherwise
|
||||||
// we'll end up in a state where the main thread is stuck on WaitGS
|
// we'll end up in a state where the main thread is stuck on WaitGS
|
||||||
|
|
|
@ -400,6 +400,7 @@ namespace Implementations
|
||||||
return;
|
return;
|
||||||
if (renderswitch_delay == 0)
|
if (renderswitch_delay == 0)
|
||||||
{
|
{
|
||||||
|
ScopedCoreThreadPause paused_core;
|
||||||
freezeData fP = {0, nullptr};
|
freezeData fP = {0, nullptr};
|
||||||
MTGS_FreezeData sstate = {&fP, 0};
|
MTGS_FreezeData sstate = {&fP, 0};
|
||||||
GetMTGS().Freeze(FREEZE_SIZE, sstate);
|
GetMTGS().Freeze(FREEZE_SIZE, sstate);
|
||||||
|
@ -410,6 +411,7 @@ namespace Implementations
|
||||||
GetMTGS().Freeze(FREEZE_LOAD, sstate);
|
GetMTGS().Freeze(FREEZE_LOAD, sstate);
|
||||||
delete[] fP.data;
|
delete[] fP.data;
|
||||||
renderswitch_delay = -1;
|
renderswitch_delay = -1;
|
||||||
|
paused_core.AllowResume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,10 @@ struct SysState_Component
|
||||||
|
|
||||||
int SysState_MTGSFreeze(int mode, freezeData* fP)
|
int SysState_MTGSFreeze(int mode, freezeData* fP)
|
||||||
{
|
{
|
||||||
|
ScopedCoreThreadPause paused_core;
|
||||||
MTGS_FreezeData sstate = {fP, 0};
|
MTGS_FreezeData sstate = {fP, 0};
|
||||||
GetMTGS().Freeze(mode, sstate);
|
GetMTGS().Freeze(mode, sstate);
|
||||||
|
paused_core.AllowResume();
|
||||||
return sstate.retval;
|
return sstate.retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue