jd's requested changes

This commit is contained in:
Xpl0itR 2020-02-19 11:32:36 +00:00
commit 1fe5b1a260
No known key found for this signature in database
GPG key ID: 91798184109676AD
5 changed files with 145 additions and 24 deletions

View file

@ -14,6 +14,7 @@ namespace Ryujinx.HLE
private double[] _averageFrameRate; private double[] _averageFrameRate;
private double[] _accumulatedFrameTime; private double[] _accumulatedFrameTime;
private double[] _previousFrameTime; private double[] _previousFrameTime;
private double[] _deltaFrameTime;
private long[] _framesRendered; private long[] _framesRendered;
@ -30,6 +31,7 @@ namespace Ryujinx.HLE
_averageFrameRate = new double[2]; _averageFrameRate = new double[2];
_accumulatedFrameTime = new double[2]; _accumulatedFrameTime = new double[2];
_previousFrameTime = new double[2]; _previousFrameTime = new double[2];
_deltaFrameTime = new double[2];
_framesRendered = new long[2]; _framesRendered = new long[2];
@ -96,13 +98,13 @@ namespace Ryujinx.HLE
{ {
double currentFrameTime = _executionTime.ElapsedTicks * _ticksToSeconds; double currentFrameTime = _executionTime.ElapsedTicks * _ticksToSeconds;
double elapsedFrameTime = currentFrameTime - _previousFrameTime[frameType]; _deltaFrameTime[frameType] = currentFrameTime - _previousFrameTime[frameType];
_previousFrameTime[frameType] = currentFrameTime; _previousFrameTime[frameType] = currentFrameTime;
lock (_frameLock[frameType]) lock (_frameLock[frameType])
{ {
_accumulatedFrameTime[frameType] += elapsedFrameTime; _accumulatedFrameTime[frameType] += _deltaFrameTime[frameType];
_framesRendered[frameType]++; _framesRendered[frameType]++;
} }
@ -117,5 +119,15 @@ namespace Ryujinx.HLE
{ {
return _averageFrameRate[FrameTypeGame]; return _averageFrameRate[FrameTypeGame];
} }
public double GetSystemFrameTime()
{
return _deltaFrameTime[FrameTypeSystem] * 1000;
}
public double GetGameFrameTime()
{
return _deltaFrameTime[FrameTypeGame] * 1000;
}
} }
} }

View file

