Ryujinx/Ryujinx.Graphics.OpenGL/Debugger.cs
gdkchan b18ef8e3a0
Workaround for AMD and Intel view format bug (#1050)
* Workaround for Intel view format bug

* Dispose of the intermmediate texture aswell

* Apply workaround on AMD aswell
2020-03-29 23:48:39 +11:00

48 lines
1.4 KiB
C#

using OpenTK.Graphics.OpenGL;
using Ryujinx.Common.Logging;
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);
GL.DebugMessageControl(DebugSourceControl.DontCare, DebugTypeControl.DontCare, DebugSeverityControl.DontCare, 0, (int[])null, true);
_debugCallback = GLDebugHandler;
GL.DebugMessageCallback(_debugCallback, IntPtr.Zero);
}
private static void GLDebugHandler(
DebugSource source,
DebugType type,
int id,
DebugSeverity severity,
int length,
IntPtr message,
IntPtr userParam)
{
string fullMessage = $"{type} {severity} {source} {Marshal.PtrToStringAnsi(message)}";
switch (type)
{
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;
}
}
}
}