Skip to content

Commit e6788b3

Browse files
committed
System: Add 'Runahead for Analog Input' option
Mitigates the performance impact of serializing PGXP state.
1 parent cf0b602 commit e6788b3

15 files changed

+94
-59
lines changed

src/core/analog_controller.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ void AnalogController::SetBindState(u32 index, float value)
262262
}
263263

264264
if (std::memcmp(m_axis_state.data(), prev_axis_state.data(), m_axis_state.size()) != 0)
265-
System::SetRunaheadReplayFlag();
265+
System::SetRunaheadReplayFlag(true);
266266

267267
#undef MERGE
268268

@@ -274,14 +274,14 @@ void AnalogController::SetBindState(u32 index, float value)
274274
if (value >= m_button_deadzone)
275275
{
276276
if (m_button_state & bit)
277-
System::SetRunaheadReplayFlag();
277+
System::SetRunaheadReplayFlag(false);
278278

279279
m_button_state &= ~(bit);
280280
}
281281
else
282282
{
283283
if (!(m_button_state & bit))
284-
System::SetRunaheadReplayFlag();
284+
System::SetRunaheadReplayFlag(false);
285285

286286
m_button_state |= bit;
287287
}

src/core/analog_joystick.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ void AnalogJoystick::SetBindState(u32 index, float value)
101101
return;
102102

103103
const u8 u8_value = static_cast<u8>(std::clamp(value * m_analog_sensitivity * 255.0f, 0.0f, 255.0f));
104-
if (u8_value != m_half_axis_state[sub_index])
105-
System::SetRunaheadReplayFlag();
104+
if (m_half_axis_state[sub_index] == u8_value)
105+
return;
106106

107107
m_half_axis_state[sub_index] = u8_value;
108108

@@ -181,7 +181,7 @@ void AnalogJoystick::SetBindState(u32 index, float value)
181181
}
182182

183183
if (std::memcmp(m_axis_state.data(), prev_axis_state.data(), m_axis_state.size()) != 0)
184-
System::SetRunaheadReplayFlag();
184+
System::SetRunaheadReplayFlag(true);
185185

186186
#undef MERGE
187187

@@ -193,14 +193,14 @@ void AnalogJoystick::SetBindState(u32 index, float value)
193193
if (value >= 0.5f)
194194
{
195195
if (m_button_state & bit)
196-
System::SetRunaheadReplayFlag();
196+
System::SetRunaheadReplayFlag(false);
197197

198198
m_button_state &= ~(bit);
199199
}
200200
else
201201
{
202202
if (!(m_button_state & bit))
203-
System::SetRunaheadReplayFlag();
203+
System::SetRunaheadReplayFlag(false);
204204

205205
m_button_state |= bit;
206206
}

src/core/ddgo_controller.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ void DDGoController::SetBindState(u32 index, float value)
114114
if (pressed)
115115
{
116116
if (m_button_state & bit)
117-
System::SetRunaheadReplayFlag();
117+
System::SetRunaheadReplayFlag(false);
118118

119119
m_button_state &= ~bit;
120120
}
121121
else
122122
{
123123
if (!(m_button_state & bit))
124-
System::SetRunaheadReplayFlag();
124+
System::SetRunaheadReplayFlag(false);
125125

126126
m_button_state |= bit;
127127
}
@@ -215,7 +215,7 @@ void DDGoController::SetPowerLevel(u32 level)
215215
m_power_level = Truncate8(level);
216216
m_power_transition_frames_remaining = m_power_transition_frames;
217217
UpdatePowerBits();
218-
System::SetRunaheadReplayFlag();
218+
System::SetRunaheadReplayFlag(false);
219219
}
220220

221221
void DDGoController::UpdatePowerBits()
@@ -251,7 +251,7 @@ void DDGoController::SetBrakeLevel(u32 level)
251251
m_brake_level = Truncate8(level);
252252
m_brake_transition_frames_remaining = m_brake_transition_frames;
253253
UpdateBrakeBits();
254-
System::SetRunaheadReplayFlag();
254+
System::SetRunaheadReplayFlag(false);
255255
}
256256

257257
void DDGoController::UpdateBrakeBits()

src/core/digital_controller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ void DigitalController::SetBindState(u32 index, float value)
6464
if (pressed)
6565
{
6666
if (m_button_state & bit)
67-
System::SetRunaheadReplayFlag();
67+
System::SetRunaheadReplayFlag(false);
6868

6969
m_button_state &= ~bit;
7070
}
7171
else
7272
{
7373
if (!(m_button_state & bit))
74-
System::SetRunaheadReplayFlag();
74+
System::SetRunaheadReplayFlag(false);
7575

7676
m_button_state |= bit;
7777
}

