summaryrefslogtreecommitdiff
path: root/glamor
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2015-07-01 16:23:45 -0700
committerEric Anholt <eric@anholt.net>2015-07-06 12:01:33 -0700
commit3703c88ac18063a35fd8c0fc52fee52d8c669638 (patch)
tree2931a5a5cea9d2470fb2d5ea42ebab6943befe87 /glamor
parentf4dfd282d311e5f23631d33e0251bad1854b1ab9 (diff)
glamor: Use GL_ARB_debug_output to log GL errors.
This should help people debugging when glamor does something stupid on their driver. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Diffstat (limited to 'glamor')
-rw-r--r--glamor/glamor.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 702efd120..50d85ff22 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -384,6 +384,45 @@ glamor_check_instruction_count(int gl_version)
return TRUE;
}
+static void GLAPIENTRY
+glamor_debug_output_callback(GLenum source,
+ GLenum type,
+ GLuint id,
+ GLenum severity,
+ GLsizei length,
+ const GLchar *message,
+ const void *userParam)
+{
+ ScreenPtr screen = (void *)userParam;
+ LogMessageVerb(X_ERROR, 0, "glamor%d: GL error: %*s\n",
+ screen->myNum, length, message);
+}
+
+/**
+ * Configures GL_ARB_debug_output to give us immediate callbacks when
+ * GL errors occur, so that we can log them.
+ */
+static void
+glamor_setup_debug_output(ScreenPtr screen)
+{
+ if (!epoxy_has_gl_extension("GL_ARB_debug_output"))
+ return;
+
+ glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
+ glDebugMessageControl(GL_DEBUG_SOURCE_API,
+ GL_DEBUG_TYPE_ERROR,
+ GL_DONT_CARE,
+ 0, NULL, GL_TRUE);
+ glDebugMessageCallback(glamor_debug_output_callback,
+ screen);
+
+ /* If KHR_debug is present, all debug output is disabled by
+ * default on non-debug contexts.
+ */
+ if (epoxy_has_gl_extension("GL_KHR_debug"))
+ glEnable(GL_DEBUG_OUTPUT);
+}
+
/** Set up glamor for an already-configured GL context. */
Bool
glamor_init(ScreenPtr screen, unsigned int flags)
@@ -531,6 +570,8 @@ glamor_init(ScreenPtr screen, unsigned int flags)
epoxy_gl_version() >= 30 ||
epoxy_has_gl_extension("GL_NV_pack_subimage");
+ glamor_setup_debug_output(screen);
+
glamor_priv->use_quads = (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
/* Driver-specific hack: Avoid using GL_QUADS on VC4, where
* they'll be emulated more expensively than we can with our