gl_common: initialize string marker logger

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-03-27 14:51:20 +00:00
parent 51ad94f745
commit ad3ec8cada
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
5 changed files with 28 additions and 16 deletions

View File

@ -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();
}

View File

@ -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 {

View File

@ -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);
}
}

View File

@ -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

View File

@ -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: