From 7597ac12b6093a75170ab017d6678a820e7f964c Mon Sep 17 00:00:00 2001 From: Gauvain 'GovanifY' Roussel-Tarbouriech Date: Sun, 20 Jun 2021 04:00:57 +0200 Subject: [PATCH] gs: ensure the panel doesn't open at all when unneeded --- pcsx2/MTGS.cpp | 7 +++++-- pcsx2/gui/MainMenuClicks.cpp | 31 ++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index 992c1fd5a7..72391a52e0 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -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() diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index 35b2774855..20f3522c27 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -51,6 +51,8 @@ using namespace Dialogs; +extern std::atomic_bool init_gspanel; + void MainEmuFrame::Menu_SysSettings_Click(wxCommandEvent& event) { AppOpenDialog(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(); }