Display some actual timing data
This commit is contained in:
parent
e550889328
commit
f20a449c78
4 changed files with 64 additions and 8 deletions
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace Ryujinx.Profiler
|
||||
{
|
||||
|
@ -73,5 +75,20 @@ namespace Ryujinx.Profiler
|
|||
return (sessionCounter++).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<ProfileConfig, TimingInfo> GetProfilingData()
|
||||
{
|
||||
// Forcibly get copy so user doesn't block profiling
|
||||
ProfileConfig[] configs = Timers.Keys.ToArray();
|
||||
TimingInfo[] times = Timers.Values.ToArray();
|
||||
Dictionary<ProfileConfig, TimingInfo> outDict = new Dictionary<ProfileConfig, TimingInfo>();
|
||||
|
||||
for (int i = 0; i < configs.Length; i++)
|
||||
{
|
||||
outDict.Add(configs[i], times[i]);
|
||||
}
|
||||
|
||||
return outDict;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Profiler
|
||||
{
|
||||
|
@ -63,5 +64,12 @@ namespace Ryujinx.Profiler
|
|||
return null;
|
||||
return ProfileInstance.GetSession();
|
||||
}
|
||||
|
||||
public static Dictionary<ProfileConfig, TimingInfo> GetProfilingData()
|
||||
{
|
||||
if (!ProfilingEnabled())
|
||||
return new Dictionary<ProfileConfig, TimingInfo>();
|
||||
return ProfileInstance.GetProfilingData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Ryujinx.Profiler;
|
||||
using Ryujinx.Profiler.UI.SharpFontHelpers;
|
||||
|
||||
namespace Ryujinx
|
||||
{
|
||||
public class ProfileWindow : GameWindow
|
||||
{
|
||||
private bool visible = true;
|
||||
private bool visible = true, initComplete = false;
|
||||
public bool visibleChanged;
|
||||
private FontService fontService;
|
||||
private Dictionary<ProfileConfig, TimingInfo> profileData;
|
||||
|
||||
public ProfileWindow()
|
||||
: base(400, 720)
|
||||
|
@ -78,7 +81,8 @@ namespace Ryujinx
|
|||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
// Nothing to do!
|
||||
initComplete = true;
|
||||
profileData = Profile.GetProfilingData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -96,18 +100,40 @@ namespace Ryujinx
|
|||
visibleChanged = false;
|
||||
}
|
||||
|
||||
if (!visible)
|
||||
if (!visible || !initComplete)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
|
||||
GL.ClearColor(Color.White);
|
||||
fontService.fontColor = Color.Black;
|
||||
fontService.DrawText("This is a test", 50, 50, 32);
|
||||
GL.ClearColor(Color.Black);
|
||||
fontService.fontColor = Color.White;
|
||||
int verticalIndex = 0;
|
||||
int lineHeight = 12;
|
||||
|
||||
this.SwapBuffers();
|
||||
float maxWidth = 0;
|
||||
|
||||
foreach (var entry in profileData)
|
||||
{
|
||||
float y = Height - (lineHeight + 2) * (verticalIndex++ + 1);
|
||||
float width = fontService.DrawText(entry.Key.Tag, 50, y, lineHeight);
|
||||
if (width > maxWidth)
|
||||
{
|
||||
maxWidth = width;
|
||||
}
|
||||
}
|
||||
|
||||
verticalIndex = 0;
|
||||
|
||||
foreach (var entry in profileData)
|
||||
{
|
||||
float y = Height - (lineHeight + 2) * (verticalIndex++ + 1);
|
||||
fontService.DrawText($"{entry.Value.AverageTime:F3}", 75 + maxWidth, y, lineHeight);
|
||||
fontService.DrawText($"{entry.Value.LastTime:F3}", 175 + maxWidth, y, lineHeight);
|
||||
}
|
||||
|
||||
SwapBuffers();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -68,8 +68,10 @@ namespace Ryujinx.Profiler.UI.SharpFontHelpers
|
|||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
|
||||
public void DrawText(string text, float x, float y, float height)
|
||||
public float DrawText(string text, float x, float y, float height)
|
||||
{
|
||||
float originalX = x;
|
||||
|
||||
// Use font map texture
|
||||
GL.BindTexture(TextureTarget.Texture2D, characterTextureSheet);
|
||||
|
||||
|
@ -102,6 +104,9 @@ namespace Ryujinx.Profiler.UI.SharpFontHelpers
|
|||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
GL.Disable(EnableCap.Texture2D);
|
||||
GL.Disable(EnableCap.Blend);
|
||||
|
||||
// Return width of rendered text
|
||||
return x - originalX;
|
||||
}
|
||||
|
||||
private void DrawChar(CharacterInfo charInfo, float left, float right, float top, float bottom)
|
||||
|
|
Loading…
Add table
Reference in a new issue