mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-20 00:46:34 +00:00
Implement shader compile counter (Avalonia)
This commit is contained in:
parent
ca59c3f499
commit
67b873645f
9 changed files with 81 additions and 5 deletions
|
@ -14,6 +14,8 @@ namespace Ryujinx.Graphics.GAL
|
|||
|
||||
IWindow Window { get; }
|
||||
|
||||
uint ProgramCount { get; }
|
||||
|
||||
void BackgroundContextAction(Action action, bool alwaysBackground = false);
|
||||
|
||||
BufferHandle CreateBuffer(int size, BufferAccess access = BufferAccess.Default);
|
||||
|
|
|
@ -55,6 +55,8 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
|||
private int _refProducerPtr;
|
||||
private int _refConsumerPtr;
|
||||
|
||||
public uint ProgramCount { get; set; } = 0;
|
||||
|
||||
private Action _interruptAction;
|
||||
private readonly object _interruptLock = new();
|
||||
|
||||
|
@ -307,6 +309,8 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
|||
|
||||
Programs.Add(request);
|
||||
|
||||
ProgramCount++;
|
||||
|
||||
New<CreateProgramCommand>().Set(Ref((IProgramRequest)request));
|
||||
QueueCommand();
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
private readonly Sync _sync;
|
||||
|
||||
public uint ProgramCount { get; set; } = 0;
|
||||
|
||||
public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured;
|
||||
|
||||
internal PersistentBuffers PersistentBuffers { get; }
|
||||
|
@ -94,6 +96,8 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
public IProgram CreateProgram(ShaderSource[] shaders, ShaderInfo info)
|
||||
{
|
||||
ProgramCount++;
|
||||
|
||||
return new Program(shaders, info.FragmentOutputMap);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
private bool _initialized;
|
||||
|
||||
public uint ProgramCount { get; set; } = 0;
|
||||
|
||||
internal FormatCapabilities FormatCapabilities { get; private set; }
|
||||
internal HardwareCapabilities Capabilities;
|
||||
|
||||
|
@ -544,6 +546,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
public IProgram CreateProgram(ShaderSource[] sources, ShaderInfo info)
|
||||
{
|
||||
ProgramCount++;
|
||||
|
||||
bool isCompute = sources.Length == 1 && sources[0].Stage == ShaderStage.Compute;
|
||||
|
||||
if (info.State.HasValue || isCompute)
|
||||
|
|
|
@ -13,7 +13,15 @@ namespace Ryujinx.UI
|
|||
public string GpuName;
|
||||
public string GpuBackend;
|
||||
|
||||
public StatusUpdatedEventArgs(bool vSyncEnabled, float volume, string gpuBackend, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus, string gpuName)
|
||||
public StatusUpdatedEventArgs(
|
||||
bool vSyncEnabled,
|
||||
float volume,
|
||||
string gpuBackend,
|
||||
string dockedMode,
|
||||
string aspectRatio,
|
||||
string gameStatus,
|
||||
string fifoStatus,
|
||||
string gpuName)
|
||||
{
|
||||
VSyncEnabled = vSyncEnabled;
|
||||
Volume = volume;
|
||||
|
|
|
@ -103,6 +103,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;
|
||||
|
@ -1059,6 +1063,8 @@ namespace Ryujinx.Ava
|
|||
// Run a status update only when a frame is to be drawn. This prevents from updating the ui and wasting a render when no frame is queued.
|
||||
string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? LocaleManager.Instance[LocaleKeys.Docked] : LocaleManager.Instance[LocaleKeys.Handheld];
|
||||
|
||||
UpdateShaderCount();
|
||||
|
||||
if (GraphicsConfig.ResScale != 1)
|
||||
{
|
||||
dockedMode += $" ({GraphicsConfig.ResScale}x)";
|
||||
|
@ -1070,7 +1076,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()
|
||||
|
@ -1096,6 +1103,25 @@ 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)
|
||||
|
|
|
@ -10,8 +10,9 @@ namespace Ryujinx.Ava.UI.Models
|
|||
public string DockedMode { get; }
|
||||
public string FifoStatus { get; }
|
||||
public string GameStatus { get; }
|
||||
public uint ShaderCount { get; }
|
||||
|
||||
public StatusUpdatedEventArgs(bool vSyncEnabled, string volumeStatus, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus)
|
||||
public StatusUpdatedEventArgs(bool vSyncEnabled, string volumeStatus, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus, uint shaderCount)
|
||||
{
|
||||
VSyncEnabled = vSyncEnabled;
|
||||
VolumeStatus = volumeStatus;
|
||||
|
@ -19,6 +20,7 @@ namespace Ryujinx.Ava.UI.Models
|
|||
AspectRatio = aspectRatio;
|
||||
GameStatus = gameStatus;
|
||||
FifoStatus = fifoStatus;
|
||||
ShaderCount = shaderCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
private string _gameStatusText;
|
||||
private string _volumeStatusText;
|
||||
private string _gpuStatusText;
|
||||
private string _shaderCountText;
|
||||
private bool _isAmiiboRequested;
|
||||
private bool _isGameRunning;
|
||||
private bool _isFullScreen;
|
||||
|
@ -502,6 +503,17 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public string ShaderCountText
|
||||
{
|
||||
get => _shaderCountText;
|
||||
set
|
||||
{
|
||||
_shaderCountText = value;
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string BackendText
|
||||
{
|
||||
get => _backendText;
|
||||
|
@ -1243,6 +1255,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
GameStatusText = args.GameStatus;
|
||||
VolumeStatusText = args.VolumeStatus;
|
||||
FifoStatusText = args.FifoStatus;
|
||||
ShaderCountText = args.ShaderCount > 0 ? LocaleManager.Instance[LocaleKeys.CompilingShaders] + $": {args.ShaderCount}" : "";
|
||||
|
||||
ShowStatusSeparator = true;
|
||||
});
|
||||
|
|
|
@ -270,7 +270,20 @@
|
|||
VerticalAlignment="Center"
|
||||
IsVisible="{Binding !ShowLoadProgress}"
|
||||
Text="{Binding GpuNameText}"
|
||||
TextAlignment="Start" />
|
||||
TextAlignment="Left" />
|
||||
<Border
|
||||
Width="2"
|
||||
Height="12"
|
||||
Margin="0"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="1"
|
||||
IsVisible="{Binding !ShowLoadProgress}" />
|
||||
<TextBlock
|
||||
Name="ShaderCount"
|
||||
Margin="5,0,5,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding ShaderCountText}" />
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Grid.Column="3"
|
||||
|
|
Loading…
Reference in a new issue