From c93789f5e9a7db66196ea66addabc9b5fd32fc2f Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Wed, 9 Jan 2019 21:58:16 +0000 Subject: [PATCH] Enable the glStringMarker logger when available glStringMarker is usually only available when running under some kind of GL debugger, and can be used to insert strings into the GL command string. Writing logs using it can be useful, since it lets us correspond GL calls with what happens in compton. More info about the extension can be found here: https://www.khronos.org/registry/OpenGL/extensions/GREMEDY/GREMEDY_string_marker.txt Signed-off-by: Yuxuan Shui --- src/compton.c | 8 ++++++++ src/log.c | 6 +++++- src/opengl.c | 2 +- src/opengl.h | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/compton.c b/src/compton.c index d6ca66ac..c610bd40 100644 --- a/src/compton.c +++ b/src/compton.c @@ -2953,6 +2953,14 @@ session_init(session_t *ps_old, int argc, char **argv) { exit(0); } + if (bkend_use_glx(ps)) { + auto glx_logger = glx_string_marker_logger_new(); + if (glx_logger) { + log_info("Enabling gl string marker"); + log_add_target_tls(glx_logger); + } + } + // Initialize software optimization if (ps->o.sw_opti) ps->o.sw_opti = swopti_init(ps); diff --git a/src/log.c b/src/log.c index 3d5ac5b9..5ff700fc 100644 --- a/src/log.c +++ b/src/log.c @@ -8,7 +8,7 @@ #include #ifdef CONFIG_OPENGL -#include +#include #endif #include "compiler.h" @@ -326,6 +326,10 @@ static const struct log_ops glx_string_marker_logger_ops = { }; struct log_target *glx_string_marker_logger_new(void) { + if (!glx_hasglext("GL_GREMEDY_string_marker")) { + return NULL; + } + void *fnptr = glXGetProcAddress((GLubyte *)"glStringMarkerGREMEDY"); if (!fnptr) return NULL; diff --git a/src/opengl.c b/src/opengl.c index f859488b..2a6c598f 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -347,7 +347,7 @@ glx_init(session_t *ps, bool need_render) { // Check GL_ARB_texture_non_power_of_two, requires a GLX context and // must precede FBConfig fetching if (need_render) - psglx->has_texture_non_power_of_two = glx_hasglext(ps, + psglx->has_texture_non_power_of_two = glx_hasglext( "GL_ARB_texture_non_power_of_two"); // Acquire function addresses diff --git a/src/opengl.h b/src/opengl.h index 13b3a4fd..d3f7225a 100644 --- a/src/opengl.h +++ b/src/opengl.h @@ -119,7 +119,7 @@ glx_hasglxext(session_t *ps, const char *ext) { * Check if a GLX extension exists. */ static inline bool -glx_hasglext(session_t *ps, const char *ext) { +glx_hasglext(const char *ext) { const char *gl_exts = (const char *) glGetString(GL_EXTENSIONS); if (!gl_exts) { log_error("Failed get GL extension list.");