src/core/fullscreen_ui.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4662,6 +4662,11 @@ void FullscreenUI::DrawEmulationSettingsPage()
46624662
"high system requirements."),
46634663
"Main", "RunaheadFrameCount", 0, runahead_options);
46644664

4665+
DrawToggleSetting(
4666+
bsi, FSUI_ICONVSTR(ICON_PF_ANALOG_ANY, "Runahead for Analog Input"),
4667+
FSUI_VSTR("Activates runahead when analog input changes, which significantly increases system requirements."),
4668+
"Main", "RunaheadForAnalogInput", false, runahead_enabled);
4669+
46654670
TinyString rewind_summary;
46664671
if (runahead_enabled)
46674672
{
@@ -9559,6 +9564,7 @@ TRANSLATE_NOOP("FullscreenUI", "Achievements");
95599564
TRANSLATE_NOOP("FullscreenUI", "Achievements Settings");
95609565
TRANSLATE_NOOP("FullscreenUI", "Achievements are not enabled.");
95619566
TRANSLATE_NOOP("FullscreenUI", "Achievements: ");
9567+
TRANSLATE_NOOP("FullscreenUI", "Activates runahead when analog input changes, which significantly increases system requirements.");
95629568
TRANSLATE_NOOP("FullscreenUI", "Add Search Directory");
95639569
TRANSLATE_NOOP("FullscreenUI", "Add Shader");
95649570
TRANSLATE_NOOP("FullscreenUI", "Adds a new directory to the game search list.");
@@ -9770,7 +9776,6 @@ TRANSLATE_NOOP("FullscreenUI", "Enable VRAM Write Replacement");
97709776
TRANSLATE_NOOP("FullscreenUI", "Enable XInput Input Source");
97719777
TRANSLATE_NOOP("FullscreenUI", "Enable debugging when supported by the host's renderer API. Only for developer use.");
97729778
TRANSLATE_NOOP("FullscreenUI", "Enable/Disable the Player LED on DualSense controllers.");
9773-
TRANSLATE_NOOP("FullscreenUI", "Enable/Disable using the DualSense controller's Mic Mute LED to indicate when Analog Mode is active.");
97749779
TRANSLATE_NOOP("FullscreenUI", "Enables alignment and bus exceptions. Not needed for any known games.");
97759780
TRANSLATE_NOOP("FullscreenUI", "Enables an additional 6MB of RAM to obtain a total of 2+6 = 8MB, usually present on dev consoles.");
97769781
TRANSLATE_NOOP("FullscreenUI", "Enables an additional three controller slots on each port. Not supported in all games.");
@@ -9941,6 +9946,7 @@ TRANSLATE_NOOP("FullscreenUI", "Mute CD Audio");
99419946
TRANSLATE_NOOP("FullscreenUI", "Navigate");
99429947
TRANSLATE_NOOP("FullscreenUI", "No");
99439948
TRANSLATE_NOOP("FullscreenUI", "No Game Selected");
9949+
TRANSLATE_NOOP("FullscreenUI", "No LED");
99449950
TRANSLATE_NOOP("FullscreenUI", "No Vibration");
99459951
TRANSLATE_NOOP("FullscreenUI", "No cheats are available for this game.");
99469952
TRANSLATE_NOOP("FullscreenUI", "No devices with vibration motors were detected.");
@@ -10056,10 +10062,10 @@ TRANSLATE_NOOP("FullscreenUI", "Right: ");
1005610062
TRANSLATE_NOOP("FullscreenUI", "Round Upscaled Texture Coordinates");
1005710063
TRANSLATE_NOOP("FullscreenUI", "Rounds texture coordinates instead of flooring when upscaling. Can fix misaligned textures in some games, but break others, and is incompatible with texture filtering.");
1005810064
TRANSLATE_NOOP("FullscreenUI", "Runahead");
10065+
TRANSLATE_NOOP("FullscreenUI", "Runahead for Analog Input");
1005910066
TRANSLATE_NOOP("FullscreenUI", "Runahead/Rewind");
1006010067
TRANSLATE_NOOP("FullscreenUI", "Runs the software renderer in parallel for VRAM readbacks. On some systems, this may result in greater performance when using graphical enhancements with the hardware renderer.");
1006110068
TRANSLATE_NOOP("FullscreenUI", "SDL DualSense Player LED");
10062-
TRANSLATE_NOOP("FullscreenUI", "SDL DualSense Mic Mute LED for Analog Mode");
1006310069
TRANSLATE_NOOP("FullscreenUI", "SDL DualShock 4 / DualSense Enhanced Mode");
1006410070
TRANSLATE_NOOP("FullscreenUI", "Safe Mode");
1006510071
TRANSLATE_NOOP("FullscreenUI", "Save Controller Preset");

src/core/imgui_overlays.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ void ImGuiManager::DrawEnhancementsOverlay(const GPUBackend* gpu)
561561
if (g_settings.rewind_enable)
562562
text.append_format(" RW={}/{}", g_settings.rewind_save_frequency, g_settings.rewind_save_slots);
563563
if (g_settings.IsRunaheadEnabled())
564-
text.append_format(" RA={}", g_settings.runahead_frames);
564+
text.append_format(" RA={}{}", g_settings.runahead_frames, g_settings.runahead_for_analog_input ? "+A" : "");
565565

566566
if (g_settings.cpu_overclock_active)
567567
text.append_format(" CPU={}%", g_settings.GetCPUOverclockPercent());

src/core/jogcon.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,22 @@ void JogCon::SetBindState(u32 index, float value)
126126
-static_cast<s8>((static_cast<u32>(m_half_axis_state[static_cast<u32>(HalfAxis::SteeringLeft)]) + 1) / 2);
127127

128128
if (m_steering_state != prev_steering_state)
129-
System::SetRunaheadReplayFlag();
129+
System::SetRunaheadReplayFlag(true);
130130
}
131131

