mirror of
https://git.ryujinx.app/kenji-nx/ryujinx.git
synced 2025-12-16 13:37:03 +00:00
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:
parent
da0b784679
commit
e9dea85064
9 changed files with 99 additions and 31 deletions
|
|
@ -41,10 +41,12 @@ namespace Ryujinx.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator T(ReactiveObject<T> obj)
|
public static implicit operator T(ReactiveObject<T> obj) => obj.Value;
|
||||||
{
|
}
|
||||||
return obj.Value;
|
|
||||||
}
|
public static class ReactiveObjectHelper
|
||||||
|
{
|
||||||
|
public static void Toggle(this ReactiveObject<bool> rBoolean) => rBoolean.Value = !rBoolean.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ReactiveEventArgs<T>
|
public class ReactiveEventArgs<T>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ namespace Ryujinx.Graphics.GAL
|
||||||
|
|
||||||
IWindow Window { get; }
|
IWindow Window { get; }
|
||||||
|
|
||||||
|
uint ProgramCount { get; }
|
||||||
|
|
||||||
void BackgroundContextAction(Action action, bool alwaysBackground = false);
|
void BackgroundContextAction(Action action, bool alwaysBackground = false);
|
||||||
|
|
||||||
BufferHandle CreateBuffer(int size, BufferAccess access = BufferAccess.Default);
|
BufferHandle CreateBuffer(int size, BufferAccess access = BufferAccess.Default);
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,8 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
||||||
private int _refProducerPtr;
|
private int _refProducerPtr;
|
||||||
private int _refConsumerPtr;
|
private int _refConsumerPtr;
|
||||||
|
|
||||||
|
public uint ProgramCount { get; set; } = 0;
|
||||||
|
|
||||||
private Action _interruptAction;
|
private Action _interruptAction;
|
||||||
private readonly Lock _interruptLock = new();
|
private readonly Lock _interruptLock = new();
|
||||||
|
|
||||||
|
|
@ -307,6 +309,8 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
||||||
|
|
||||||
Programs.Add(request);
|
Programs.Add(request);
|
||||||
|
|
||||||
|
ProgramCount++;
|
||||||
|
|
||||||
New<CreateProgramCommand>().Set(Ref((IProgramRequest)request));
|
New<CreateProgramCommand>().Set(Ref((IProgramRequest)request));
|
||||||
QueueCommand();
|
QueueCommand();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
|
|
||||||
private readonly Sync _sync;
|
private readonly Sync _sync;
|
||||||
|
|
||||||
|
public uint ProgramCount { get; set; } = 0;
|
||||||
|
|
||||||
public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured;
|
public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured;
|
||||||
|
|
||||||
internal PersistentBuffers PersistentBuffers { get; }
|
internal PersistentBuffers PersistentBuffers { get; }
|
||||||
|
|
@ -94,6 +96,8 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
|
|
||||||
public IProgram CreateProgram(ShaderSource[] shaders, ShaderInfo info)
|
public IProgram CreateProgram(ShaderSource[] shaders, ShaderInfo info)
|
||||||
{
|
{
|
||||||
|
ProgramCount++;
|
||||||
|
|
||||||
return new Program(shaders, info.FragmentOutputMap);
|
return new Program(shaders, info.FragmentOutputMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
|
|
||||||
|
public uint ProgramCount { get; set; } = 0;
|
||||||
|
|
||||||
internal FormatCapabilities FormatCapabilities { get; private set; }
|
internal FormatCapabilities FormatCapabilities { get; private set; }
|
||||||
internal HardwareCapabilities Capabilities;
|
internal HardwareCapabilities Capabilities;
|
||||||
|
|
||||||
|
|
@ -511,6 +513,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
public IProgram CreateProgram(ShaderSource[] sources, ShaderInfo info)
|
public IProgram CreateProgram(ShaderSource[] sources, ShaderInfo info)
|
||||||
{
|
{
|
||||||
|
ProgramCount++;
|
||||||
|
|
||||||
bool isCompute = sources.Length == 1 && sources[0].Stage == ShaderStage.Compute;
|
bool isCompute = sources.Length == 1 && sources[0].Stage == ShaderStage.Compute;
|
||||||
|
|
||||||
if (info.State.HasValue || isCompute)
|
if (info.State.HasValue || isCompute)
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,10 @@ namespace Ryujinx.Ava
|
||||||
private CursorStates _cursorState = !ConfigurationState.Instance.Hid.EnableMouse.Value ?
|
private CursorStates _cursorState = !ConfigurationState.Instance.Hid.EnableMouse.Value ?
|
||||||
CursorStates.CursorIsVisible : CursorStates.CursorIsHidden;
|
CursorStates.CursorIsVisible : CursorStates.CursorIsHidden;
|
||||||
|
|
||||||
|
private DateTime _lastShaderReset;
|
||||||
|
private uint _displayCount;
|
||||||
|
private uint _previousCount = 0;
|
||||||
|
|
||||||
private bool _isStopped;
|
private bool _isStopped;
|
||||||
private bool _isActive;
|
private bool _isActive;
|
||||||
private bool _renderingStarted;
|
private bool _renderingStarted;
|
||||||
|
|
@ -121,7 +125,6 @@ namespace Ryujinx.Ava
|
||||||
private readonly Lock _lockObject = new();
|
private readonly Lock _lockObject = new();
|
||||||
|
|
||||||
public event EventHandler AppExit;
|
public event EventHandler AppExit;
|
||||||
public event EventHandler<StatusInitEventArgs> StatusInitEvent;
|
|
||||||
public event EventHandler<StatusUpdatedEventArgs> StatusUpdatedEvent;
|
public event EventHandler<StatusUpdatedEventArgs> StatusUpdatedEvent;
|
||||||
|
|
||||||
public VirtualFileSystem VirtualFileSystem { get; }
|
public VirtualFileSystem VirtualFileSystem { get; }
|
||||||
|
|
@ -571,8 +574,7 @@ namespace Ryujinx.Ava
|
||||||
}
|
}
|
||||||
|
|
||||||
_isStopped = true;
|
_isStopped = true;
|
||||||
_isActive = false;
|
Stop();
|
||||||
DiscordIntegrationModule.SwitchToMainState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisposeContext()
|
public void DisposeContext()
|
||||||
|
|
@ -1107,14 +1109,14 @@ namespace Ryujinx.Ava
|
||||||
|
|
||||||
public void InitStatus()
|
public void InitStatus()
|
||||||
{
|
{
|
||||||
StatusInitEvent?.Invoke(this, new StatusInitEventArgs(
|
_viewModel.BackendText = ConfigurationState.Instance.Graphics.GraphicsBackend.Value switch
|
||||||
ConfigurationState.Instance.Graphics.GraphicsBackend.Value switch
|
{
|
||||||
{
|
GraphicsBackend.Vulkan => "Vulkan",
|
||||||
GraphicsBackend.Vulkan => "Vulkan",
|
GraphicsBackend.OpenGl => "OpenGL",
|
||||||
GraphicsBackend.OpenGl => "OpenGL",
|
_ => throw new NotImplementedException()
|
||||||
_ => throw new NotImplementedException()
|
};
|
||||||
},
|
|
||||||
$"GPU: {_renderer.GetHardwareInfo().GpuDriver}"));
|
_viewModel.GpuNameText = $"GPU: {_renderer.GetHardwareInfo().GpuDriver}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateStatus()
|
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 dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? LocaleManager.Instance[LocaleKeys.Docked] : LocaleManager.Instance[LocaleKeys.Handheld];
|
||||||
string vSyncMode = Device.VSyncMode.ToString();
|
string vSyncMode = Device.VSyncMode.ToString();
|
||||||
|
|
||||||
|
UpdateShaderCount();
|
||||||
|
|
||||||
if (GraphicsConfig.ResScale != 1)
|
if (GraphicsConfig.ResScale != 1)
|
||||||
{
|
{
|
||||||
dockedMode += $" ({GraphicsConfig.ResScale}x)";
|
dockedMode += $" ({GraphicsConfig.ResScale}x)";
|
||||||
|
|
@ -1134,7 +1138,8 @@ namespace Ryujinx.Ava
|
||||||
dockedMode,
|
dockedMode,
|
||||||
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
|
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
|
||||||
LocaleManager.Instance[LocaleKeys.Game] + $": {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
|
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()
|
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()
|
private bool UpdateFrame()
|
||||||
{
|
{
|
||||||
if (!_isActive)
|
if (!_isActive)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,9 @@ namespace Ryujinx.Ava.UI.Models
|
||||||
public string FifoStatus { get; }
|
public string FifoStatus { get; }
|
||||||
public string GameStatus { get; }
|
public string GameStatus { get; }
|
||||||
|
|
||||||
public StatusUpdatedEventArgs(string vSyncMode, string volumeStatus, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus)
|
public uint ShaderCount { get; }
|
||||||
|
|
||||||
|
public StatusUpdatedEventArgs(string vSyncMode, string volumeStatus, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus, uint shaderCount)
|
||||||
{
|
{
|
||||||
VSyncMode = vSyncMode;
|
VSyncMode = vSyncMode;
|
||||||
VolumeStatus = volumeStatus;
|
VolumeStatus = volumeStatus;
|
||||||
|
|
@ -19,6 +21,7 @@ namespace Ryujinx.Ava.UI.Models
|
||||||
AspectRatio = aspectRatio;
|
AspectRatio = aspectRatio;
|
||||||
GameStatus = gameStatus;
|
GameStatus = gameStatus;
|
||||||
FifoStatus = fifoStatus;
|
FifoStatus = fifoStatus;
|
||||||
|
ShaderCount = shaderCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ using DynamicData;
|
||||||
using DynamicData.Alias;
|
using DynamicData.Alias;
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
|
using Gommon;
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
using Ryujinx.Ava.Common;
|
using Ryujinx.Ava.Common;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
|
@ -69,7 +70,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
private string _gameStatusText;
|
private string _gameStatusText;
|
||||||
private string _volumeStatusText;
|
private string _volumeStatusText;
|
||||||
private string _gpuStatusText;
|
private string _gpuStatusText;
|
||||||
|
private string _shaderCountText;
|
||||||
private bool _isAmiiboRequested;
|
private bool _isAmiiboRequested;
|
||||||
|
private bool _showRightmostSeparator;
|
||||||
private bool _isAmiiboBinRequested;
|
private bool _isAmiiboBinRequested;
|
||||||
private bool _isGameRunning;
|
private bool _isGameRunning;
|
||||||
private bool _isFullScreen;
|
private bool _isFullScreen;
|
||||||
|
|
@ -324,6 +327,17 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
|
||||||
public bool ShowFirmwareStatus => !ShowLoadProgress;
|
public bool ShowFirmwareStatus => !ShowLoadProgress;
|
||||||
|
|
||||||
|
public bool ShowRightmostSeparator
|
||||||
|
{
|
||||||
|
get => _showRightmostSeparator;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_showRightmostSeparator = value;
|
||||||
|
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsGameRunning
|
public bool IsGameRunning
|
||||||
{
|
{
|
||||||
get => _isGameRunning;
|
get => _isGameRunning;
|
||||||
|
|
@ -681,6 +695,16 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ShaderCountText
|
||||||
|
{
|
||||||
|
get => _shaderCountText;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_shaderCountText = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string BackendText
|
public string BackendText
|
||||||
{
|
{
|
||||||
get => _backendText;
|
get => _backendText;
|
||||||
|
|
@ -1474,7 +1498,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
RendererHostControl.WindowCreated += RendererHost_Created;
|
RendererHostControl.WindowCreated += RendererHost_Created;
|
||||||
|
|
||||||
AppHost.StatusInitEvent += Init_StatusBar;
|
|
||||||
AppHost.StatusUpdatedEvent += Update_StatusBar;
|
AppHost.StatusUpdatedEvent += Update_StatusBar;
|
||||||
AppHost.AppExit += AppHost_AppExit;
|
AppHost.AppExit += AppHost_AppExit;
|
||||||
|
|
||||||
|
|
@ -1501,18 +1524,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Init_StatusBar(object sender, StatusInitEventArgs args)
|
|
||||||
{
|
|
||||||
if (ShowMenuAndStatusBar && !ShowLoadProgress)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.InvokeAsync(() =>
|
|
||||||
{
|
|
||||||
GpuNameText = args.GpuName;
|
|
||||||
BackendText = args.GpuBackend;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Update_StatusBar(object sender, StatusUpdatedEventArgs args)
|
private void Update_StatusBar(object sender, StatusUpdatedEventArgs args)
|
||||||
{
|
{
|
||||||
if (ShowMenuAndStatusBar && !ShowLoadProgress)
|
if (ShowMenuAndStatusBar && !ShowLoadProgress)
|
||||||
|
|
@ -1536,6 +1547,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
GameStatusText = args.GameStatus;
|
GameStatusText = args.GameStatus;
|
||||||
VolumeStatusText = args.VolumeStatus;
|
VolumeStatusText = args.VolumeStatus;
|
||||||
FifoStatusText = args.FifoStatus;
|
FifoStatusText = args.FifoStatus;
|
||||||
|
ShaderCountText = args.ShaderCount > 0 ? $"Compiling shaders: {args.ShaderCount}" : string.Empty;
|
||||||
|
ShowRightmostSeparator = !ShaderCountText.IsNullOrEmpty();
|
||||||
|
|
||||||
ShowStatusSeparator = true;
|
ShowStatusSeparator = true;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -325,6 +325,19 @@
|
||||||
IsVisible="{Binding !ShowLoadProgress}"
|
IsVisible="{Binding !ShowLoadProgress}"
|
||||||
Text="{Binding GpuNameText}"
|
Text="{Binding GpuNameText}"
|
||||||
TextAlignment="Start" />
|
TextAlignment="Start" />
|
||||||
|
<Border
|
||||||
|
Width="2"
|
||||||
|
Height="12"
|
||||||
|
Margin="0"
|
||||||
|
BorderBrush="Gray"
|
||||||
|
BorderThickness="1"
|
||||||
|
IsVisible="{Binding ShowRightmostSeparator}" />
|
||||||
|
<TextBlock
|
||||||
|
Name="ShaderCount"
|
||||||
|
Margin="5,0,5,0"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{Binding ShaderCountText}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Grid.Column="3"
|
Grid.Column="3"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue