diff --git a/osu.Framework/Graphics/Performance/FrameTimeDisplay.cs b/osu.Framework/Graphics/Performance/FrameTimeDisplay.cs index 4af720302d..8646dda583 100644 --- a/osu.Framework/Graphics/Performance/FrameTimeDisplay.cs +++ b/osu.Framework/Graphics/Performance/FrameTimeDisplay.cs @@ -99,7 +99,7 @@ private void updateDisplay() elapsedSinceLastUpdate = 0; counter.Text = $"{displayFps:0}fps ({rollingElapsed:0.00}ms)" - + (clock.Throttling ? $"{(clock.MaximumUpdateHz < 10000 ? clock.MaximumUpdateHz.ToString("0") : "∞").PadLeft(4)}hz" : string.Empty); + + (clock.Throttling ? $"{(clock.MaximumUpdateHz > 0 && clock.MaximumUpdateHz < 10000 ? clock.MaximumUpdateHz.ToString("0") : "∞").PadLeft(4)}hz" : string.Empty); } private class CounterText : SpriteText diff --git a/osu.Framework/Platform/GameHost.cs b/osu.Framework/Platform/GameHost.cs index c8fbe77282..ac5960a650 100644 --- a/osu.Framework/Platform/GameHost.cs +++ b/osu.Framework/Platform/GameHost.cs @@ -190,6 +190,12 @@ public void UnregisterThread(GameThread thread) private double maximumUpdateHz; + /// + /// The target number of update frames per second when the game window is active. + /// + /// + /// A value of 0 is treated the same as "unlimited" or . + /// public double MaximumUpdateHz { get => maximumUpdateHz; @@ -198,12 +204,25 @@ public double MaximumUpdateHz private double maximumDrawHz; + /// + /// The target number of draw frames per second when the game window is active. + /// + /// + /// A value of 0 is treated the same as "unlimited" or . + /// public double MaximumDrawHz { get => maximumDrawHz; set => DrawThread.ActiveHz = maximumDrawHz = value; } + /// + /// The target number of updates per second when the game window is inactive. + /// This is applied to all threads. + /// + /// + /// A value of 0 is treated the same as "unlimited" or . + /// public double MaximumInactiveHz { get => DrawThread.InactiveHz; diff --git a/osu.Framework/Statistics/PerformanceMonitor.cs b/osu.Framework/Statistics/PerformanceMonitor.cs index 3a97c4069e..6bf66c7049 100644 --- a/osu.Framework/Statistics/PerformanceMonitor.cs +++ b/osu.Framework/Statistics/PerformanceMonitor.cs @@ -57,7 +57,7 @@ public bool EnablePerformanceProfiling private Thread thread; - public double FrameAimTime => 1000.0 / (Clock?.MaximumUpdateHz ?? double.MaxValue); + public double FrameAimTime => 1000.0 / (Clock?.MaximumUpdateHz > 0 ? Clock.MaximumUpdateHz : double.MaxValue); internal PerformanceMonitor(GameThread thread, IEnumerable counters) { diff --git a/osu.Framework/Threading/GameThread.cs b/osu.Framework/Threading/GameThread.cs index ed71915cac..006bd89760 100644 --- a/osu.Framework/Threading/GameThread.cs +++ b/osu.Framework/Threading/GameThread.cs @@ -97,8 +97,11 @@ public CultureInfo CurrentCulture private CultureInfo culture; /// - /// The refresh rate this thread should run at when active. Only applies when the underlying clock is throttling. + /// The target number of updates per second when the game window is active. /// + /// + /// A value of 0 is treated the same as "unlimited" or . + /// public double ActiveHz { get => activeHz; @@ -112,8 +115,11 @@ public double ActiveHz private double activeHz = DEFAULT_ACTIVE_HZ; /// - /// The refresh rate this thread should run at when inactive. Only applies when the underlying clock is throttling. + /// The target number of updates per second when the game window is inactive. /// + /// + /// A value of 0 is treated the same as "unlimited" or . + /// public double InactiveHz { get => inactiveHz; diff --git a/osu.Framework/Timing/ThrottledFrameClock.cs b/osu.Framework/Timing/ThrottledFrameClock.cs index 56ab6adad1..7c158bb6f5 100644 --- a/osu.Framework/Timing/ThrottledFrameClock.cs +++ b/osu.Framework/Timing/ThrottledFrameClock.cs @@ -15,12 +15,15 @@ namespace osu.Framework.Timing public class ThrottledFrameClock : FramedClock { /// - /// The number of updated per second which is permitted. + /// The target number of updates per second. Only used when is true. /// + /// + /// A value of 0 is treated the same as "unlimited" or . + /// public double MaximumUpdateHz = 1000.0; /// - /// Whether throttling should be enabled. Defaults to true. + /// Whether throttling should be enabled. Defaults to true. /// public bool Throttling = true; @@ -37,7 +40,7 @@ public override void ProcessFrame() if (Throttling) { - if (MaximumUpdateHz > 0) + if (MaximumUpdateHz > 0 && MaximumUpdateHz < double.MaxValue) { throttle(); }