132132
const u16 bit = u16(1) << static_cast<u8>(index);
133133

134134
if (value >= m_button_deadzone)
135135
{
136136
if (m_button_state & bit)
137-
System::SetRunaheadReplayFlag();
137+
System::SetRunaheadReplayFlag(false);
138138

139139
m_button_state &= ~(bit);
140140
}
141141
else
142142
{
143143
if (!(m_button_state & bit))
144-
System::SetRunaheadReplayFlag();
144+
System::SetRunaheadReplayFlag(false);
145145

146146
m_button_state |= bit;
147147
}

src/core/negcon.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ void NeGcon::SetBindState(u32 index, float value)
137137
if (value >= 0.5f)
138138
{
139139
if (m_button_state & bit)
140-
System::SetRunaheadReplayFlag();
140+
System::SetRunaheadReplayFlag(false);
141141

142142
m_button_state &= ~bit;
143143
}
144144
else
145145
{
146146
if (!(m_button_state & bit))
147-
System::SetRunaheadReplayFlag();
147+
System::SetRunaheadReplayFlag(false);
148148

149149
m_button_state |= bit;
150150
}

src/core/negcon_rumble.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,14 @@ void NeGconRumble::SetBindState(u32 index, float value)
194194
if (value >= 0.5f)
195195
{
196196
if (m_button_state & bit)
197-
System::SetRunaheadReplayFlag();
197+
System::SetRunaheadReplayFlag(false);
198198

199199
m_button_state &= ~bit;
200200
}
201201
else
202202
{
203203
if (!(m_button_state & bit))
204-
System::SetRunaheadReplayFlag();
204+
System::SetRunaheadReplayFlag(false);
205205

206206
m_button_state |= bit;
207207
}

src/core/settings.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ void Settings::Load(const SettingsInterface& si, const SettingsInterface& contro
216216
rewind_save_frequency = si.GetFloatValue("Main", "RewindFrequency", 10.0f);
217217
rewind_save_slots = static_cast<u16>(std::min(si.GetUIntValue("Main", "RewindSaveSlots", 10u), 65535u));
218218
runahead_frames = static_cast<u8>(std::min(si.GetUIntValue("Main", "RunaheadFrameCount", 0u), 255u));
219+
runahead_for_analog_input = si.GetBoolValue("Main", "RunaheadForAnalogInput", false);
219220

220221
cpu_execution_mode =
221222
ParseCPUExecutionMode(
@@ -598,6 +599,7 @@ void Settings::Save(SettingsInterface& si, bool ignore_base) const
598599
si.SetFloatValue("Main", "RewindFrequency", rewind_save_frequency);
599600
si.SetUIntValue("Main", "RewindSaveSlots", rewind_save_slots);
600601
si.SetUIntValue("Main", "RunaheadFrameCount", runahead_frames);
602+
si.SetBoolValue("Main", "RunaheadForAnalogInput", runahead_for_analog_input);
601603

602604
si.SetStringValue("CPU", "ExecutionMode", GetCPUExecutionModeName(cpu_execution_mode));
603605
si.SetBoolValue("CPU", "OverclockEnable", cpu_overclock_enable);
@@ -1061,6 +1063,7 @@ void Settings::ApplySettingRestrictions()
10611063
g_settings.mdec_use_old_routines = false;
10621064
g_settings.bios_patch_fast_boot = false;
10631065
g_settings.runahead_frames = 0;
1066+
g_settings.runahead_for_analog_input = false;
10641067
g_settings.rewind_enable = false;
10651068
g_settings.pio_device_type = PIODeviceType::None;
10661069
g_settings.pcdrv_enable = false;

0 commit comments

Comments
 (0)