From 1fe5b1a2606c33761818518c6140c0cab43c0ca0 Mon Sep 17 00:00:00 2001 From: Xpl0itR Date: Wed, 19 Feb 2020 11:32:36 +0000 Subject: [PATCH] jd's requested changes --- Ryujinx.HLE/PerformanceStatistics.cs | 16 ++++- Ryujinx/Ui/GLRenderer.cs | 15 +++-- Ryujinx/Ui/MainWindow.cs | 30 +++++---- Ryujinx/Ui/MainWindow.glade | 95 ++++++++++++++++++++++++++-- Ryujinx/Ui/StatusUpdatedEventArgs.cs | 13 ++++ 5 files changed, 145 insertions(+), 24 deletions(-) create mode 100644 Ryujinx/Ui/StatusUpdatedEventArgs.cs diff --git a/Ryujinx.HLE/PerformanceStatistics.cs b/Ryujinx.HLE/PerformanceStatistics.cs index 5abf2628ee..f77d721895 100644 --- a/Ryujinx.HLE/PerformanceStatistics.cs +++ b/Ryujinx.HLE/PerformanceStatistics.cs @@ -14,6 +14,7 @@ namespace Ryujinx.HLE private double[] _averageFrameRate; private double[] _accumulatedFrameTime; private double[] _previousFrameTime; + private double[] _deltaFrameTime; private long[] _framesRendered; @@ -30,6 +31,7 @@ namespace Ryujinx.HLE _averageFrameRate = new double[2]; _accumulatedFrameTime = new double[2]; _previousFrameTime = new double[2]; + _deltaFrameTime = new double[2]; _framesRendered = new long[2]; @@ -96,13 +98,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]++; } @@ -117,5 +119,15 @@ namespace Ryujinx.HLE { return _averageFrameRate[FrameTypeGame]; } + + public double GetSystemFrameTime() + { + return _deltaFrameTime[FrameTypeSystem] * 1000; + } + + public double GetGameFrameTime() + { + return _deltaFrameTime[FrameTypeGame] * 1000; + } } } diff --git a/Ryujinx/Ui/GLRenderer.cs b/Ryujinx/Ui/GLRenderer.cs index 8c3bbfac0a..cc5ffb6a3f 100644 --- a/Ryujinx/Ui/GLRenderer.cs +++ b/Ryujinx/Ui/GLRenderer.cs @@ -24,7 +24,7 @@ namespace Ryujinx.Ui public ManualResetEvent WaitEvent { get; set; } - public static event EventHandler<(bool, string)> StatusUpdatedEvent; + public static event EventHandler StatusUpdatedEvent; public bool IsActive { get; set; } public bool IsStopped { get; set; } @@ -325,11 +325,14 @@ namespace Ryujinx.Ui _device.Statistics.RecordSystemFrameTime(); - double hostFps = _device.Statistics.GetSystemFrameRate(); - double gameFps = _device.Statistics.GetGameFrameRate(); - string status = $"| Host FPS: {hostFps:0.0} | Game FPS: {gameFps:0.0}"; - - StatusUpdatedEvent?.Invoke(this, (_device.EnableDeviceVsync, status)); + StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs + { + VSyncEnabled = _device.EnableDeviceVsync, + HostFpsStatus = $"Host FPS: {_device.Statistics.GetSystemFrameRate():0.0}", + GameFpsStatus = $"Game FPS: {_device.Statistics.GetGameFrameRate():0.0}", + HostFrameTimeStatus = $"Host Frame Time: {_device.Statistics.GetSystemFrameTime():00.00}ms", + GameFrameTimeStatus = $"Game Frame Time: {_device.Statistics.GetGameFrameTime():00.00}ms" + }); _device.System.SignalVsync(); diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs index 972937fa04..745c9bf4fc 100644 --- a/Ryujinx/Ui/MainWindow.cs +++ b/Ryujinx/Ui/MainWindow.cs @@ -56,6 +56,8 @@ namespace Ryujinx.Ui [GUI] CheckMenuItem _favToggle; [GUI] MenuItem _firmwareInstallFile; [GUI] MenuItem _firmwareInstallDirectory; + [GUI] Label _hostFpsStatus; + [GUI] Label _hostFrameTimeStatus; [GUI] MenuItem _openDebugger; [GUI] CheckMenuItem _iconToggle; [GUI] CheckMenuItem _appToggle; @@ -65,8 +67,9 @@ namespace Ryujinx.Ui [GUI] CheckMenuItem _lastPlayedToggle; [GUI] CheckMenuItem _fileExtToggle; [GUI] CheckMenuItem _fileSizeToggle; - [GUI] Label _fpsStatus; [GUI] CheckMenuItem _pathToggle; + [GUI] Label _gameFpsStatus; + [GUI] Label _gameFrameTimeStatus; [GUI] TreeView _gameTable; [GUI] ScrolledWindow _gameTableWindow; [GUI] TreeSelection _gameTableSelection; @@ -86,7 +89,8 @@ namespace Ryujinx.Ui { builder.Autoconnect(this); - DeleteEvent += Window_Close; + this.DeleteEvent += Window_Close; + _fullScreen.Activated += FullScreen_Toggled; ApplicationLibrary.ApplicationAdded += Application_Added; ApplicationLibrary.ApplicationCountUpdated += ApplicationCount_Updated; @@ -165,7 +169,7 @@ namespace Ryujinx.Ui Task.Run(RefreshFirmwareLabel); - _fullScreen.Activated += FullScreen_Toggled; + _statusBar.Hide(); } #if USE_DEBUGGING @@ -405,7 +409,7 @@ namespace Ryujinx.Ui _viewBox.Child = _gLWidget; _gLWidget.ShowAll(); - ClearFooterForGameRender(); + EditFooterForGameRender(); }); _gLWidget.WaitEvent.WaitOne(); @@ -456,14 +460,13 @@ namespace Ryujinx.Ui private void RecreateFooterForMenu() { _listStatusBox.Show(); - - _fpsStatus.Text = ""; - _vSyncStatus.Text = ""; + _statusBar.Hide(); } - private void ClearFooterForGameRender() + private void EditFooterForGameRender() { _listStatusBox.Hide(); + _statusBar.Show(); } public void ToggleExtraWidgets(bool show) @@ -598,14 +601,17 @@ namespace Ryujinx.Ui }); } - private void Update_StatusBar(object sender, (bool vSync, string fps) status) + private void Update_StatusBar(object sender, StatusUpdatedEventArgs args) { Application.Invoke(delegate { - _vSyncStatus.Text = status.vSync ? "VSync On" : "VSync Off"; - _fpsStatus.Text = status.fps; + _vSyncStatus.Text = args.VSyncEnabled ? "VSync On" : "VSync Off"; + _hostFpsStatus.Text = args.HostFpsStatus; + _gameFpsStatus.Text = args.GameFpsStatus; + _hostFrameTimeStatus.Text = args.HostFrameTimeStatus; + _gameFrameTimeStatus.Text = args.GameFrameTimeStatus; - if (status.vSync) + if (args.VSyncEnabled) { _vSyncStatus.Attributes = new Pango.AttrList(); _vSyncStatus.Attributes.Insert(new Pango.AttrForeground(0, ushort.MaxValue, 0)); diff --git a/Ryujinx/Ui/MainWindow.glade b/Ryujinx/Ui/MainWindow.glade index 9c8a819de0..0007275a99 100644 --- a/Ryujinx/Ui/MainWindow.glade +++ b/Ryujinx/Ui/MainWindow.glade @@ -461,7 +461,7 @@ - False + True True 0 @@ -474,7 +474,9 @@ True False + start 10 + 5 False @@ -483,17 +485,102 @@ - + + True + False + + + False + True + 1 + + + + + True + False + start + 5 + 5 + + + False + True + 2 + + + + + True + False + + + False + True + 3 + + + + + True + False + start + 5 + 5 + + + False + True + 4 + + + + + True + False + + + False + True + 5 + + + + + True + False + start + 5 + 5 + + + False + True + 6 + + + + + True + False + + + False + True + 7 + + + + True False start 5 - 10 True True - 1 + 8 diff --git a/Ryujinx/Ui/StatusUpdatedEventArgs.cs b/Ryujinx/Ui/StatusUpdatedEventArgs.cs new file mode 100644 index 0000000000..f5d90ff5c3 --- /dev/null +++ b/Ryujinx/Ui/StatusUpdatedEventArgs.cs @@ -0,0 +1,13 @@ +using System; + +namespace Ryujinx.Ui +{ + public class StatusUpdatedEventArgs : EventArgs + { + public bool VSyncEnabled { get; set; } + public string HostFpsStatus { get; set; } + public string GameFpsStatus { get; set; } + public string HostFrameTimeStatus { get; set; } + public string GameFrameTimeStatus { get; set; } + } +} \ No newline at end of file