diff --git a/Ryujinx.Profiler/InternalProfile.cs b/Ryujinx.Profiler/InternalProfile.cs index e318e8a7cb..8dfeeb559a 100644 --- a/Ryujinx.Profiler/InternalProfile.cs +++ b/Ryujinx.Profiler/InternalProfile.cs @@ -30,6 +30,8 @@ namespace Ryujinx.Profiler private const int MaxFlags = 50; + private Action _timingFlagCallback; + public InternalProfile(long history) { _timingFlags = new TimingFlag[MaxFlags]; @@ -71,9 +73,13 @@ namespace Ryujinx.Profiler }; if (++_timingFlagIndex >= MaxFlags) + { _timingFlagIndex = 0; + } _timingFlagCount = Math.Max(_timingFlagCount + 1, MaxFlags); + + _timingFlagCallback?.Invoke(_timingFlags[_timingFlagIndex]); } public void BeginProfile(ProfileConfig config) @@ -148,6 +154,11 @@ namespace Ryujinx.Profiler return outFlags; } + public void RegisterFlagReciever(Action reciever) + { + _timingFlagCallback = reciever; + } + public void Dispose() { _cleanupRunning = false; diff --git a/Ryujinx.Profiler/Profile.cs b/Ryujinx.Profiler/Profile.cs index d45bd538a2..9373a8c258 100644 --- a/Ryujinx.Profiler/Profile.cs +++ b/Ryujinx.Profiler/Profile.cs @@ -6,12 +6,12 @@ namespace Ryujinx.Profiler { public static class Profile { + public static float UpdateRate => _settings.UpdateRate; + public static long HistoryLength => _settings.History; + private static InternalProfile _profileInstance; private static ProfilerSettings _settings; - public static float UpdateRate => _settings.UpdateRate; - public static long HistoryLength => _settings.History; - public static bool ProfilingEnabled() { if (!_settings.Enabled) @@ -46,6 +46,13 @@ namespace Ryujinx.Profiler _profileInstance.FlagTime(flagType); } + public static void RegisterFlagReciever(Action reciever) + { + if (!ProfilingEnabled()) + return; + _profileInstance.RegisterFlagReciever(reciever); + } + public static void Begin(ProfileConfig config) { if (!ProfilingEnabled()) diff --git a/Ryujinx.Profiler/UI/ProfileWindow.cs b/Ryujinx.Profiler/UI/ProfileWindow.cs index 98e66f64f6..95fc06d687 100644 --- a/Ryujinx.Profiler/UI/ProfileWindow.cs +++ b/Ryujinx.Profiler/UI/ProfileWindow.cs @@ -98,6 +98,18 @@ namespace Ryujinx.Profiler.UI Location = new Point(DisplayDevice.Default.Width - 1280, (DisplayDevice.Default.Height - 720) - 50); + if (Profile.UpdateRate <= 0) + { + // Perform step regardless of flag type + Profile.RegisterFlagReciever((t) => + { + if (!_paused) + { + _doStep = true; + } + }); + } + // Large number to force an update on first update _updateTimer = 0xFFFF; @@ -218,7 +230,7 @@ namespace Ryujinx.Profiler.UI // Get timing data if enough time has passed _updateTimer += e.Time; - if (_doStep || (!_paused && (_updateTimer > Profile.UpdateRate))) + if (_doStep || ((Profile.UpdateRate > 0) && (!_paused && (_updateTimer > Profile.UpdateRate)))) { _updateTimer = 0; _unsortedProfileData = Profile.GetProfilingData().ToList(); diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 557d1f4114..cefb667612 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -65,14 +65,14 @@ namespace Ryujinx } } - string profilePath = parser.Value("Profile_Dump_Path"); + double updateRateHz = Convert.ToSingle(parser.Value("Profiling_Update_Rate")); Profile.Configure(new ProfilerSettings() { Enabled = Convert.ToBoolean(parser.Value("Profiling_Enabled")), FileDumpEnabled = profilePath != "", DumpLocation = profilePath, - UpdateRate = 1.0f / Convert.ToSingle(parser.Value("Profiling_Update_Rate")), + UpdateRate = (float)((updateRateHz <= 0) ? -1 : 1.0f / updateRateHz), History = Profile.ConvertSecondsToTicks(Convert.ToDouble(parser.Value("Profiling_History"))), });