Qt: Simplify runahead settings

This commit is contained in:
Connor McLaughlin 2021-01-26 02:48:40 +10:00
parent 1b16ba3d98
commit 16a32bf696
7 changed files with 92 additions and 71 deletions

View File

@ -495,8 +495,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
si.SetBoolValue("Main", "RewindEnable", false); si.SetBoolValue("Main", "RewindEnable", false);
si.SetFloatValue("Main", "RewindFrequency", 10.0f); si.SetFloatValue("Main", "RewindFrequency", 10.0f);
si.SetIntValue("Main", "RewindSaveSlots", 10); si.SetIntValue("Main", "RewindSaveSlots", 10);
si.SetBoolValue("Main", "RunaheadEnable", false); si.SetFloatValue("Main", "RunaheadFrameCount", 0);
si.SetFloatValue("Main", "RunaheadFrames", 1);
si.SetStringValue("CPU", "ExecutionMode", Settings::GetCPUExecutionModeName(Settings::DEFAULT_CPU_EXECUTION_MODE)); si.SetStringValue("CPU", "ExecutionMode", Settings::GetCPUExecutionModeName(Settings::DEFAULT_CPU_EXECUTION_MODE));
si.SetBoolValue("CPU", "RecompilerMemoryExceptions", false); si.SetBoolValue("CPU", "RecompilerMemoryExceptions", false);
@ -666,7 +665,7 @@ void HostInterface::FixIncompatibleSettings(bool display_osd_messages)
#endif #endif
// rewinding causes issues with mmap fastmem, so just use LUT // rewinding causes issues with mmap fastmem, so just use LUT
if ((g_settings.rewind_enable || g_settings.runahead_enable) && g_settings.IsUsingFastmem() && if ((g_settings.rewind_enable || g_settings.IsRunaheadEnabled()) && g_settings.IsUsingFastmem() &&
g_settings.cpu_fastmem_mode == CPUFastmemMode::MMap) g_settings.cpu_fastmem_mode == CPUFastmemMode::MMap)
{ {
Log_WarningPrintf("Disabling mmap fastmem due to rewind being enabled"); Log_WarningPrintf("Disabling mmap fastmem due to rewind being enabled");
@ -674,13 +673,13 @@ void HostInterface::FixIncompatibleSettings(bool display_osd_messages)
} }
// code compilation is too slow with runahead, use the recompiler // code compilation is too slow with runahead, use the recompiler
if (g_settings.runahead_enable && g_settings.IsUsingCodeCache()) if (g_settings.IsRunaheadEnabled() && g_settings.IsUsingCodeCache())
{ {
Log_WarningPrintf("Code cache/recompiler disabled due to runahead"); Log_WarningPrintf("Code cache/recompiler disabled due to runahead");
g_settings.cpu_execution_mode = CPUExecutionMode::Interpreter; g_settings.cpu_execution_mode = CPUExecutionMode::Interpreter;
} }
if (g_settings.runahead_enable && g_settings.rewind_enable) if (g_settings.IsRunaheadEnabled() && g_settings.rewind_enable)
{ {
Log_WarningPrintf("Rewind disabled due to runahead being enabled"); Log_WarningPrintf("Rewind disabled due to runahead being enabled");
g_settings.rewind_enable = false; g_settings.rewind_enable = false;
@ -789,7 +788,7 @@ void HostInterface::CheckForSettingsChanges(const Settings& old_settings)
g_settings.display_line_start_offset != old_settings.display_line_start_offset || g_settings.display_line_start_offset != old_settings.display_line_start_offset ||
g_settings.display_line_end_offset != old_settings.display_line_end_offset || g_settings.display_line_end_offset != old_settings.display_line_end_offset ||
g_settings.rewind_enable != old_settings.rewind_enable || g_settings.rewind_enable != old_settings.rewind_enable ||
g_settings.runahead_enable != old_settings.runahead_enable) g_settings.runahead_frames != old_settings.runahead_frames)
{ {
if (g_settings.IsUsingCodeCache()) if (g_settings.IsUsingCodeCache())
CPU::CodeCache::Reinitialize(); CPU::CodeCache::Reinitialize();
@ -830,7 +829,6 @@ void HostInterface::CheckForSettingsChanges(const Settings& old_settings)
if (g_settings.rewind_enable != old_settings.rewind_enable || if (g_settings.rewind_enable != old_settings.rewind_enable ||
g_settings.rewind_save_frequency != old_settings.rewind_save_frequency || g_settings.rewind_save_frequency != old_settings.rewind_save_frequency ||
g_settings.rewind_save_slots != old_settings.rewind_save_slots || g_settings.rewind_save_slots != old_settings.rewind_save_slots ||
g_settings.runahead_enable != old_settings.runahead_enable ||
g_settings.runahead_frames != old_settings.runahead_frames) g_settings.runahead_frames != old_settings.runahead_frames)
{ {
System::UpdateMemorySaveStateSettings(); System::UpdateMemorySaveStateSettings();

View File

@ -126,8 +126,7 @@ void Settings::Load(SettingsInterface& si)
rewind_enable = si.GetBoolValue("Main", "RewindEnable", false); rewind_enable = si.GetBoolValue("Main", "RewindEnable", false);
rewind_save_frequency = si.GetFloatValue("Main", "RewindFrequency", 10.0f); rewind_save_frequency = si.GetFloatValue("Main", "RewindFrequency", 10.0f);
rewind_save_slots = static_cast<u32>(si.GetIntValue("Main", "RewindSaveSlots", 10)); rewind_save_slots = static_cast<u32>(si.GetIntValue("Main", "RewindSaveSlots", 10));
runahead_enable = si.GetBoolValue("Main", "RunaheadEnable", false); runahead_frames = static_cast<u32>(si.GetIntValue("Main", "RunaheadFrameCount", 0));
runahead_frames = static_cast<u32>(si.GetIntValue("Main", "RunaheadFrames", 1));
cpu_execution_mode = cpu_execution_mode =
ParseCPUExecutionMode( ParseCPUExecutionMode(
@ -303,8 +302,7 @@ void Settings::Save(SettingsInterface& si) const
si.SetBoolValue("Main", "RewindEnable", rewind_enable); si.SetBoolValue("Main", "RewindEnable", rewind_enable);
si.SetFloatValue("Main", "RewindFrequency", rewind_save_frequency); si.SetFloatValue("Main", "RewindFrequency", rewind_save_frequency);
si.SetIntValue("Main", "RewindSaveSlots", rewind_save_slots); si.SetIntValue("Main", "RewindSaveSlots", rewind_save_slots);
si.SetBoolValue("Main", "RunaheadEnable", runahead_enable); si.SetIntValue("Main", "RunaheadFrameCount", runahead_frames);
si.SetIntValue("Main", "RunaheadFrames", runahead_frames);
si.SetStringValue("CPU", "ExecutionMode", GetCPUExecutionModeName(cpu_execution_mode)); si.SetStringValue("CPU", "ExecutionMode", GetCPUExecutionModeName(cpu_execution_mode));
si.SetBoolValue("CPU", "OverclockEnable", cpu_overclock_enable); si.SetBoolValue("CPU", "OverclockEnable", cpu_overclock_enable);

View File

@ -95,10 +95,9 @@ struct Settings
bool disable_all_enhancements = false; bool disable_all_enhancements = false;
bool rewind_enable = false; bool rewind_enable = false;
bool runahead_enable = false;
float rewind_save_frequency = 10.0f; float rewind_save_frequency = 10.0f;
u32 rewind_save_slots = 10; u32 rewind_save_slots = 10;
u32 runahead_frames = 1; u32 runahead_frames = 0;
GPURenderer gpu_renderer = GPURenderer::Software; GPURenderer gpu_renderer = GPURenderer::Software;
std::string gpu_adapter; std::string gpu_adapter;
@ -224,6 +223,7 @@ struct Settings
ALWAYS_INLINE bool IsUsingCodeCache() const { return (cpu_execution_mode != CPUExecutionMode::Interpreter); } ALWAYS_INLINE bool IsUsingCodeCache() const { return (cpu_execution_mode != CPUExecutionMode::Interpreter); }
ALWAYS_INLINE bool IsUsingRecompiler() const { return (cpu_execution_mode == CPUExecutionMode::Recompiler); } ALWAYS_INLINE bool IsUsingRecompiler() const { return (cpu_execution_mode == CPUExecutionMode::Recompiler); }
ALWAYS_INLINE bool IsUsingSoftwareRenderer() const { return (gpu_renderer == GPURenderer::Software); } ALWAYS_INLINE bool IsUsingSoftwareRenderer() const { return (gpu_renderer == GPURenderer::Software); }
ALWAYS_INLINE bool IsRunaheadEnabled() const { return (runahead_frames > 0); }
ALWAYS_INLINE PGXPMode GetPGXPMode() ALWAYS_INLINE PGXPMode GetPGXPMode()
{ {

View File

@ -1977,7 +1977,7 @@ void UpdateMemorySaveStateSettings()
s_rewind_load_frequency = -1; s_rewind_load_frequency = -1;
s_rewind_load_counter = -1; s_rewind_load_counter = -1;
s_runahead_frames = g_settings.runahead_enable ? g_settings.runahead_frames : 0; s_runahead_frames = g_settings.runahead_frames;
s_runahead_replay_pending = false; s_runahead_replay_pending = false;
if (s_runahead_frames > 0) if (s_runahead_frames > 0)
{ {

View File

@ -18,8 +18,7 @@ EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface
SettingWidgetBinder::BindWidgetToFloatSetting(m_host_interface, m_ui.rewindSaveFrequency, "Main", "RewindFrequency", SettingWidgetBinder::BindWidgetToFloatSetting(m_host_interface, m_ui.rewindSaveFrequency, "Main", "RewindFrequency",
10.0f); 10.0f);
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.rewindSaveSlots, "Main", "RewindSaveSlots", 10); SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.rewindSaveSlots, "Main", "RewindSaveSlots", 10);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.runaheadEnable, "Main", "RunaheadEnable", false); SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.runaheadFrames, "Main", "RunaheadFrameCount", 0);
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.runaheadFrames, "Main", "RunaheadFrames", 1);
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed); QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed);
const int emulation_speed_index = const int emulation_speed_index =
@ -43,12 +42,13 @@ EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface
connect(m_ui.turboSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(m_ui.turboSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&EmulationSettingsWidget::onTurboSpeedIndexChanged); &EmulationSettingsWidget::onTurboSpeedIndexChanged);
connect(m_ui.rewindEnable, &QCheckBox::stateChanged, this, &EmulationSettingsWidget::updateRewindSummaryLabel); connect(m_ui.rewindEnable, &QCheckBox::stateChanged, this, &EmulationSettingsWidget::updateRewind);
connect(m_ui.rewindSaveFrequency, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(m_ui.rewindSaveFrequency, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&EmulationSettingsWidget::updateRewindSummaryLabel); &EmulationSettingsWidget::updateRewind);
connect(m_ui.rewindSaveSlots, QOverload<int>::of(&QSpinBox::valueChanged), this, connect(m_ui.rewindSaveSlots, QOverload<int>::of(&QSpinBox::valueChanged), this,
&EmulationSettingsWidget::updateRewindSummaryLabel); &EmulationSettingsWidget::updateRewind);
connect(m_ui.runaheadEnable, &QCheckBox::stateChanged, this, &EmulationSettingsWidget::updateRunaheadFields); connect(m_ui.runaheadFrames, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&EmulationSettingsWidget::updateRewind);
dialog->registerWidgetHelp( dialog->registerWidgetHelp(
m_ui.emulationSpeed, tr("Emulation Speed"), "100%", m_ui.emulationSpeed, tr("Emulation Speed"), "100%",
@ -69,8 +69,7 @@ EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface
"the console's refresh rate is too far from the host's refresh rate. Users with variable refresh rate displays " "the console's refresh rate is too far from the host's refresh rate. Users with variable refresh rate displays "
"should disable this option.")); "should disable this option."));
updateRewindSummaryLabel(); updateRewind();
updateRunaheadFields();
} }
EmulationSettingsWidget::~EmulationSettingsWidget() = default; EmulationSettingsWidget::~EmulationSettingsWidget() = default;
@ -99,8 +98,10 @@ void EmulationSettingsWidget::onTurboSpeedIndexChanged(int index)
m_host_interface->applySettings(); m_host_interface->applySettings();
} }
void EmulationSettingsWidget::updateRewindSummaryLabel() void EmulationSettingsWidget::updateRewind()
{ {
m_ui.rewindEnable->setEnabled(!runaheadEnabled());
if (m_ui.rewindEnable->isEnabled() && m_ui.rewindEnable->isChecked()) if (m_ui.rewindEnable->isEnabled() && m_ui.rewindEnable->isChecked())
{ {
const u32 frames = static_cast<u32>(m_ui.rewindSaveSlots->value()); const u32 frames = static_cast<u32>(m_ui.rewindSaveSlots->value());
@ -124,7 +125,8 @@ void EmulationSettingsWidget::updateRewindSummaryLabel()
{ {
if (!m_ui.rewindEnable->isEnabled()) if (!m_ui.rewindEnable->isEnabled())
{ {
m_ui.rewindSummary->setText(tr("Rewind is disabled because runahead is enabled.")); m_ui.rewindSummary->setText(tr(
"Rewind is disabled because runahead is enabled. Runahead will significantly increase system requirements."));
} }
else else
{ {
@ -135,10 +137,3 @@ void EmulationSettingsWidget::updateRewindSummaryLabel()
m_ui.rewindSaveSlots->setEnabled(false); m_ui.rewindSaveSlots->setEnabled(false);
} }
} }
void EmulationSettingsWidget::updateRunaheadFields()
{
m_ui.runaheadFrames->setEnabled(m_ui.runaheadEnable->isChecked());
m_ui.rewindEnable->setEnabled(!m_ui.runaheadEnable->isChecked());
updateRewindSummaryLabel();
}

View File

@ -19,10 +19,10 @@ private Q_SLOTS:
void onEmulationSpeedIndexChanged(int index); void onEmulationSpeedIndexChanged(int index);
void onFastForwardSpeedIndexChanged(int index); void onFastForwardSpeedIndexChanged(int index);
void onTurboSpeedIndexChanged(int index); void onTurboSpeedIndexChanged(int index);
void updateRewindSummaryLabel(); void updateRewind();
void updateRunaheadFields();
private: private:
bool runaheadEnabled() { return m_ui.runaheadFrames->currentIndex() > 0; }
Ui::EmulationSettingsWidget m_ui; Ui::EmulationSettingsWidget m_ui;

View File

@ -75,7 +75,7 @@
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>Rewind</string> <string>Rewind/Runahead</string>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
@ -125,7 +125,73 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Runahead:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="runaheadFrames">
<item>
<property name="text">
<string>Disabled</string>
</property>
</item>
<item>
<property name="text">
<string>1 Frame</string>
</property>
</item>
<item>
<property name="text">
<string>2 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>3 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>4 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>5 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>6 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>7 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>8 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>9 Frames</string>
</property>
</item>
<item>
<property name="text">
<string>10 Frames</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="rewindSummary"> <widget class="QLabel" name="rewindSummary">
<property name="text"> <property name="text">
<string>TextLabel</string> <string>TextLabel</string>
@ -138,42 +204,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Runahead</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="runaheadEnable">
<property name="text">
<string>Enable Runahead</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Runahead Frames:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="runaheadFrames">
<property name="suffix">
<string> Frames</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">