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.SetFloatValue("Main", "RewindFrequency", 10.0f);
si.SetIntValue("Main", "RewindSaveSlots", 10);
si.SetBoolValue("Main", "RunaheadEnable", false);
si.SetFloatValue("Main", "RunaheadFrames", 1);
si.SetFloatValue("Main", "RunaheadFrameCount", 0);
si.SetStringValue("CPU", "ExecutionMode", Settings::GetCPUExecutionModeName(Settings::DEFAULT_CPU_EXECUTION_MODE));
si.SetBoolValue("CPU", "RecompilerMemoryExceptions", false);
@ -666,7 +665,7 @@ void HostInterface::FixIncompatibleSettings(bool display_osd_messages)
#endif
// 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)
{
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
if (g_settings.runahead_enable && g_settings.IsUsingCodeCache())
if (g_settings.IsRunaheadEnabled() && g_settings.IsUsingCodeCache())
{
Log_WarningPrintf("Code cache/recompiler disabled due to runahead");
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");
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_end_offset != old_settings.display_line_end_offset ||
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())
CPU::CodeCache::Reinitialize();
@ -830,7 +829,6 @@ void HostInterface::CheckForSettingsChanges(const Settings& old_settings)
if (g_settings.rewind_enable != old_settings.rewind_enable ||
g_settings.rewind_save_frequency != old_settings.rewind_save_frequency ||
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)
{
System::UpdateMemorySaveStateSettings();

View File

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

View File

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

View File

@ -1977,7 +1977,7 @@ void UpdateMemorySaveStateSettings()
s_rewind_load_frequency = -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;
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",
10.0f);
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", "RunaheadFrames", 1);
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.runaheadFrames, "Main", "RunaheadFrameCount", 0);
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed);
const int emulation_speed_index =
@ -43,12 +42,13 @@ EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface
connect(m_ui.turboSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&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,
&EmulationSettingsWidget::updateRewindSummaryLabel);
&EmulationSettingsWidget::updateRewind);
connect(m_ui.rewindSaveSlots, QOverload<int>::of(&QSpinBox::valueChanged), this,
&EmulationSettingsWidget::updateRewindSummaryLabel);
connect(m_ui.runaheadEnable, &QCheckBox::stateChanged, this, &EmulationSettingsWidget::updateRunaheadFields);
&EmulationSettingsWidget::updateRewind);
connect(m_ui.runaheadFrames, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&EmulationSettingsWidget::updateRewind);
dialog->registerWidgetHelp(
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 "
"should disable this option."));
updateRewindSummaryLabel();
updateRunaheadFields();
updateRewind();
}
EmulationSettingsWidget::~EmulationSettingsWidget() = default;
@ -99,8 +98,10 @@ void EmulationSettingsWidget::onTurboSpeedIndexChanged(int index)
m_host_interface->applySettings();
}
void EmulationSettingsWidget::updateRewindSummaryLabel()
void EmulationSettingsWidget::updateRewind()
{
m_ui.rewindEnable->setEnabled(!runaheadEnabled());
if (m_ui.rewindEnable->isEnabled() && m_ui.rewindEnable->isChecked())
{
const u32 frames = static_cast<u32>(m_ui.rewindSaveSlots->value());
@ -124,7 +125,8 @@ void EmulationSettingsWidget::updateRewindSummaryLabel()
{
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
{
@ -135,10 +137,3 @@ void EmulationSettingsWidget::updateRewindSummaryLabel()
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 onFastForwardSpeedIndexChanged(int index);
void onTurboSpeedIndexChanged(int index);
void updateRewindSummaryLabel();
void updateRunaheadFields();
void updateRewind();
private:
bool runaheadEnabled() { return m_ui.runaheadFrames->currentIndex() > 0; }
Ui::EmulationSettingsWidget m_ui;

View File

@ -75,7 +75,7 @@
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Rewind</string>
<string>Rewind/Runahead</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0" colspan="2">
@ -125,7 +125,73 @@
</property>
</widget>
</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">
<property name="text">
<string>TextLabel</string>
@ -138,42 +204,6 @@
</layout>
</widget>
</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>
<spacer name="verticalSpacer">
<property name="orientation">