gl_common: initialize string marker logger
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
51ad94f745
commit
ad3ec8cada
|
@ -658,6 +658,11 @@ bool gl_init(struct gl_data *gd, session_t *ps) {
|
||||||
// textures are already set up.
|
// textures are already set up.
|
||||||
gl_resize(gd, ps->root_width, ps->root_height);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,6 +687,11 @@ void gl_deinit(struct gl_data *gd) {
|
||||||
glDeleteFramebuffers(1, &gd->blur_fbo);
|
glDeleteFramebuffers(1, &gd->blur_fbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gd->logger) {
|
||||||
|
log_remove_target_tls(gd->logger);
|
||||||
|
gd->logger = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
gl_check_err();
|
gl_check_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,8 @@ struct gl_data {
|
||||||
GLuint blur_texture[2];
|
GLuint blur_texture[2];
|
||||||
// Temporary fbo used for blurring
|
// Temporary fbo used for blurring
|
||||||
GLuint blur_fbo;
|
GLuint blur_fbo;
|
||||||
|
|
||||||
|
struct log_target *logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -2004,10 +2004,10 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
|
||||||
free(config_file_to_free);
|
free(config_file_to_free);
|
||||||
|
|
||||||
if (bkend_use_glx(ps) && !ps->o.experimental_backends) {
|
if (bkend_use_glx(ps) && !ps->o.experimental_backends) {
|
||||||
auto glx_logger = glx_string_marker_logger_new();
|
auto gl_logger = gl_string_marker_logger_new();
|
||||||
if (glx_logger) {
|
if (gl_logger) {
|
||||||
log_info("Enabling gl string marker");
|
log_info("Enabling gl string marker");
|
||||||
log_add_target_tls(glx_logger);
|
log_add_target_tls(gl_logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
24
src/log.c
24
src/log.c
|
@ -327,23 +327,23 @@ struct log_target *stderr_logger_new(void) {
|
||||||
#ifdef CONFIG_OPENGL
|
#ifdef CONFIG_OPENGL
|
||||||
/// An opengl logger that can be used for logging into opengl debugging tools,
|
/// An opengl logger that can be used for logging into opengl debugging tools,
|
||||||
/// such as apitrace
|
/// such as apitrace
|
||||||
struct glx_string_marker_logger {
|
struct gl_string_marker_logger {
|
||||||
struct log_target tgt;
|
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) {
|
void gl_string_marker_logger_write(struct log_target *tgt, const char *str, size_t len) {
|
||||||
auto g = (struct glx_string_marker_logger *)tgt;
|
auto g = (struct gl_string_marker_logger *)tgt;
|
||||||
g->glx_string_marker(len, str);
|
g->gl_string_marker(len, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct log_ops glx_string_marker_logger_ops = {
|
static const struct log_ops gl_string_marker_logger_ops = {
|
||||||
.write = glx_string_marker_logger_write,
|
.write = gl_string_marker_logger_write,
|
||||||
.writev = log_default_writev,
|
.writev = log_default_writev,
|
||||||
.destroy = logger_trivial_destroy,
|
.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")) {
|
if (!gl_has_extension("GL_GREMEDY_string_marker")) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -352,14 +352,14 @@ struct log_target *glx_string_marker_logger_new(void) {
|
||||||
if (!fnptr)
|
if (!fnptr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
auto ret = cmalloc(struct glx_string_marker_logger);
|
auto ret = cmalloc(struct gl_string_marker_logger);
|
||||||
ret->tgt.ops = &glx_string_marker_logger_ops;
|
ret->tgt.ops = &gl_string_marker_logger_ops;
|
||||||
ret->glx_string_marker = fnptr;
|
ret->gl_string_marker = fnptr;
|
||||||
return &ret->tgt;
|
return &ret->tgt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
struct log_target *glx_string_marker_logger_new(void) {
|
struct log_target *gl_string_marker_logger_new(void) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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 *stderr_logger_new(void);
|
||||||
attr_malloc struct log_target *file_logger_new(const char *file);
|
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 *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:
|
// vim: set noet sw=8 ts=8:
|
||||||
|
|
Loading…
Reference in New Issue