From ad6e7a0be15cf6c47635987a04cd5824fb5de054 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Mon, 15 Aug 2016 04:00:59 -0400 Subject: OpenGL: backtrace on errors (--debug-gpu) Backtrace so we can pinpoint where the GL error came from. Then fflush on severe errors in case it's severe enough to crash Blender. --- source/blender/gpu/intern/gpu_debug.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source/blender/gpu') diff --git a/source/blender/gpu/intern/gpu_debug.c b/source/blender/gpu/intern/gpu_debug.c index 555af8b087a..21458a22221 100644 --- a/source/blender/gpu/intern/gpu_debug.c +++ b/source/blender/gpu/intern/gpu_debug.c @@ -207,13 +207,21 @@ static void APIENTRY gpu_debug_proc( GLenum severity, GLsizei UNUSED(length), const GLchar *message, const GLvoid *UNUSED(userParm)) { + bool backtrace = false; + switch (severity) { case GL_DEBUG_SEVERITY_HIGH: + backtrace = true; + /* fall through */ case GL_DEBUG_SEVERITY_MEDIUM: case GL_DEBUG_SEVERITY_LOW: case GL_DEBUG_SEVERITY_NOTIFICATION: /* KHR has this, ARB does not */ fprintf(stderr, "GL %s %s: %s\n", source_name(source), message_type_name(type), message); - fflush(stderr); + } + + if (backtrace) { + BLI_system_backtrace(stderr); + fflush(stderr); } } @@ -224,12 +232,20 @@ static void APIENTRY gpu_debug_proc_amd( GLenum severity, GLsizei UNUSED(length), const GLchar *message, GLvoid *UNUSED(userParm)) { + bool backtrace = false; + switch (severity) { case GL_DEBUG_SEVERITY_HIGH: + backtrace = true; + /* fall through */ case GL_DEBUG_SEVERITY_MEDIUM: case GL_DEBUG_SEVERITY_LOW: fprintf(stderr, "GL %s: %s\n", category_name_amd(category), message); - fflush(stderr); + } + + if (backtrace) { + BLI_system_backtrace(stderr); + fflush(stderr); } } #endif -- cgit v1.2.3