Commit e166bc11 authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Remove FrameLimiter code

parent 5868ce75
Pipeline #17370 passed with stage
in 5 minutes
......@@ -165,8 +165,6 @@ void UpdateSettings() {
// We don't need these, as this is the frontend's responsibility.
Settings::values.enable_audio_stretching = false;
Settings::values.use_frame_limit = false;
Settings::values.frame_limit = 100;
// For our other settings, import them from LibRetro.
Settings::values.use_cpu_jit =
......
......@@ -150,7 +150,6 @@ public:
const Service::SM::ServiceManager& ServiceManager() const;
PerfStats perf_stats;
FrameLimiter frame_limiter;
void SetStatus(ResultStatus new_status, const char* details = nullptr) {
status = new_status;
......
......@@ -73,35 +73,4 @@ double PerfStats::GetLastFrameTimeScale() {
return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH;
}
void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) {
if (!Settings::values.use_frame_limit) {
return;
}
auto now = Clock::now();
double sleep_scale = Settings::values.frame_limit / 100.0;
// Max lag caused by slow frames. Shouldn't be more than the length of a frame at the current
// speed percent or it will clamp too much and prevent this from properly limiting to that
// percent. High values means it'll take longer after a slow frame to recover and start limiting
const microseconds max_lag_time_us = duration_cast<microseconds>(
std::chrono::duration<double, std::chrono::microseconds::period>(25ms / sleep_scale));
frame_limiting_delta_err += duration_cast<microseconds>(
std::chrono::duration<double, std::chrono::microseconds::period>(
(current_system_time_us - previous_system_time_us) / sleep_scale));
frame_limiting_delta_err -= duration_cast<microseconds>(now - previous_walltime);
frame_limiting_delta_err =
std::clamp(frame_limiting_delta_err, -max_lag_time_us, max_lag_time_us);
if (frame_limiting_delta_err > microseconds::zero()) {
std::this_thread::sleep_for(frame_limiting_delta_err);
auto now_after_sleep = Clock::now();
frame_limiting_delta_err -= duration_cast<microseconds>(now_after_sleep - now);
now = now_after_sleep;
}
previous_system_time_us = current_system_time_us;
previous_walltime = now;
}
} // namespace Core
......@@ -64,20 +64,4 @@ private:
Clock::duration previous_frame_length = Clock::duration::zero();
};
class FrameLimiter {
public:
using Clock = std::chrono::high_resolution_clock;
void DoFrameLimiting(std::chrono::microseconds current_system_time_us);
private:
/// Emulated system time (in microseconds) at the last limiter invocation
std::chrono::microseconds previous_system_time_us{0};
/// Walltime at the last limiter invocation
Clock::time_point previous_walltime = Clock::now();
/// Accumulated difference between walltime and emulated time
std::chrono::microseconds frame_limiting_delta_err{0};
};
} // namespace Core
......@@ -56,8 +56,6 @@ void LogSettings() {
LogSetting("Renderer_UseShaderJit", Settings::values.use_shader_jit);
LogSetting("Renderer_UseResolutionFactor", Settings::values.resolution_factor);
LogSetting("Renderer_UseVsync", Settings::values.use_vsync);
LogSetting("Renderer_UseFrameLimit", Settings::values.use_frame_limit);
LogSetting("Renderer_FrameLimit", Settings::values.frame_limit);
LogSetting("Layout_Toggle3d", Settings::values.toggle_3d);
LogSetting("Layout_Factor3d", Settings::values.factor_3d);
LogSetting("Layout_LayoutOption", static_cast<int>(Settings::values.layout_option));
......
......@@ -124,8 +124,6 @@ struct Values {
bool use_shader_jit;
u16 resolution_factor;
bool use_vsync;
bool use_frame_limit;
u16 frame_limit;
LayoutOption layout_option;
bool swap_screen;
......
......@@ -148,7 +148,6 @@ void RendererOpenGL::SwapBuffers() {
render_window.PollEvents();
render_window.SwapBuffers();
Core::System::GetInstance().frame_limiter.DoFrameLimiting(CoreTiming::GetGlobalTimeUs());
Core::System::GetInstance().perf_stats.BeginSystemFrame();
prev_state.Apply();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment