2019-10-12 23:02:07 -07:00
|
|
|
using OpenTK.Graphics.OpenGL;
|
2019-12-28 15:45:33 -08:00
|
|
|
using Ryujinx.Common.Logging;
|
2019-10-12 23:02:07 -07: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 15:45:33 -08:00
|
|
|
GL.DebugMessageControl(DebugSourceControl.DontCare, DebugTypeControl.DontCare, DebugSeverityControl.DontCare, 0, (int[])null, true);
|
2019-10-12 23:02:07 -07:00
|
|
|
|
2019-12-28 15:45:33 -08:00
|
|
|
_debugCallback = GLDebugHandler;
|
2019-10-12 23:02:07 -07:00
|
|
|
|
|
|
|
GL.DebugMessageCallback(_debugCallback, IntPtr.Zero);
|
|
|
|
}
|
|
|
|
|
2019-12-28 15:45:33 -08:00
|
|
|
private static void GLDebugHandler(
|
2019-10-12 23:02:07 -07:00
|
|
|
DebugSource source,
|
|
|
|
DebugType type,
|
|
|
|
int id,
|
|
|
|
DebugSeverity severity,
|
|
|
|
int length,
|
|
|
|
IntPtr message,
|
|
|
|
IntPtr userParam)
|
|
|
|
{
|
2019-12-28 15:45:33 -08:00
|
|
|
string fullMessage = $"{type} {severity} {source} {Marshal.PtrToStringAnsi(message)}";
|
2019-10-12 23:02:07 -07:00
|
|
|
|
2019-12-28 15:45:33 -08:00
|
|
|
switch (type)
|
2019-10-12 23:02:07 -07:00
|
|
|
{
|
2019-12-28 15:45:33 -08:00
|
|
|
case DebugType.DebugTypeError:
|
2019-12-30 09:47:20 -08:00
|
|
|
Logger.PrintDebug(LogClass.Gpu, fullMessage);
|
2019-12-28 15:45:33 -08:00
|
|
|
break;
|
|
|
|
case DebugType.DebugTypePerformance:
|
|
|
|
Logger.PrintWarning(LogClass.Gpu, fullMessage);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Logger.PrintDebug(LogClass.Gpu, fullMessage);
|
|
|
|
break;
|
2019-10-12 23:02:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|