From ad3ec8cada0e78bab0a6dcb78c348ec58755d264 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Wed, 27 Mar 2019 14:51:20 +0000 Subject: [PATCH] gl_common: initialize string marker logger Signed-off-by: Yuxuan Shui --- src/backend/gl/gl_common.c | 10 ++++++++++ src/backend/gl/gl_common.h | 2 ++ src/compton.c | 6 +++--- src/log.c | 24 ++++++++++++------------ src/log.h | 2 +- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/backend/gl/gl_common.c b/src/backend/gl/gl_common.c index 18f21fa..6e8b788 100644 --- a/src/backend/gl/gl_common.c +++ b/src/backend/gl/gl_common.c @@ -658,6 +658,11 @@ bool gl_init(struct gl_data *gd, session_t *ps) { // textures are already set up. gl_resize(gd, ps->root_width, ps->root_height); + gd->logger = gl_string_marker_logger_new(); + if (gd->logger) { + log_add_target_tls(gd->logger); + } + return true; } @@ -682,6 +687,11 @@ void gl_deinit(struct gl_data *gd) { glDeleteFramebuffers(1, &gd->blur_fbo); } + if (gd->logger) { + log_remove_target_tls(gd->logger); + gd->logger = NULL; + } + gl_check_err(); } diff --git a/src/backend/gl/gl_common.h b/src/backend/gl/gl_common.h index cc215a0..03ad353 100644 --- a/src/backend/gl/gl_common.h +++ b/src/backend/gl/gl_common.h @@ -61,6 +61,8 @@ struct gl_data { GLuint blur_texture[2]; // Temporary fbo used for blurring GLuint blur_fbo; + + struct log_target *logger; }; typedef struct { diff --git a/src/compton.c b/src/compton.c index b861f03..1ba4316 100644 --- a/src/compton.c +++ b/src/compton.c @@ -2004,10 +2004,10 @@ static session_t *session_init(int argc, char **argv, Display *dpy, free(config_file_to_free); if (bkend_use_glx(ps) && !ps->o.experimental_backends) { - auto glx_logger = glx_string_marker_logger_new(); - if (glx_logger) { + auto gl_logger = gl_string_marker_logger_new(); + if (gl_logger) { log_info("Enabling gl string marker"); - log_add_target_tls(glx_logger); + log_add_target_tls(gl_logger); } } diff --git a/src/log.c b/src/log.c index b23e300..7a70721 100644 --- a/src/log.c +++ b/src/log.c @@ -327,23 +327,23 @@ struct log_target *stderr_logger_new(void) { #ifdef CONFIG_OPENGL /// An opengl logger that can be used for logging into opengl debugging tools, /// such as apitrace -struct glx_string_marker_logger { +struct gl_string_marker_logger { struct log_target tgt; - void (*glx_string_marker)(GLsizei len, const char *); + void (*gl_string_marker)(GLsizei len, const char *); }; -void glx_string_marker_logger_write(struct log_target *tgt, const char *str, size_t len) { - auto g = (struct glx_string_marker_logger *)tgt; - g->glx_string_marker(len, str); +void gl_string_marker_logger_write(struct log_target *tgt, const char *str, size_t len) { + auto g = (struct gl_string_marker_logger *)tgt; + g->gl_string_marker(len, str); } -static const struct log_ops glx_string_marker_logger_ops = { - .write = glx_string_marker_logger_write, +static const struct log_ops gl_string_marker_logger_ops = { + .write = gl_string_marker_logger_write, .writev = log_default_writev, .destroy = logger_trivial_destroy, }; -struct log_target *glx_string_marker_logger_new(void) { +struct log_target *gl_string_marker_logger_new(void) { if (!gl_has_extension("GL_GREMEDY_string_marker")) { return NULL; } @@ -352,14 +352,14 @@ struct log_target *glx_string_marker_logger_new(void) { if (!fnptr) return NULL; - auto ret = cmalloc(struct glx_string_marker_logger); - ret->tgt.ops = &glx_string_marker_logger_ops; - ret->glx_string_marker = fnptr; + auto ret = cmalloc(struct gl_string_marker_logger); + ret->tgt.ops = &gl_string_marker_logger_ops; + ret->gl_string_marker = fnptr; return &ret->tgt; } #else -struct log_target *glx_string_marker_logger_new(void) { +struct log_target *gl_string_marker_logger_new(void) { return NULL; } #endif diff --git a/src/log.h b/src/log.h index 4df3f8e..1d16b0d 100644 --- a/src/log.h +++ b/src/log.h @@ -89,6 +89,6 @@ static inline void log_deinit_tls(void) { attr_malloc struct log_target *stderr_logger_new(void); attr_malloc struct log_target *file_logger_new(const char *file); attr_malloc struct log_target *null_logger_new(void); -attr_malloc struct log_target *glx_string_marker_logger_new(void); +attr_malloc struct log_target *gl_string_marker_logger_new(void); // vim: set noet sw=8 ts=8: