From c004e9ca9dd010116f2e8275c6f0b3bbb3460aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 13 Nov 2021 22:10:37 +0100 Subject: [PATCH 1/3] Windows debugger: Load the dialogs on demand. I think this is especially good for the Ge dialog since we now can avoid initializing that extra GL context unless you open the dialog. --- Windows/Debugger/Debugger_Disasm.cpp | 3 ++- Windows/Debugger/Debugger_Lists.cpp | 3 +++ Windows/MainWindow.cpp | 33 ++++++++++++++++++---------- Windows/MainWindow.h | 5 +++-- Windows/MainWindowMenu.cpp | 3 +++ Windows/main.cpp | 5 ++++- 6 files changed, 36 insertions(+), 16 deletions(-) diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 833a9dbe0d00..5c4f0a13ad89 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -899,7 +899,8 @@ void CDisasm::UpdateDialog(bool _bComplete) _snwprintf(tempTicks, 24, L"%lld", CoreTiming::GetTicks() - lastTicks); SetDlgItemText(m_hDlg, IDC_DEBUG_COUNT, tempTicks); } - // Update Register Dialog + + // Update memory window if (memoryWindow) memoryWindow->Update(); diff --git a/Windows/Debugger/Debugger_Lists.cpp b/Windows/Debugger/Debugger_Lists.cpp index 9c90d6d0f2ef..b60ed587d172 100644 --- a/Windows/Debugger/Debugger_Lists.cpp +++ b/Windows/Debugger/Debugger_Lists.cpp @@ -6,6 +6,7 @@ #include "Windows/Debugger/DebuggerShared.h" #include "Windows/Debugger/CtrlDisAsmView.h" #include "Windows/W32Util/ContextMenu.h" +#include "Windows/MainWindow.h" #include "Windows/resource.h" #include "Windows/main.h" #include "Common/Data/Encoding/Utf8.h" @@ -373,10 +374,12 @@ void CtrlBreakpointList::gotoBreakpointAddress(int itemIndex) if (isMemory) { u32 address = displayedMemChecks_[index].start; + MainWindow::CreateMemoryWindow(); if (memoryWindow) memoryWindow->Goto(address); } else { u32 address = displayedBreakPoints_[index].addr; + MainWindow::CreateDisasmWindow(); if (disasmWindow) disasmWindow->Goto(address); } diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index e583846e6c97..22998cc37627 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -533,36 +533,46 @@ namespace MainWindow return TRUE; } - void CreateDebugWindows() { - disasmWindow = new CDisasm(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS); - DialogManager::AddDlg(disasmWindow); - disasmWindow->Show(g_Config.bShowDebuggerOnLoad, false); + void CreateDisasmWindow() { + if (!disasmWindow) { + disasmWindow = new CDisasm(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS); + DialogManager::AddDlg(disasmWindow); + } + } + void CreateGeDebuggerWindow() { + if (!geDebuggerWindow) { #if PPSSPP_API(ANY_GL) - geDebuggerWindow = new CGEDebugger(MainWindow::GetHInstance(), MainWindow::GetHWND()); - DialogManager::AddDlg(geDebuggerWindow); + geDebuggerWindow = new CGEDebugger(MainWindow::GetHInstance(), MainWindow::GetHWND()); + DialogManager::AddDlg(geDebuggerWindow); #endif - memoryWindow = new CMemoryDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS); - DialogManager::AddDlg(memoryWindow); + } + } + + void CreateMemoryWindow() { + if (!memoryWindow) { + memoryWindow = new CMemoryDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS); + DialogManager::AddDlg(memoryWindow); + } } void DestroyDebugWindows() { DialogManager::RemoveDlg(disasmWindow); if (disasmWindow) delete disasmWindow; - disasmWindow = 0; + disasmWindow = nullptr; #if PPSSPP_API(ANY_GL) DialogManager::RemoveDlg(geDebuggerWindow); if (geDebuggerWindow) delete geDebuggerWindow; - geDebuggerWindow = 0; + geDebuggerWindow = nullptr; #endif DialogManager::RemoveDlg(memoryWindow); if (memoryWindow) delete memoryWindow; - memoryWindow = 0; + memoryWindow = nullptr; } LRESULT CALLBACK DisplayProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -928,7 +938,6 @@ namespace MainWindow disasmWindow->NotifyMapLoaded(); if (memoryWindow) memoryWindow->NotifyMapLoaded(); - if (disasmWindow) disasmWindow->UpdateDialog(); break; diff --git a/Windows/MainWindow.h b/Windows/MainWindow.h index 23ee0a269601..0792222d89e6 100644 --- a/Windows/MainWindow.h +++ b/Windows/MainWindow.h @@ -61,9 +61,10 @@ namespace MainWindow void Init(HINSTANCE hInstance); BOOL Show(HINSTANCE hInstance); - void CreateDebugWindows(); + void CreateDisasmWindow(); + void CreateGeDebuggerWindow(); + void CreateMemoryWindow(); void DestroyDebugWindows(); - void Close(); void UpdateMenus(bool isMenuSelect = false); void UpdateCommands(); void UpdateSwitchUMD(); diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index acda99fdbb50..66e69787b308 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -896,18 +896,21 @@ namespace MainWindow { break; case ID_DEBUG_DISASSEMBLY: + CreateDisasmWindow(); if (disasmWindow) disasmWindow->Show(true); break; case ID_DEBUG_GEDEBUGGER: #if PPSSPP_API(ANY_GL) + CreateGeDebuggerWindow(); if (geDebuggerWindow) geDebuggerWindow->Show(true); #endif break; case ID_DEBUG_MEMORYVIEW: + CreateMemoryWindow(); if (memoryWindow) memoryWindow->Show(true); break; diff --git a/Windows/main.cpp b/Windows/main.cpp index 59ee239d7d39..fab160b037e0 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -686,7 +686,10 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin #endif DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS)); - MainWindow::CreateDebugWindows(); + if (g_Config.bShowDebuggerOnLoad) { + MainWindow::CreateDisasmWindow(); + disasmWindow->Show(g_Config.bShowDebuggerOnLoad, false); + } const bool minimized = iCmdShow == SW_MINIMIZE || iCmdShow == SW_SHOWMINIMIZED || iCmdShow == SW_SHOWMINNOACTIVE; if (minimized) { From fc26beca4b88c57239ba220f1b2b4c547df61d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 13 Nov 2021 22:24:30 +0100 Subject: [PATCH 2/3] Also delay-load the VFPU dialog, just because --- Windows/Debugger/Debugger_Disasm.cpp | 1 + Windows/Debugger/Debugger_VFPUDlg.cpp | 2 -- Windows/Debugger/Debugger_VFPUDlg.h | 3 --- Windows/MainWindow.cpp | 12 ++++++++++++ Windows/MainWindow.h | 1 + Windows/W32Util/DialogManager.cpp | 3 +++ Windows/main.cpp | 2 +- Windows/main.h | 4 ++++ 8 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 5c4f0a13ad89..8e9c147e7e04 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -466,6 +466,7 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) break; case IDC_SHOWVFPU: + MainWindow::CreateVFPUWindow(); vfpudlg->Show(true); break; diff --git a/Windows/Debugger/Debugger_VFPUDlg.cpp b/Windows/Debugger/Debugger_VFPUDlg.cpp index 5075e617316c..1a6bc4385200 100644 --- a/Windows/Debugger/Debugger_VFPUDlg.cpp +++ b/Windows/Debugger/Debugger_VFPUDlg.cpp @@ -13,8 +13,6 @@ #include "Core/MIPS/MIPS.h" // BAD -CVFPUDlg *vfpudlg; - CVFPUDlg::CVFPUDlg(HINSTANCE _hInstance, HWND _hParent, DebugInterface *cpu_) : Dialog((LPCSTR)IDD_VFPU, _hInstance,_hParent) { cpu = cpu_; diff --git a/Windows/Debugger/Debugger_VFPUDlg.h b/Windows/Debugger/Debugger_VFPUDlg.h index 9c3c4deede0e..0e5763dcfc22 100644 --- a/Windows/Debugger/Debugger_VFPUDlg.h +++ b/Windows/Debugger/Debugger_VFPUDlg.h @@ -20,6 +20,3 @@ class CVFPUDlg : public Dialog { int mode; BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; - - -extern CVFPUDlg *vfpudlg; diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 22998cc37627..12ba10517b35 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -556,6 +556,13 @@ namespace MainWindow } } + void CreateVFPUWindow() { + if (!vfpudlg) { + vfpudlg = new CVFPUDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS); + DialogManager::AddDlg(vfpudlg); + } + } + void DestroyDebugWindows() { DialogManager::RemoveDlg(disasmWindow); if (disasmWindow) @@ -573,6 +580,11 @@ namespace MainWindow if (memoryWindow) delete memoryWindow; memoryWindow = nullptr; + + DialogManager::RemoveDlg(vfpudlg); + if (vfpudlg) + delete vfpudlg; + vfpudlg = nullptr; } LRESULT CALLBACK DisplayProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { diff --git a/Windows/MainWindow.h b/Windows/MainWindow.h index 0792222d89e6..d3e3aa8d13b3 100644 --- a/Windows/MainWindow.h +++ b/Windows/MainWindow.h @@ -64,6 +64,7 @@ namespace MainWindow void CreateDisasmWindow(); void CreateGeDebuggerWindow(); void CreateMemoryWindow(); + void CreateVFPUWindow(); void DestroyDebugWindows(); void UpdateMenus(bool isMenuSelect = false); void UpdateCommands(); diff --git a/Windows/W32Util/DialogManager.cpp b/Windows/W32Util/DialogManager.cpp index df131d9db4e7..ee5526f45bb1 100644 --- a/Windows/W32Util/DialogManager.cpp +++ b/Windows/W32Util/DialogManager.cpp @@ -76,6 +76,9 @@ void DialogManager::AddDlg(Dialog *dialog) void DialogManager::RemoveDlg(Dialog *dialog) { + if (!dialog) { + return; + } dialogs.erase(std::remove(dialogs.begin(), dialogs.end(), dialog), dialogs.end()); } diff --git a/Windows/main.cpp b/Windows/main.cpp index fab160b037e0..6b0f2d10983d 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -95,6 +95,7 @@ CGEDebugger* geDebuggerWindow = nullptr; CDisasm *disasmWindow = nullptr; CMemoryDlg *memoryWindow = nullptr; +CVFPUDlg *vfpudlg = nullptr; static std::string langRegion; static std::string osName; @@ -684,7 +685,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin #if PPSSPP_API(ANY_GL) CGEDebugger::Init(); #endif - DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS)); if (g_Config.bShowDebuggerOnLoad) { MainWindow::CreateDisasmWindow(); diff --git a/Windows/main.h b/Windows/main.h index 890acc845c61..44cdbd621ad9 100644 --- a/Windows/main.h +++ b/Windows/main.h @@ -19,12 +19,16 @@ #pragma once #include "ppsspp_config.h" + #include "Debugger/Debugger_Disasm.h" #include "Debugger/Debugger_MemoryDlg.h" +#include "Debugger/Debugger_VFPUDlg.h" + #include "Common/CommonWindows.h" extern CDisasm *disasmWindow; extern CMemoryDlg *memoryWindow; +extern CVFPUDlg *vfpudlg; #if PPSSPP_API(ANY_GL) #include "Windows/GEDebugger/GEDebugger.h" From 42bc9066eeae5f805ff24377607679930fed1b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 13 Nov 2021 22:47:29 +0100 Subject: [PATCH 3/3] Add shortcut for content_uri and native paths in CleanRecent. Saves 150ms. --- Core/Config.cpp | 23 ++++++++++++++++++++--- Windows/MainWindow.cpp | 4 ++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 8143123e8867..a0267b51bb3b 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -29,6 +29,7 @@ #include "Common/Net/URL.h" #include "Common/Log.h" +#include "Common/TimeUtil.h" #include "Common/Data/Format/IniFile.h" #include "Common/Data/Format/JSONReader.h" #include "Common/Data/Text/I18n.h" @@ -1643,18 +1644,34 @@ void Config::RemoveRecent(const std::string &file) { } void Config::CleanRecent() { + double startTime = time_now_d(); + std::vector cleanedRecent; for (size_t i = 0; i < recentIsos.size(); i++) { - FileLoader *loader = ConstructFileLoader(Path(recentIsos[i])); - if (loader->ExistsFast()) { + bool exists = false; + Path path = Path(recentIsos[i]); + switch (path.Type()) { + case PathType::CONTENT_URI: + case PathType::NATIVE: + exists = File::Exists(path); + break; + default: + FileLoader *loader = ConstructFileLoader(path); + exists = loader->ExistsFast(); + delete loader; + break; + } + + if (exists) { // Make sure we don't have any redundant items. auto duplicate = std::find(cleanedRecent.begin(), cleanedRecent.end(), recentIsos[i]); if (duplicate == cleanedRecent.end()) { cleanedRecent.push_back(recentIsos[i]); } } - delete loader; } + + INFO_LOG(SYSTEM, "CleanRecent took %0.2f", time_now_d() - startTime); recentIsos = cleanedRecent; } diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 12ba10517b35..12dd5e0fb71a 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -541,12 +541,12 @@ namespace MainWindow } void CreateGeDebuggerWindow() { - if (!geDebuggerWindow) { #if PPSSPP_API(ANY_GL) + if (!geDebuggerWindow) { geDebuggerWindow = new CGEDebugger(MainWindow::GetHInstance(), MainWindow::GetHWND()); DialogManager::AddDlg(geDebuggerWindow); -#endif } +#endif } void CreateMemoryWindow() {