diff options
author | gdkchan <gab.dark.100@gmail.com> | 2019-12-28 20:45:33 -0300 |
---|---|---|
committer | Thog <thog@protonmail.com> | 2020-01-09 02:13:00 +0100 |
commit | af8498d6790ba83f1cf87eccf5f272f2ccbeb169 (patch) | |
tree | f4bbd0c418a056211f5077646100bedeb5e8fc13 /Ryujinx.Graphics.OpenGL/Debugger.cs | |
parent | d1ab9fb42c2fd9f018d4410ca619cd66294eafc9 (diff) |
Add basic error logging to the GPU
Diffstat (limited to 'Ryujinx.Graphics.OpenGL/Debugger.cs')
-rw-r--r-- | Ryujinx.Graphics.OpenGL/Debugger.cs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Debugger.cs b/Ryujinx.Graphics.OpenGL/Debugger.cs index 9da98ae1..ff9fcd85 100644 --- a/Ryujinx.Graphics.OpenGL/Debugger.cs +++ b/Ryujinx.Graphics.OpenGL/Debugger.cs @@ -1,4 +1,5 @@ using OpenTK.Graphics.OpenGL; +using Ryujinx.Common.Logging; using System; using System.Runtime.InteropServices; @@ -12,16 +13,14 @@ namespace Ryujinx.Graphics.OpenGL { GL.Enable(EnableCap.DebugOutputSynchronous); - int[] array = null; + GL.DebugMessageControl(DebugSourceControl.DontCare, DebugTypeControl.DontCare, DebugSeverityControl.DontCare, 0, (int[])null, true); - GL.DebugMessageControl(DebugSourceControl.DontCare, DebugTypeControl.DontCare, DebugSeverityControl.DontCare, 0, array, true); - - _debugCallback = PrintDbg; + _debugCallback = GLDebugHandler; GL.DebugMessageCallback(_debugCallback, IntPtr.Zero); } - private static void PrintDbg( + private static void GLDebugHandler( DebugSource source, DebugType type, int id, @@ -30,14 +29,20 @@ namespace Ryujinx.Graphics.OpenGL IntPtr message, IntPtr userParam) { - string msg = Marshal.PtrToStringAnsi(message); + string fullMessage = $"{type} {severity} {source} {Marshal.PtrToStringAnsi(message)}"; - if (type == DebugType.DebugTypeError && !msg.Contains("link")) + switch (type) { - throw new Exception(msg); + case DebugType.DebugTypeError: + Logger.PrintError(LogClass.Gpu, fullMessage); + break; + case DebugType.DebugTypePerformance: + Logger.PrintWarning(LogClass.Gpu, fullMessage); + break; + default: + Logger.PrintDebug(LogClass.Gpu, fullMessage); + break; } - - System.Console.WriteLine("GL message: " + source + " " + type + " " + severity + " " + msg); } } } |