enable and disable flags button added
better fix for race crash
This commit is contained in:
parent
4df550ab79
commit
6ecb6cfd86
4 changed files with 67 additions and 42 deletions
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
|
@ -178,18 +179,15 @@ namespace Ryujinx.Profiler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<ProfileConfig, TimingInfo> GetProfilingData()
|
public List<KeyValuePair<ProfileConfig, TimingInfo>> GetProfilingData()
|
||||||
{
|
{
|
||||||
_preserve = PerformanceCounter.ElapsedTicks;
|
_preserve = PerformanceCounter.ElapsedTicks;
|
||||||
|
|
||||||
// Skip clearing queue if already clearing
|
lock (_timerQueueClearLock)
|
||||||
if (Monitor.TryEnter(_timerQueueClearLock))
|
|
||||||
{
|
{
|
||||||
ClearTimerQueue();
|
ClearTimerQueue();
|
||||||
Monitor.Exit(_timerQueueClearLock);
|
return Timers.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Timers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimingFlag[] GetTimingFlags()
|
public TimingFlag[] GetTimingFlags()
|
||||||
|
|
|
@ -107,14 +107,14 @@ namespace Ryujinx.Profiler
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<ProfileConfig, TimingInfo> GetProfilingData()
|
public static List<KeyValuePair<ProfileConfig, TimingInfo>> GetProfilingData()
|
||||||
{
|
{
|
||||||
#if USE_PROFILING
|
#if USE_PROFILING
|
||||||
if (!ProfilingEnabled())
|
if (!ProfilingEnabled())
|
||||||
return new Dictionary<ProfileConfig, TimingInfo>();
|
return new List<KeyValuePair<ProfileConfig, TimingInfo>>();
|
||||||
return _profileInstance.GetProfilingData();
|
return _profileInstance.GetProfilingData();
|
||||||
#else
|
#else
|
||||||
return new Dictionary<ProfileConfig, TimingInfo>();
|
return new List<KeyValuePair<ProfileConfig, TimingInfo>>();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,11 @@ namespace Ryujinx.Profiler.UI
|
||||||
ChangeDisplay = 7,
|
ChangeDisplay = 7,
|
||||||
|
|
||||||
// Don't automatically draw after here
|
// Don't automatically draw after here
|
||||||
Step = 8,
|
ToggleFlags = 8,
|
||||||
|
Step = 9,
|
||||||
|
|
||||||
// Update this when new buttons are added
|
// Update this when new buttons are added
|
||||||
Count = 9,
|
Count = 10,
|
||||||
Autodraw = 8,
|
Autodraw = 8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ namespace Ryujinx.Profiler.UI
|
||||||
private bool _viewportUpdated = true;
|
private bool _viewportUpdated = true;
|
||||||
private bool _redrawPending = true;
|
private bool _redrawPending = true;
|
||||||
private bool _displayGraph = true;
|
private bool _displayGraph = true;
|
||||||
|
private bool _displayFlags = true;
|
||||||
private bool _showInactive = true;
|
private bool _showInactive = true;
|
||||||
private bool _paused = false;
|
private bool _paused = false;
|
||||||
private bool _doStep = false;
|
private bool _doStep = false;
|
||||||
|
@ -151,7 +153,6 @@ namespace Ryujinx.Profiler.UI
|
||||||
_buttons[(int)ButtonIndex.InstantTitle] = new ProfileButton(_fontService, () => SetSort(new ProfileSorters.InstantAscending()));
|
_buttons[(int)ButtonIndex.InstantTitle] = new ProfileButton(_fontService, () => SetSort(new ProfileSorters.InstantAscending()));
|
||||||
_buttons[(int)ButtonIndex.AverageTitle] = new ProfileButton(_fontService, () => SetSort(new ProfileSorters.AverageAscending()));
|
_buttons[(int)ButtonIndex.AverageTitle] = new ProfileButton(_fontService, () => SetSort(new ProfileSorters.AverageAscending()));
|
||||||
_buttons[(int)ButtonIndex.TotalTitle] = new ProfileButton(_fontService, () => SetSort(new ProfileSorters.TotalAscending()));
|
_buttons[(int)ButtonIndex.TotalTitle] = new ProfileButton(_fontService, () => SetSort(new ProfileSorters.TotalAscending()));
|
||||||
_buttons[(int)ButtonIndex.ChangeDisplay] = new ProfileButton(_fontService, () => _displayGraph = !_displayGraph);
|
|
||||||
_buttons[(int)ButtonIndex.Step] = new ProfileButton(_fontService, () => _doStep = true);
|
_buttons[(int)ButtonIndex.Step] = new ProfileButton(_fontService, () => _doStep = true);
|
||||||
_buttons[(int)ButtonIndex.FilterBar] = new ProfileButton(_fontService, () =>
|
_buttons[(int)ButtonIndex.FilterBar] = new ProfileButton(_fontService, () =>
|
||||||
{
|
{
|
||||||
|
@ -171,6 +172,18 @@ namespace Ryujinx.Profiler.UI
|
||||||
_paused = !_paused;
|
_paused = !_paused;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_buttons[(int)ButtonIndex.ToggleFlags] = new ProfileButton(_fontService, () =>
|
||||||
|
{
|
||||||
|
_displayFlags = !_displayFlags;
|
||||||
|
_redrawPending = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
_buttons[(int)ButtonIndex.ChangeDisplay] = new ProfileButton(_fontService, () =>
|
||||||
|
{
|
||||||
|
_displayGraph = !_displayGraph;
|
||||||
|
_redrawPending = true;
|
||||||
|
});
|
||||||
|
|
||||||
Visible = _visible;
|
Visible = _visible;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -246,14 +259,11 @@ namespace Ryujinx.Profiler.UI
|
||||||
_captureTime = PerformanceCounter.ElapsedTicks;
|
_captureTime = PerformanceCounter.ElapsedTicks;
|
||||||
_timingFlags = Profile.GetTimingFlags();
|
_timingFlags = Profile.GetTimingFlags();
|
||||||
_doStep = false;
|
_doStep = false;
|
||||||
|
|
||||||
Dictionary<ProfileConfig, TimingInfo> data = Profile.GetProfilingData();
|
|
||||||
if (data.Count > 0)
|
|
||||||
{
|
|
||||||
(_timingFlagsAverages, _timingFlagsLast) = Profile.GetTimingAveragesAndLast();
|
|
||||||
_unsortedProfileData = data.ToList();
|
|
||||||
_profileUpdated = true;
|
_profileUpdated = true;
|
||||||
}
|
|
||||||
|
_unsortedProfileData = Profile.GetProfilingData();
|
||||||
|
(_timingFlagsAverages, _timingFlagsLast) = Profile.GetTimingAveragesAndLast();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filtering
|
// Filtering
|
||||||
|
@ -593,7 +603,15 @@ namespace Ryujinx.Profiler.UI
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change display
|
// Change display
|
||||||
width = _buttons[(int)ButtonIndex.ChangeDisplay].UpdateSize($"View: {(_displayGraph ? "Graph" : "Bars")}", 25 + (int)widthStepButton, 5, 4, 16) + widthStepButton;
|
float widthChangeDisplay = _buttons[(int)ButtonIndex.ChangeDisplay].UpdateSize($"View: {(_displayGraph ? "Graph" : "Bars")}", 25 + (int)widthStepButton, 5, 4, 16) + widthStepButton;
|
||||||
|
|
||||||
|
width = widthChangeDisplay;
|
||||||
|
|
||||||
|
if (_displayGraph)
|
||||||
|
{
|
||||||
|
width += _buttons[(int) ButtonIndex.ToggleFlags].UpdateSize($"{(_displayFlags ? "Hide" : "Show")} Flags", 35 + (int)widthChangeDisplay, 5, 4, 16) + 10;
|
||||||
|
_buttons[(int)ButtonIndex.ToggleFlags].Draw();
|
||||||
|
}
|
||||||
|
|
||||||
// Filter bar
|
// Filter bar
|
||||||
_fontService.DrawText($"{(_regexEnabled ? "Regex " : "Filter")}: {_filterText}", 35 + width, 7, 16);
|
_fontService.DrawText($"{(_regexEnabled ? "Regex " : "Filter")}: {_filterText}", 35 + width, 7, 16);
|
||||||
|
@ -634,6 +652,12 @@ namespace Ryujinx.Profiler.UI
|
||||||
GL.Vertex2(widthStepButton + 20, FilterHeight);
|
GL.Vertex2(widthStepButton + 20, FilterHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_displayGraph)
|
||||||
|
{
|
||||||
|
GL.Vertex2(widthChangeDisplay + 30, 0);
|
||||||
|
GL.Vertex2(widthChangeDisplay + 30, FilterHeight);
|
||||||
|
}
|
||||||
|
|
||||||
GL.Vertex2(width + 30, 0);
|
GL.Vertex2(width + 30, 0);
|
||||||
GL.Vertex2(width + 30, FilterHeight);
|
GL.Vertex2(width + 30, FilterHeight);
|
||||||
|
|
||||||
|
@ -643,7 +667,6 @@ namespace Ryujinx.Profiler.UI
|
||||||
GL.Vertex2(timingDataLeft, FilterHeight);
|
GL.Vertex2(timingDataLeft, FilterHeight);
|
||||||
GL.Vertex2(timingDataLeft, timingDataTop);
|
GL.Vertex2(timingDataLeft, timingDataTop);
|
||||||
|
|
||||||
|
|
||||||
GL.Vertex2(timingWidth + timingDataLeft, FilterHeight);
|
GL.Vertex2(timingWidth + timingDataLeft, FilterHeight);
|
||||||
GL.Vertex2(timingWidth + timingDataLeft, timingDataTop);
|
GL.Vertex2(timingWidth + timingDataLeft, timingDataTop);
|
||||||
GL.End();
|
GL.End();
|
||||||
|
|
|
@ -46,10 +46,13 @@ namespace Ryujinx.Profiler.UI
|
||||||
|
|
||||||
graphPositionTicks = _captureTime - graphPositionTicks;
|
graphPositionTicks = _captureTime - graphPositionTicks;
|
||||||
|
|
||||||
|
GL.Enable(EnableCap.ScissorTest);
|
||||||
|
|
||||||
// Draw timing flags
|
// Draw timing flags
|
||||||
|
if (_displayFlags)
|
||||||
|
{
|
||||||
TimingFlagType prevType = TimingFlagType.Count;
|
TimingFlagType prevType = TimingFlagType.Count;
|
||||||
|
|
||||||
GL.Enable(EnableCap.ScissorTest);
|
|
||||||
GL.Enable(EnableCap.Blend);
|
GL.Enable(EnableCap.Blend);
|
||||||
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
|
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
|
||||||
|
|
||||||
|
@ -68,6 +71,7 @@ namespace Ryujinx.Profiler.UI
|
||||||
}
|
}
|
||||||
GL.End();
|
GL.End();
|
||||||
GL.Disable(EnableCap.Blend);
|
GL.Disable(EnableCap.Blend);
|
||||||
|
}
|
||||||
|
|
||||||
// Draw bars
|
// Draw bars
|
||||||
GL.Begin(PrimitiveType.Triangles);
|
GL.Begin(PrimitiveType.Triangles);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue