Update at when flag issued (ie every frame)

This commit is contained in:
Andy Adshead 2019-01-30 02:45:17 +00:00
commit 6458361d35
4 changed files with 36 additions and 6 deletions

View file

@ -30,6 +30,8 @@ namespace Ryujinx.Profiler
private const int MaxFlags = 50; private const int MaxFlags = 50;
private Action<TimingFlag> _timingFlagCallback;
public InternalProfile(long history) public InternalProfile(long history)
{ {
_timingFlags = new TimingFlag[MaxFlags]; _timingFlags = new TimingFlag[MaxFlags];
@ -71,9 +73,13 @@ namespace Ryujinx.Profiler
}; };
if (++_timingFlagIndex >= MaxFlags) if (++_timingFlagIndex >= MaxFlags)
{
_timingFlagIndex = 0; _timingFlagIndex = 0;
}
_timingFlagCount = Math.Max(_timingFlagCount + 1, MaxFlags); _timingFlagCount = Math.Max(_timingFlagCount + 1, MaxFlags);
_timingFlagCallback?.Invoke(_timingFlags[_timingFlagIndex]);
} }
public void BeginProfile(ProfileConfig config) public void BeginProfile(ProfileConfig config)
@ -148,6 +154,11 @@ namespace Ryujinx.Profiler
return outFlags; return outFlags;
} }
public void RegisterFlagReciever(Action<TimingFlag> reciever)
{
_timingFlagCallback = reciever;
}
public void Dispose() public void Dispose()
{ {
_cleanupRunning = false; _cleanupRunning = false;

View file

@ -6,12 +6,12 @@ namespace Ryujinx.Profiler
{ {
public static class Profile public static class Profile
{ {
private static InternalProfile _profileInstance;
private static ProfilerSettings _settings;
public static float UpdateRate => _settings.UpdateRate; public static float UpdateRate => _settings.UpdateRate;
public static long HistoryLength => _settings.History; public static long HistoryLength => _settings.History;
private static InternalProfile _profileInstance;
private static ProfilerSettings _settings;
public static bool ProfilingEnabled() public static bool ProfilingEnabled()
{ {
if (!_settings.Enabled) if (!_settings.Enabled)
@ -46,6 +46,13 @@ namespace Ryujinx.Profiler
_profileInstance.FlagTime(flagType); _profileInstance.FlagTime(flagType);
} }
public static void RegisterFlagReciever(Action<TimingFlag> reciever)
{
if (!ProfilingEnabled())
return;
_profileInstance.RegisterFlagReciever(reciever);
}
public static void Begin(ProfileConfig config) public static void Begin(ProfileConfig config)
{ {
if (!ProfilingEnabled()) if (!ProfilingEnabled())

View file

@ -98,6 +98,18 @@ namespace Ryujinx.Profiler.UI
Location = new Point(DisplayDevice.Default.Width - 1280, Location = new Point(DisplayDevice.Default.Width - 1280,
(DisplayDevice.Default.Height - 720) - 50); (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 // Large number to force an update on first update
_updateTimer = 0xFFFF; _updateTimer = 0xFFFF;
@ -218,7 +230,7 @@ namespace Ryujinx.Profiler.UI
// Get timing data if enough time has passed // Get timing data if enough time has passed
_updateTimer += e.Time; _updateTimer += e.Time;
if (_doStep || (!_paused && (_updateTimer > Profile.UpdateRate))) if (_doStep || ((Profile.UpdateRate > 0) && (!_paused && (_updateTimer > Profile.UpdateRate))))
{ {
_updateTimer = 0; _updateTimer = 0;
_unsortedProfileData = Profile.GetProfilingData().ToList(); _unsortedProfileData = Profile.GetProfilingData().ToList();

View file

@ -65,14 +65,14 @@ namespace Ryujinx
} }
} }
string profilePath = parser.Value("Profile_Dump_Path"); string profilePath = parser.Value("Profile_Dump_Path");
double updateRateHz = Convert.ToSingle(parser.Value("Profiling_Update_Rate"));
Profile.Configure(new ProfilerSettings() Profile.Configure(new ProfilerSettings()
{ {
Enabled = Convert.ToBoolean(parser.Value("Profiling_Enabled")), Enabled = Convert.ToBoolean(parser.Value("Profiling_Enabled")),
FileDumpEnabled = profilePath != "", FileDumpEnabled = profilePath != "",
DumpLocation = 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"))), History = Profile.ConvertSecondsToTicks(Convert.ToDouble(parser.Value("Profiling_History"))),
}); });