From 843401635acb08686c745351666f86146de841b7 Mon Sep 17 00:00:00 2001 From: MutantAura <44103205+MutantAura@users.noreply.github.com> Date: Wed, 15 Sep 2021 01:26:10 +0100 Subject: [PATCH] Adjustments to framerate metric and addition of frametime (#2638) * Adjust framerate data and add frametime * Update PerformanceStatistics.cs * Revert deletions of average framerate * Update Ryujinx.csproj * Remove separate GTK column * Increase FPS precision * general cleanup * even generaler cleanup * fix dumb * Remove legacy code * Update PerformanceStatistics.cs * Update PerformanceStatistics.cs --- Ryujinx.HLE/PerformanceStatistics.cs | 29 ++++++++++++++-------------- Ryujinx.Headless.SDL2/WindowBase.cs | 2 +- Ryujinx/Ui/RendererWidgetBase.cs | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Ryujinx.HLE/PerformanceStatistics.cs b/Ryujinx.HLE/PerformanceStatistics.cs index b254356c1b..95fc2abe39 100644 --- a/Ryujinx.HLE/PerformanceStatistics.cs +++ b/Ryujinx.HLE/PerformanceStatistics.cs @@ -5,11 +5,10 @@ namespace Ryujinx.HLE { public class PerformanceStatistics { - private const double FrameRateWeight = 0.5; - private const int FrameTypeGame = 0; - private const int PercentTypeFifo = 0; + private const int FrameTypeGame = 0; + private const int PercentTypeFifo = 0; - private double[] _averageFrameRate; + private double[] _frameRate; private double[] _accumulatedFrameTime; private double[] _previousFrameTime; @@ -30,7 +29,7 @@ namespace Ryujinx.HLE public PerformanceStatistics() { - _averageFrameRate = new double[1]; + _frameRate = new double[1]; _accumulatedFrameTime = new double[1]; _previousFrameTime = new double[1]; @@ -45,7 +44,7 @@ namespace Ryujinx.HLE _frameLock = new object[] { new object() }; _percentLock = new object[] { new object() }; - _resetTimer = new Timer(1000); + _resetTimer = new Timer(750); _resetTimer.Elapsed += ResetTimerElapsed; _resetTimer.AutoReset = true; @@ -57,11 +56,11 @@ namespace Ryujinx.HLE private void ResetTimerElapsed(object sender, ElapsedEventArgs e) { - CalculateAverageFrameRate(FrameTypeGame); + CalculateFrameRate(FrameTypeGame); CalculateAveragePercent(PercentTypeFifo); } - private void CalculateAverageFrameRate(int frameType) + private void CalculateFrameRate(int frameType) { double frameRate = 0; @@ -72,7 +71,7 @@ namespace Ryujinx.HLE frameRate = _framesRendered[frameType] / _accumulatedFrameTime[frameType]; } - _averageFrameRate[frameType] = LinearInterpolate(_averageFrameRate[frameType], frameRate); + _frameRate[frameType] = frameRate; _framesRendered[frameType] = 0; _accumulatedFrameTime[frameType] = 0; } @@ -97,11 +96,6 @@ namespace Ryujinx.HLE } } - private static double LinearInterpolate(double lhs, double rhs) - { - return lhs * (1.0 - FrameRateWeight) + rhs * FrameRateWeight; - } - public void RecordGameFrameTime() { RecordFrameTime(FrameTypeGame); @@ -157,12 +151,17 @@ namespace Ryujinx.HLE public double GetGameFrameRate() { - return _averageFrameRate[FrameTypeGame]; + return _frameRate[FrameTypeGame]; } public double GetFifoPercent() { return _averagePercent[PercentTypeFifo]; } + + public double GetGameFrameTime() + { + return 1000 / _frameRate[FrameTypeGame]; + } } } \ No newline at end of file diff --git a/Ryujinx.Headless.SDL2/WindowBase.cs b/Ryujinx.Headless.SDL2/WindowBase.cs index 6297e64e15..858b08010e 100644 --- a/Ryujinx.Headless.SDL2/WindowBase.cs +++ b/Ryujinx.Headless.SDL2/WindowBase.cs @@ -198,7 +198,7 @@ namespace Ryujinx.Headless.SDL2 Device.EnableDeviceVsync, dockedMode, Device.Configuration.AspectRatio.ToText(), - $"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS", + $"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)", $"FIFO: {Device.Statistics.GetFifoPercent():0.00} %", $"GPU: {_gpuVendorName}")); diff --git a/Ryujinx/Ui/RendererWidgetBase.cs b/Ryujinx/Ui/RendererWidgetBase.cs index 2ddd44dca8..c25e2163d1 100644 --- a/Ryujinx/Ui/RendererWidgetBase.cs +++ b/Ryujinx/Ui/RendererWidgetBase.cs @@ -427,7 +427,7 @@ namespace Ryujinx.Ui Device.EnableDeviceVsync, dockedMode, ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(), - $"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS", + $"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)", $"FIFO: {Device.Statistics.GetFifoPercent():0.00} %", $"GPU: {_gpuVendorName}"));