diff options
| author | TSR Berry <20988865+TSRBerry@users.noreply.github.com> | 2023-04-08 01:22:00 +0200 |
|---|---|---|
| committer | Mary <thog@protonmail.com> | 2023-04-27 23:51:14 +0200 |
| commit | cee712105850ac3385cd0091a923438167433f9f (patch) | |
| tree | 4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /Ryujinx.Graphics.OpenGL/Debugger.cs | |
| parent | cd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff) | |
Move solution and projects to src
Diffstat (limited to 'Ryujinx.Graphics.OpenGL/Debugger.cs')
| -rw-r--r-- | Ryujinx.Graphics.OpenGL/Debugger.cs | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Debugger.cs b/Ryujinx.Graphics.OpenGL/Debugger.cs deleted file mode 100644 index 9f67cfc6..00000000 --- a/Ryujinx.Graphics.OpenGL/Debugger.cs +++ /dev/null @@ -1,101 +0,0 @@ -using OpenTK.Graphics.OpenGL; -using Ryujinx.Common.Configuration; -using Ryujinx.Common.Logging; -using System; -using System.Runtime.InteropServices; -using System.Threading; - -namespace Ryujinx.Graphics.OpenGL -{ - public static class Debugger - { - private static DebugProc _debugCallback; - - private static int _counter; - - public static void Initialize(GraphicsDebugLevel logLevel) - { - // Disable everything - GL.DebugMessageControl(DebugSourceControl.DontCare, DebugTypeControl.DontCare, DebugSeverityControl.DontCare, 0, (int[])null, false); - - if (logLevel == GraphicsDebugLevel.None) - { - GL.Disable(EnableCap.DebugOutputSynchronous); - GL.DebugMessageCallback(null, IntPtr.Zero); - - return; - } - - GL.Enable(EnableCap.DebugOutputSynchronous); - - if (logLevel == GraphicsDebugLevel.Error) - { - GL.DebugMessageControl(DebugSourceControl.DontCare, DebugTypeControl.DebugTypeError, DebugSeverityControl.DontCare, 0, (int[])null, true); - } - else if (logLevel == GraphicsDebugLevel.Slowdowns) - { - GL.DebugMessageControl(DebugSourceControl.DontCare, DebugTypeControl.DebugTypeError, DebugSeverityControl.DontCare, 0, (int[])null, true); - GL.DebugMessageControl(DebugSourceControl.DontCare, DebugTypeControl.DebugTypePerformance, DebugSeverityControl.DontCare, 0, (int[])null, true); - } - else - { - GL.DebugMessageControl(DebugSourceControl.DontCare, DebugTypeControl.DontCare, DebugSeverityControl.DontCare, 0, (int[])null, true); - } - - _counter = 0; - _debugCallback = GLDebugHandler; - - GL.DebugMessageCallback(_debugCallback, IntPtr.Zero); - - Logger.Warning?.Print(LogClass.Gpu, "OpenGL Debugging is enabled. Performance will be negatively impacted."); - } - - private static void GLDebugHandler( - DebugSource source, - DebugType type, - int id, - DebugSeverity severity, - int length, - IntPtr message, - IntPtr userParam) - { - string msg = Marshal.PtrToStringUTF8(message).Replace('\n', ' '); - - switch (type) - { - case DebugType.DebugTypeError : Logger.Error?.Print(LogClass.Gpu, $"{severity}: {msg}\nCallStack={Environment.StackTrace}", "GLERROR"); break; - case DebugType.DebugTypePerformance: Logger.Warning?.Print(LogClass.Gpu, $"{severity}: {msg}", "GLPERF"); break; - case DebugType.DebugTypePushGroup : Logger.Info?.Print(LogClass.Gpu, $"{{ ({id}) {severity}: {msg}", "GLINFO"); break; - case DebugType.DebugTypePopGroup : Logger.Info?.Print(LogClass.Gpu, $"}} ({id}) {severity}: {msg}", "GLINFO"); break; - default: - if (source == DebugSource.DebugSourceApplication) - { - Logger.Info?.Print(LogClass.Gpu, $"{type} {severity}: {msg}", "GLINFO"); - } - else - { - Logger.Debug?.Print(LogClass.Gpu, $"{type} {severity}: {msg}", "GLDEBUG"); - } - break; - } - } - - // Useful debug helpers - public static void PushGroup(string dbgMsg) - { - int counter = Interlocked.Increment(ref _counter); - - GL.PushDebugGroup(DebugSourceExternal.DebugSourceApplication, counter, dbgMsg.Length, dbgMsg); - } - - public static void PopGroup() - { - GL.PopDebugGroup(); - } - - public static void Print(string dbgMsg, DebugType type = DebugType.DebugTypeMarker, DebugSeverity severity = DebugSeverity.DebugSeverityNotification, int id = 999999) - { - GL.DebugMessageInsert(DebugSourceExternal.DebugSourceApplication, type, id, severity, dbgMsg.Length, dbgMsg); - } - } -} |
