jd's requested changes

This commit is contained in:
Xpl0itR 2020-02-19 11:32:36 +00:00
parent 1c38ac8813
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[] _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;
}
}
}

View file

@ -24,7 +24,7 @@ namespace Ryujinx.Ui
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 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();

View file

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

View file

@ -461,7 +461,7 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
@ -474,7 +474,9 @@
<object class="GtkLabel" id="_vSyncStatus">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">10</property>
<property name="margin_right">5</property>
</object>
<packing>
<property name="expand">False</property>
@ -483,17 +485,102 @@
</packing>
</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="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">5</property>
<property name="margin_right">10</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">8</property>
</packing>
</child>
</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; }
}
}