gs: ensure the panel doesn't open at all when unneeded

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2021-06-20 04:00:57 +02:00 committed by Kojin
parent b06468e268
commit 7597ac12b6
2 changed files with 25 additions and 13 deletions

View File

@ -52,6 +52,7 @@ using namespace Threading;
__aligned(32) MTGS_BufferedData RingBuffer;
extern bool renderswitch;
std::atomic_bool init_gspanel = true;
#ifdef RINGBUF_DEBUG_STACK
@ -242,7 +243,8 @@ void SysMtgsThread::OpenGS()
if (m_Opened)
return;
sApp.OpenGsPanel();
if (init_gspanel)
sApp.OpenGsPanel();
memcpy(RingBuffer.Regs, PS2MEM_GS, sizeof(PS2MEM_GS));
GSsetBaseMem(RingBuffer.Regs);
@ -596,7 +598,8 @@ void SysMtgsThread::CloseGS()
return;
m_Opened = false;
GSclose();
sApp.CloseGsPanel();
if (init_gspanel)
sApp.CloseGsPanel();
}
void SysMtgsThread::OnSuspendInThread()

View File

@ -51,6 +51,8 @@
using namespace Dialogs;
extern std::atomic_bool init_gspanel;
void MainEmuFrame::Menu_SysSettings_Click(wxCommandEvent& event)
{
AppOpenDialog<SysConfigDialog>(this);
@ -91,20 +93,27 @@ void MainEmuFrame::Menu_PADSettings_Click(wxCommandEvent& event)
void MainEmuFrame::Menu_GSSettings_Click(wxCommandEvent& event)
{
ScopedCoreThreadPause paused_core;
bool is_frame_closed = (wxGetApp().GetGsFramePtr() == nullptr);
if (!is_frame_closed)
is_frame_closed = !wxGetApp().GetGsFramePtr()->IsShown();
bool is_frame_init = !(wxGetApp().GetGsFramePtr() == nullptr);
bool need_shutdown = GetMTGS().IsClosed();
init_gspanel = false;
freezeData fP = {0, nullptr};
MTGS_FreezeData sstate = {&fP, 0};
GetMTGS().Freeze(FREEZE_SIZE, sstate);
fP.data = new char[fP.size];
GetMTGS().Freeze(FREEZE_SAVE, sstate);
GetMTGS().Suspend(true);
if (is_frame_init)
{
GetMTGS().Freeze(FREEZE_SIZE, sstate);
fP.data = new char[fP.size];
GetMTGS().Freeze(FREEZE_SAVE, sstate);
GetMTGS().Suspend(true);
}
GSconfigure();
GetMTGS().Freeze(FREEZE_LOAD, sstate);
delete[] fP.data;
if (is_frame_closed)
wxGetApp().GetGsFramePtr()->Hide();
if (is_frame_init)
{
GetMTGS().Freeze(FREEZE_LOAD, sstate);
delete[] fP.data;
}
if (need_shutdown)
GetMTGS().Suspend(true);
init_gspanel = true;
paused_core.AllowResume();
}