2019-10-13 02:02:07 -04:00
|
|
|
using OpenTK.Graphics.OpenGL;
|
2019-12-28 18:45:33 -05:00
|
|
|
using Ryujinx.Common.Logging;
|
2019-10-13 02:02:07 -04:00
|
|
|
using System;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.OpenGL
|
|
|
|
{
|
|
|
|
public static class Debugger
|
|
|
|
{
|
|
|
|
private static DebugProc _debugCallback;
|
|
|
|
|
|
|
|
public static void Initialize()
|
|
|
|
{
|
|
|
|
GL.Enable(EnableCap.DebugOutputSynchronous);
|
|
|
|
|
2019-12-28 18:45:33 -05:00
|
|
|
GL.DebugMessageControl(DebugSourceControl.DontCare, DebugTypeControl.DontCare, DebugSeverityControl.DontCare, 0, (int[])null, true);
|
2019-10-13 02:02:07 -04:00
|
|
|
|
2019-12-28 18:45:33 -05:00
|
|
|
_debugCallback = GLDebugHandler;
|
2019-10-13 02:02:07 -04:00
|
|
|
|
|
|
|
GL.DebugMessageCallback(_debugCallback, IntPtr.Zero);
|
|
|
|
}
|
|
|
|
|
2019-12-28 18:45:33 -05:00
|
|
|
private static void GLDebugHandler(
|
2019-10-13 02:02:07 -04:00
|
|
|
DebugSource source,
|
|
|
|
DebugType type,
|
|
|
|
int id,
|
|
|
|
DebugSeverity severity,
|
|
|
|
int length,
|
|
|
|
IntPtr message,
|
|
|
|
IntPtr userParam)
|
|
|
|
{
|
2019-12-28 18:45:33 -05:00
|
|
|
string fullMessage = $"{type} {severity} {source} {Marshal.PtrToStringAnsi(message)}";
|
2019-10-13 02:02:07 -04:00
|
|
|
|
2019-12-28 18:45:33 -05:00
|
|
|
switch (type)
|
2019-10-13 02:02:07 -04:00
|
|
|
{
|
2019-12-28 18:45:33 -05:00
|
|
|
case DebugType.DebugTypeError:
|
2019-12-30 12:47:20 -05:00
|
|
|
Logger.PrintDebug(LogClass.Gpu, fullMessage);
|
2019-12-28 18:45:33 -05:00
|
|
|
break;
|
|
|
|
case DebugType.DebugTypePerformance:
|
|
|
|
Logger.PrintWarning(LogClass.Gpu, fullMessage);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Logger.PrintDebug(LogClass.Gpu, fullMessage);
|
|
|
|
break;
|
2019-10-13 02:02:07 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|