Added support for timing flags
This commit is contained in:
parent
a6dec90b29
commit
9f3b0cd1ef
5 changed files with 84 additions and 3 deletions
|
@ -22,8 +22,16 @@ namespace Ryujinx.Profiler
|
|||
private bool _cleanupRunning;
|
||||
private readonly long _history;
|
||||
|
||||
// Timing flags
|
||||
private TimingFlag[] _timingFlags;
|
||||
private int _timingFlagCount;
|
||||
private int _timingFlagIndex;
|
||||
|
||||
private const int MaxFlags = 50;
|
||||
|
||||
public InternalProfile(long history)
|
||||
{
|
||||
_timingFlags = new TimingFlag[MaxFlags];
|
||||
Timers = new ConcurrentDictionary<ProfileConfig, TimingInfo>();
|
||||
_history = history;
|
||||
_cleanupRunning = true;
|
||||
|
@ -53,6 +61,20 @@ namespace Ryujinx.Profiler
|
|||
}
|
||||
}
|
||||
|
||||
public void FlagTime(TimingFlagType flagType)
|
||||
{
|
||||
_timingFlags[_timingFlagIndex] = new TimingFlag()
|
||||
{
|
||||
FlagType = flagType,
|
||||
Timestamp = SW.ElapsedTicks
|
||||
};
|
||||
|
||||
if (++_timingFlagIndex >= MaxFlags)
|
||||
_timingFlagIndex = 0;
|
||||
|
||||
_timingFlagCount = Math.Max(_timingFlagCount + 1, MaxFlags);
|
||||
}
|
||||
|
||||
public void BeginProfile(ProfileConfig config)
|
||||
{
|
||||
Timers.GetOrAdd(config, profileConfig => new TimingInfo()).Begin(SW.ElapsedTicks);
|
||||
|
@ -108,6 +130,21 @@ namespace Ryujinx.Profiler
|
|||
return outDict;
|
||||
}
|
||||
|
||||
public TimingFlag[] GetTimingFlags()
|
||||
{
|
||||
int count = Math.Max(_timingFlagCount, MaxFlags);
|
||||
TimingFlag[] outFlags = new TimingFlag[count];
|
||||
|
||||
for (int i = 0, sourceIndex = _timingFlagIndex; i < count; i++, sourceIndex++)
|
||||
{
|
||||
if (sourceIndex >= MaxFlags)
|
||||
sourceIndex = 0;
|
||||
outFlags[i] = _timingFlags[sourceIndex];
|
||||
}
|
||||
|
||||
return outFlags;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_cleanupRunning = false;
|
||||
|
|
|
@ -39,6 +39,13 @@ namespace Ryujinx.Profiler
|
|||
_profileInstance.Dispose();
|
||||
}
|
||||
|
||||
public static void FlagTime(TimingFlagType flagType)
|
||||
{
|
||||
if (!ProfilingEnabled())
|
||||
return;
|
||||
_profileInstance.FlagTime(flagType);
|
||||
}
|
||||
|
||||
public static void Begin(ProfileConfig config)
|
||||
{
|
||||
if (!ProfilingEnabled())
|
||||
|
@ -96,7 +103,12 @@ namespace Ryujinx.Profiler
|
|||
return _profileInstance.GetProfilingData();
|
||||
}
|
||||
|
||||
|
||||
public static TimingFlag[] GetTimingFlags()
|
||||
{
|
||||
if (!ProfilingEnabled())
|
||||
return new TimingFlag[0];
|
||||
return _profileInstance.GetTimingFlags();
|
||||
}
|
||||
|
||||
public static long GetCurrentTime()
|
||||
{
|
||||
|
|
17
Ryujinx.Profiler/TimingFlag.cs
Normal file
17
Ryujinx.Profiler/TimingFlag.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.Profiler
|
||||
{
|
||||
public enum TimingFlagType
|
||||
{
|
||||
FrameSwap,
|
||||
}
|
||||
|
||||
public struct TimingFlag
|
||||
{
|
||||
public TimingFlagType FlagType;
|
||||
public long Timestamp;
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ namespace Ryujinx.Profiler.UI
|
|||
{
|
||||
public partial class ProfileWindow
|
||||
{
|
||||
private const float GraphMoveSpeed = 20000;
|
||||
private const float GraphZoomSpeed = 10;
|
||||
private const float GraphMoveSpeed = 40000;
|
||||
private const float GraphZoomSpeed = 50;
|
||||
|
||||
private float _graphZoom = 1;
|
||||
private float _graphPosition = 0;
|
||||
|
@ -32,7 +32,20 @@ namespace Ryujinx.Profiler.UI
|
|||
_graphPosition = (float)Profile.ConvertTicksToMS(graphPositionTicks);
|
||||
}
|
||||
|
||||
// Draw timing flags
|
||||
TimingFlag[] timingFlags = Profile.GetTimingFlags();
|
||||
GL.Enable(EnableCap.ScissorTest);
|
||||
GL.Color3(Color.Gray);
|
||||
GL.Begin(PrimitiveType.Lines);
|
||||
foreach (TimingFlag timingFlag in timingFlags)
|
||||
{
|
||||
int x = (int)(xOffset + width - ((float)(_captureTime - (timingFlag.Timestamp + graphPositionTicks)) / timeWidthTicks) * width);
|
||||
GL.Vertex2(x, 0);
|
||||
GL.Vertex2(x, Height);
|
||||
}
|
||||
GL.End();
|
||||
|
||||
// Draw bars
|
||||
GL.Begin(PrimitiveType.Triangles);
|
||||
foreach (var entry in _sortedProfileData)
|
||||
{
|
||||
|
|
|
@ -277,6 +277,8 @@ namespace Ryujinx
|
|||
_device.System.SignalVsync();
|
||||
|
||||
_device.VsyncEvent.Set();
|
||||
|
||||
Profile.FlagTime(TimingFlagType.FrameSwap);
|
||||
}
|
||||
|
||||
protected override void OnUnload(EventArgs e)
|
||||
|
|
Loading…
Add table
Reference in a new issue