2 unmerged PRs from original Ryujinx:

Implement shader compile counter (currently not translated, will change, need to pull changes.)
Remove event logic in favor of a single init function.
Thanks @MutantAura
This commit is contained in:
Evan Husted 2024-10-24 14:14:12 -05:00 committed by KeatonTheBot
parent da0b784679
commit e9dea85064
9 changed files with 99 additions and 31 deletions

View file

@ -104,6 +104,10 @@ namespace Ryujinx.Ava
private CursorStates _cursorState = !ConfigurationState.Instance.Hid.EnableMouse.Value ?
CursorStates.CursorIsVisible : CursorStates.CursorIsHidden;
private DateTime _lastShaderReset;
private uint _displayCount;
private uint _previousCount = 0;
private bool _isStopped;
private bool _isActive;
private bool _renderingStarted;
@ -121,7 +125,6 @@ namespace Ryujinx.Ava
private readonly Lock _lockObject = new();
public event EventHandler AppExit;
public event EventHandler<StatusInitEventArgs> StatusInitEvent;
public event EventHandler<StatusUpdatedEventArgs> StatusUpdatedEvent;
public VirtualFileSystem VirtualFileSystem { get; }
@ -571,8 +574,7 @@ namespace Ryujinx.Ava
}
_isStopped = true;
_isActive = false;
DiscordIntegrationModule.SwitchToMainState();
Stop();
}
public void DisposeContext()
@ -1107,14 +1109,14 @@ namespace Ryujinx.Ava
public void InitStatus()
{
StatusInitEvent?.Invoke(this, new StatusInitEventArgs(
ConfigurationState.Instance.Graphics.GraphicsBackend.Value switch
{
GraphicsBackend.Vulkan => "Vulkan",
GraphicsBackend.OpenGl => "OpenGL",
_ => throw new NotImplementedException()
},
$"GPU: {_renderer.GetHardwareInfo().GpuDriver}"));
_viewModel.BackendText = ConfigurationState.Instance.Graphics.GraphicsBackend.Value switch
{
GraphicsBackend.Vulkan => "Vulkan",
GraphicsBackend.OpenGl => "OpenGL",
_ => throw new NotImplementedException()
};
_viewModel.GpuNameText = $"GPU: {_renderer.GetHardwareInfo().GpuDriver}";
}
public void UpdateStatus()
@ -1123,6 +1125,8 @@ namespace Ryujinx.Ava
string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? LocaleManager.Instance[LocaleKeys.Docked] : LocaleManager.Instance[LocaleKeys.Handheld];
string vSyncMode = Device.VSyncMode.ToString();
UpdateShaderCount();
if (GraphicsConfig.ResScale != 1)
{
dockedMode += $" ({GraphicsConfig.ResScale}x)";
@ -1134,7 +1138,8 @@ namespace Ryujinx.Ava
dockedMode,
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
LocaleManager.Instance[LocaleKeys.Game] + $": {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
$"FIFO: {Device.Statistics.GetFifoPercent():00.00} %"));
$"FIFO: {Device.Statistics.GetFifoPercent():00.00} %",
_displayCount));
}
public async Task ShowExitPrompt()
@ -1160,6 +1165,24 @@ namespace Ryujinx.Ava
}
}
private void UpdateShaderCount()
{
// If there is a mismatch between total program compile and previous count
// this means new shaders have been compiled and should be displayed.
if (_renderer.ProgramCount != _previousCount)
{
_displayCount += _renderer.ProgramCount - _previousCount;
_lastShaderReset = DateTime.Now;
_previousCount = _renderer.ProgramCount;
}
// Check if 5s has passed since any new shaders were compiled.
// If yes, reset the counter.
else if (_lastShaderReset.AddSeconds(5) <= DateTime.Now)
{
_displayCount = 0;
}
}
private bool UpdateFrame()
{
if (!_isActive)