From 5e87bbeb46bc725845851b999175cf32e04ff0ff Mon Sep 17 00:00:00 2001 From: Andy Adshead Date: Sat, 29 Dec 2018 20:18:08 +0000 Subject: [PATCH] Frame times in title bar --- Ryujinx.HLE/PerformanceStatistics.cs | 26 ++++++++++++++++++++++++-- Ryujinx/Ui/GLScreen.cs | 13 +++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Ryujinx.HLE/PerformanceStatistics.cs b/Ryujinx.HLE/PerformanceStatistics.cs index 408e5d72ad..531dc0449f 100644 --- a/Ryujinx.HLE/PerformanceStatistics.cs +++ b/Ryujinx.HLE/PerformanceStatistics.cs @@ -13,6 +13,7 @@ namespace Ryujinx.HLE private double[] _averageFrameRate; private double[] _accumulatedFrameTime; private double[] _previousFrameTime; + private double[] _deltaFrameTime; private long[] _framesRendered; @@ -29,6 +30,7 @@ namespace Ryujinx.HLE _averageFrameRate = new double[2]; _accumulatedFrameTime = new double[2]; _previousFrameTime = new double[2]; + _deltaFrameTime = new double[2]; _framesRendered = new long[2]; @@ -93,13 +95,13 @@ namespace Ryujinx.HLE { double currentFrameTime = _executionTime.ElapsedTicks * _ticksToSeconds; - double elapsedFrameTime = currentFrameTime - _previousFrameTime[frameType]; + _deltaFrameTime[frameType] = currentFrameTime - _previousFrameTime[frameType]; _previousFrameTime[frameType] = currentFrameTime; lock (_frameLock[frameType]) { - _accumulatedFrameTime[frameType] += elapsedFrameTime; + _accumulatedFrameTime[frameType] += _deltaFrameTime[frameType]; _framesRendered[frameType]++; } @@ -114,5 +116,25 @@ namespace Ryujinx.HLE { return _averageFrameRate[FrameTypeGame]; } + + public double GetGameFrameTime() + { + return _deltaFrameTime[FrameTypeGame] * 1000; + } + + public double GetGameAverageFrameTime() + { + return 1000 / _averageFrameRate[FrameTypeGame]; + } + + public double GetSystemFrameTime() + { + return _deltaFrameTime[FrameTypeSystem] * 1000; + } + + public double GetSystemAverageFrameTime() + { + return 1000 / _averageFrameRate[FrameTypeSystem]; + } } } diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index e3a6d299bc..a884ed4d41 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -246,14 +246,23 @@ namespace Ryujinx _device.Statistics.RecordSystemFrameTime(); + // System double hostFps = _device.Statistics.GetSystemFrameRate(); + double hostFrameTime = _device.Statistics.GetSystemFrameTime(); + double hostAvgFrameTime = _device.Statistics.GetSystemAverageFrameTime(); + + // Game double gameFps = _device.Statistics.GetGameFrameRate(); + double gameFrameTime =_device.Statistics.GetGameFrameTime(); + double gameAvgFrameTime = _device.Statistics.GetGameAverageFrameTime(); string titleSection = string.IsNullOrWhiteSpace(_device.System.CurrentTitle) ? string.Empty : " | " + _device.System.CurrentTitle; - _newTitle = $"Ryujinx{titleSection} | Host FPS: {hostFps:0.0} | Game FPS: {gameFps:0.0} | " + - $"Game Vsync: {(_device.EnableDeviceVsync ? "On" : "Off")}"; + _newTitle = $"Ryujinx{titleSection} | " + + $"Host FPS: {hostFps:0.0} ({hostFrameTime:000.00}ms, Avg: {hostAvgFrameTime:000.00}ms) | " + + $"Game FPS: {gameFps:0.0} ({gameFrameTime:000.00}ms, Avg: {gameAvgFrameTime:000.00}ms) | " + + $"Game Vsync: {(_device.EnableDeviceVsync ? "On" : "Off")}"; _titleEvent = true;