summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index c14bdb8ab..c34215340 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -394,6 +394,58 @@ void RendererOpenGL::SetWindow(EmuWindow* window) {
render_window = window;
}
+static const char* GetSource(GLenum source) {
+#define RET(s) case GL_DEBUG_SOURCE_##s: return #s
+ switch (source) {
+ RET(API);
+ RET(WINDOW_SYSTEM);
+ RET(SHADER_COMPILER);
+ RET(THIRD_PARTY);
+ RET(APPLICATION);
+ RET(OTHER);
+ default:
+ UNREACHABLE();
+ }
+#undef RET
+}
+
+static const char* GetType(GLenum type) {
+#define RET(t) case GL_DEBUG_TYPE_##t: return #t
+ switch (type) {
+ RET(ERROR);
+ RET(DEPRECATED_BEHAVIOR);
+ RET(UNDEFINED_BEHAVIOR);
+ RET(PORTABILITY);
+ RET(PERFORMANCE);
+ RET(OTHER);
+ RET(MARKER);
+ default:
+ UNREACHABLE();
+ }
+#undef RET
+}
+
+static void DebugHandler(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
+ const GLchar* message, const void* user_param) {
+ Log::Level level;
+ switch (severity) {
+ case GL_DEBUG_SEVERITY_HIGH:
+ level = Log::Level::Error;
+ break;
+ case GL_DEBUG_SEVERITY_MEDIUM:
+ level = Log::Level::Warning;
+ break;
+ case GL_DEBUG_SEVERITY_NOTIFICATION:
+ level = Log::Level::Info;
+ break;
+ case GL_DEBUG_SEVERITY_LOW:
+ level = Log::Level::Debug;
+ break;
+ }
+ LOG_GENERIC(Log::Class::Render_OpenGL, level, "%s %s %d: %s",
+ GetSource(source), GetType(type), id, message);
+}
+
/// Initialize the renderer
void RendererOpenGL::Init() {
render_window->MakeCurrent();
@@ -404,6 +456,11 @@ void RendererOpenGL::Init() {
exit(-1);
}
+ if (GLAD_GL_KHR_debug) {
+ glEnable(GL_DEBUG_OUTPUT);
+ glDebugMessageCallback(DebugHandler, nullptr);
+ }
+
LOG_INFO(Render_OpenGL, "GL_VERSION: %s", glGetString(GL_VERSION));
LOG_INFO(Render_OpenGL, "GL_VENDOR: %s", glGetString(GL_VENDOR));
LOG_INFO(Render_OpenGL, "GL_RENDERER: %s", glGetString(GL_RENDERER));