From 957ec1d3d31ad66e1bdee80ea325470ff6aa4243 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 26 Jan 2023 01:13:55 +1000 Subject: [PATCH] VTLB: Add option to pause on TLB miss Rather than making it contingent on dev builds. --- pcsx2-qt/Settings/AdvancedSettingsWidget.cpp | 6 ++++++ pcsx2-qt/Settings/AdvancedSettingsWidget.ui | 7 +++++++ pcsx2/Config.h | 2 ++ pcsx2/Pcsx2Config.cpp | 2 ++ pcsx2/vtlb.cpp | 6 +++--- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/pcsx2-qt/Settings/AdvancedSettingsWidget.cpp b/pcsx2-qt/Settings/AdvancedSettingsWidget.cpp index 4e511d1154..c1b54f6519 100644 --- a/pcsx2-qt/Settings/AdvancedSettingsWidget.cpp +++ b/pcsx2-qt/Settings/AdvancedSettingsWidget.cpp @@ -37,6 +37,7 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(SettingsDialog* dialog, QWidget* SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.eeINTCSpinDetection, "EmuCore/Speedhacks", "IntcStat", true); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.eeWaitLoopDetection, "EmuCore/Speedhacks", "WaitLoop", true); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.eeFastmem, "EmuCore/CPU/Recompiler", "EnableFastmem", true); + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.pauseOnTLBMiss, "EmuCore/CPU/Recompiler", "PauseOnTLBMiss", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu0Recompiler, "EmuCore/CPU/Recompiler", "EnableVU0", true); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu1Recompiler, "EmuCore/CPU/Recompiler", "EnableVU1", true); @@ -84,6 +85,11 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(SettingsDialog* dialog, QWidget* dialog->registerWidgetHelp(m_ui.eeFastmem, tr("Enable Fast Memory Access"), tr("Checked"), tr("Uses backpatching to avoid register flushing on every memory access.")); + dialog->registerWidgetHelp(m_ui.pauseOnTLBMiss, tr("Pause On TLB Miss"), tr("Unchecked"), + tr("Pauses the virtual machine when a TLB miss occurs, instead of ignoring it and continuing. Note the the VM will pause after the " + "end of the block, not on the instruction which caused the exception. Refer to the console to see the address where the invalid " + "access occurred.")); + dialog->registerWidgetHelp(m_ui.vu0RoundingMode, tr("Rounding Mode"), tr("Chop / Zero (Default)"), tr("")); dialog->registerWidgetHelp(m_ui.vu1RoundingMode, tr("Rounding Mode"), tr("Chop / Zero (Default)"), tr("")); diff --git a/pcsx2-qt/Settings/AdvancedSettingsWidget.ui b/pcsx2-qt/Settings/AdvancedSettingsWidget.ui index 08ea3001d8..e1c46c39b5 100644 --- a/pcsx2-qt/Settings/AdvancedSettingsWidget.ui +++ b/pcsx2-qt/Settings/AdvancedSettingsWidget.ui @@ -165,6 +165,13 @@ + + + + Pause On TLB Miss + + + diff --git a/pcsx2/Config.h b/pcsx2/Config.h index d4a1caca32..9d010785f6 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -537,6 +537,8 @@ struct Pcsx2Config EnableEECache : 1; bool EnableFastmem : 1; + bool + PauseOnTLBMiss : 1; BITFIELD_END RecompilerOptions(); diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index 9f2e74a8e3..0b3794e076 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -209,6 +209,7 @@ Pcsx2Config::RecompilerOptions::RecompilerOptions() EnableVU0 = true; EnableVU1 = true; EnableFastmem = true; + PauseOnTLBMiss = false; // vu and fpu clamping default to standard overflow. vu0Overflow = true; @@ -286,6 +287,7 @@ void Pcsx2Config::RecompilerOptions::LoadSave(SettingsWrapper& wrap) SettingsWrapBitBool(EnableVU0); SettingsWrapBitBool(EnableVU1); SettingsWrapBitBool(EnableFastmem); + SettingsWrapBitBool(PauseOnTLBMiss); SettingsWrapBitBool(vu0Overflow); SettingsWrapBitBool(vu0ExtraOverflow); diff --git a/pcsx2/vtlb.cpp b/pcsx2/vtlb.cpp index 21ebdef61c..2a9bfe7d49 100644 --- a/pcsx2/vtlb.cpp +++ b/pcsx2/vtlb.cpp @@ -467,7 +467,7 @@ static __ri void vtlb_Miss(u32 addr, u32 mode) } const std::string message(fmt::format("TLB Miss, addr=0x{:x} [{}]", addr, mode ? "store" : "load")); - if constexpr (IsDevBuild) + if (EmuConfig.Cpu.Recompiler.PauseOnTLBMiss) { // Pause, let the user try to figure out what went wrong in the debugger. Host::ReportErrorAsync("R5900 Exception", message); @@ -477,7 +477,7 @@ static __ri void vtlb_Miss(u32 addr, u32 mode) } static int spamStop = 0; - if (spamStop++ < 50) + if (spamStop++ < 50 || IsDevBuild) Console.Error(message); } @@ -487,7 +487,7 @@ static __ri void vtlb_Miss(u32 addr, u32 mode) static __ri void vtlb_BusError(u32 addr, u32 mode) { const std::string message(fmt::format("Bus Error, addr=0x{:x} [{}]", addr, mode ? "store" : "load")); - if constexpr (IsDevBuild) + if (EmuConfig.Cpu.Recompiler.PauseOnTLBMiss) { // Pause, let the user try to figure out what went wrong in the debugger. Host::ReportErrorAsync("R5900 Exception", message);