@ -24,7 +24,7 @@ namespace Ryujinx.Ui
public ManualResetEvent WaitEvent { get; set; } public ManualResetEvent WaitEvent { get; set; }
public static event EventHandler<(bool, string)> StatusUpdatedEvent; public static event EventHandler<StatusUpdatedEventArgs> StatusUpdatedEvent;
public bool IsActive { get; set; } public bool IsActive { get; set; }
public bool IsStopped { get; set; } public bool IsStopped { get; set; }
@ -325,11 +325,14 @@ namespace Ryujinx.Ui
_device.Statistics.RecordSystemFrameTime(); _device.Statistics.RecordSystemFrameTime();
double hostFps = _device.Statistics.GetSystemFrameRate(); StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs
double gameFps = _device.Statistics.GetGameFrameRate(); {
string status = $"| Host FPS: {hostFps:0.0} | Game FPS: {gameFps:0.0}"; VSyncEnabled = _device.EnableDeviceVsync,
HostFpsStatus = $"Host FPS: {_device.Statistics.GetSystemFrameRate():0.0}",
StatusUpdatedEvent?.Invoke(this, (_device.EnableDeviceVsync, status)); 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(); _device.System.SignalVsync();

View file

@ -56,6 +56,8 @@ namespace Ryujinx.Ui
[GUI] CheckMenuItem _favToggle; [GUI] CheckMenuItem _favToggle;
[GUI] MenuItem _firmwareInstallFile; [GUI] MenuItem _firmwareInstallFile;
[GUI] MenuItem _firmwareInstallDirectory; [GUI] MenuItem _firmwareInstallDirectory;
[GUI] Label _hostFpsStatus;
[GUI] Label _hostFrameTimeStatus;
[GUI] MenuItem _openDebugger; [GUI] MenuItem _openDebugger;
[GUI] CheckMenuItem _iconToggle; [GUI] CheckMenuItem _iconToggle;
[GUI] CheckMenuItem _appToggle; [GUI] CheckMenuItem _appToggle;
@ -65,8 +67,9 @@ namespace Ryujinx.Ui
[GUI] CheckMenuItem _lastPlayedToggle; [GUI] CheckMenuItem _lastPlayedToggle;
[GUI] CheckMenuItem _fileExtToggle; [GUI] CheckMenuItem _fileExtToggle;
[GUI] CheckMenuItem _fileSizeToggle; [GUI] CheckMenuItem _fileSizeToggle;
[GUI] Label _fpsStatus;
[GUI] CheckMenuItem _pathToggle; [GUI] CheckMenuItem _pathToggle;
[GUI] Label _gameFpsStatus;
[GUI] Label _gameFrameTimeStatus;
[GUI] TreeView _gameTable; [GUI] TreeView _gameTable;
[GUI] ScrolledWindow _gameTableWindow; [GUI] ScrolledWindow _gameTableWindow;
[GUI] TreeSelection _gameTableSelection; [GUI] TreeSelection _gameTableSelection;
@ -86,7 +89,8 @@ namespace Ryujinx.Ui
{ {
builder.Autoconnect(this); builder.Autoconnect(this);
DeleteEvent += Window_Close; this.DeleteEvent += Window_Close;
_fullScreen.Activated += FullScreen_Toggled;
ApplicationLibrary.ApplicationAdded += Application_Added; ApplicationLibrary.ApplicationAdded += Application_Added;
ApplicationLibrary.ApplicationCountUpdated += ApplicationCount_Updated; ApplicationLibrary.ApplicationCountUpdated += ApplicationCount_Updated;
@ -165,7 +169,7 @@ namespace Ryujinx.Ui
Task.Run(RefreshFirmwareLabel); Task.Run(RefreshFirmwareLabel);
_fullScreen.Activated += FullScreen_Toggled; _statusBar.Hide();
} }
#if USE_DEBUGGING #if USE_DEBUGGING
@ -405,7 +409,7 @@ namespace Ryujinx.Ui
_viewBox.Child = _gLWidget; _viewBox.Child = _gLWidget;
_gLWidget.ShowAll(); _gLWidget.ShowAll();
ClearFooterForGameRender(); EditFooterForGameRender();
}); });
_gLWidget.WaitEvent.WaitOne(); _gLWidget.WaitEvent.WaitOne();
@ -456,14 +460,13 @@ namespace Ryujinx.Ui
private void RecreateFooterForMenu() private void RecreateFooterForMenu()
{ {
_listStatusBox.Show(); _listStatusBox.Show();
_statusBar.Hide();
_fpsStatus.Text = "";
_vSyncStatus.Text = "";
} }
private void ClearFooterForGameRender() private void EditFooterForGameRender()
{ {
_listStatusBox.Hide(); _listStatusBox.Hide();
_statusBar.Show();
} }
public void ToggleExtraWidgets(bool 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 Application.Invoke(delegate
{ {
_vSyncStatus.Text = status.vSync ? "VSync On" : "VSync Off"; _vSyncStatus.Text = args.VSyncEnabled ? "VSync On" : "VSync Off";
_fpsStatus.Text = status.fps; _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 = new Pango.AttrList();
_vSyncStatus.Attributes.Insert(new Pango.AttrForeground(0, ushort.MaxValue, 0)); _vSyncStatus.Attributes.Insert(new Pango.AttrForeground(0, ushort.MaxValue, 0));

View file

@ -461,7 +461,7 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
@ -474,7 +474,9 @@
<object class="GtkLabel" id="_vSyncStatus"> <object class="GtkLabel" id="_vSyncStatus">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">10</property> <property name="margin_left">10</property>
<property name="margin_right">5</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -483,17 +485,102 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="_fpsStatus"> <object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="_hostFpsStatus">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="_hostFrameTimeStatus">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="_gameFpsStatus">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="_gameFrameTimeStatus">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="margin_left">5</property> <property name="margin_left">5</property>
<property name="margin_right">10</property>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">8</property>
</packing> </packing>
</child> </child>
</object> </object>

View file

@ -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; }
}
}