This should help people debugging when glamor does something stupid on their driver.
Signed-off-by: Eric Anholt <[email protected]> --- glamor/glamor.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/glamor/glamor.c b/glamor/glamor.c index 295f415..317f451 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -322,6 +322,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) @@ -468,6 +507,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); + glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glamor_priv->max_fbo_size); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glamor_priv->max_fbo_size); glGetIntegerv(GL_MAX_VIEWPORT_DIMS, max_viewport_size); -- 2.1.4 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
