summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-23 02:46:44 +0100
committerwm4 <wm4@nowhere>2014-12-23 02:46:44 +0100
commita8ffa0d0ebca8e502c4dafb6ea5011e17c978b1a (patch)
tree81fcbf0b391ed889fe3a80bed5e4e9ba554defc3 /video
parentb7d0db8bfed7e9dac40f62977b016b3b8e5fdbc7 (diff)
downloadmpv-a8ffa0d0ebca8e502c4dafb6ea5011e17c978b1a.tar.bz2
mpv-a8ffa0d0ebca8e502c4dafb6ea5011e17c978b1a.tar.xz
vo_opengl: make use of newer OpenGL logging API
GL_ARB_debug_output provides a logging callback, which can be used to diagnose problems etc. in case the driver supports it. It's enabled only if the vo_opengl "debug" suboption is set.
Diffstat (limited to 'video')
-rw-r--r--video/out/gl_common.c13
-rw-r--r--video/out/gl_common.h8
-rw-r--r--video/out/gl_video.c36
-rw-r--r--video/out/vo_opengl.c2
-rw-r--r--video/out/vo_opengl_cb.c1
5 files changed, 58 insertions, 2 deletions
diff --git a/video/out/gl_common.c b/video/out/gl_common.c
index a94ad1fc75..cfae5cc39f 100644
--- a/video/out/gl_common.c
+++ b/video/out/gl_common.c
@@ -107,6 +107,7 @@ static const struct feature features[] = {
{MPGL_CAP_TEX_RG, "RG textures"},
{MPGL_CAP_1ST_CLASS_ARRAYS, "1st class shader arrays"},
{MPGL_CAP_3D_TEX, "3D textures"},
+ {MPGL_CAP_DEBUG, "debugging extensions"},
{MPGL_CAP_SW, "suspected software renderer"},
{0},
};
@@ -462,6 +463,16 @@ static const struct gl_functions gl_functions[] = {
.extension = "GL_APPLE_rgb_422",
.provides = MPGL_CAP_APPLE_RGB_422,
},
+ {
+ .ver_core = 430,
+ .extension = "GL_ARB_debug_output",
+ .provides = MPGL_CAP_DEBUG,
+ .functions = (const struct gl_function[]) {
+ // (only functions needed by us)
+ DEF_FN(DebugMessageCallback),
+ {0}
+ },
+ },
};
#undef FN_OFFS
@@ -972,6 +983,8 @@ MPGLContext *mpgl_init(struct vo *vo, const char *backend_name,
goto cleanup;
}
+ ctx->gl->debug_context = !!(vo_flags & VOFLAG_GL_DEBUG);
+
return ctx;
cleanup:
diff --git a/video/out/gl_common.h b/video/out/gl_common.h
index 6f7c8b8ce5..103b458203 100644
--- a/video/out/gl_common.h
+++ b/video/out/gl_common.h
@@ -81,6 +81,7 @@ enum {
MPGL_CAP_APPLE_RGB_422 = (1 << 12), // GL_APPLE_rgb_422
MPGL_CAP_1ST_CLASS_ARRAYS = (1 << 13),
MPGL_CAP_3D_TEX = (1 << 14),
+ MPGL_CAP_DEBUG = (1 << 15),
MPGL_CAP_SW = (1 << 30), // indirect or sw renderer
};
@@ -171,6 +172,9 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n),
// log, lev: module and log level, as in mp_msg()
void mp_log_source(struct mp_log *log, int lev, const char *src);
+typedef void (GLAPIENTRY *MP_GLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum,
+ GLsizei, const GLchar *,const void *);
+
//function pointers loaded from the OpenGL library
struct GL {
int version; // MPGL_VER() mangled (e.g. 210 for 2.1)
@@ -178,6 +182,7 @@ struct GL {
int glsl_version; // e.g. 130 for GLSL 1.30
char *extensions; // Equivalent to GL_EXTENSIONS
int mpgl_caps; // Bitfield of MPGL_CAP_* constants
+ bool debug_context; // use of e.g. GLX_CONTEXT_DEBUG_BIT_ARB
void (GLAPIENTRY *Begin)(GLenum);
void (GLAPIENTRY *End)(void);
@@ -326,6 +331,9 @@ struct GL {
GLint (GLAPIENTRY *GetVideoSync)(GLuint *);
GLint (GLAPIENTRY *WaitVideoSync)(GLint, GLint, unsigned int *);
+
+ void (GLAPIENTRY *DebugMessageCallback)(MP_GLDEBUGPROC callback,
+ const void *userParam);
};
#endif /* MPLAYER_GL_COMMON_H */
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 5235f1bd1e..fdbb26a7eb 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -127,6 +127,7 @@ struct gl_video {
struct mp_log *log;
struct gl_video_opts opts;
bool gl_debug;
+ bool debug_cb_set;
int depth_g;
@@ -434,9 +435,39 @@ static void debug_check_gl(struct gl_video *p, const char *msg)
glCheckError(p->gl, p->log, msg);
}
+
+static void GLAPIENTRY gl_debug_cb(GLenum source, GLenum type, GLuint id,
+ GLenum severity, GLsizei length,
+ const GLchar *message, const void *userParam)
+{
+ // keep in mind that the debug callback can be asynchronous
+ struct gl_video *p = (void *)userParam;
+ int level = MSGL_ERR;
+ switch (severity) {
+ case GL_DEBUG_SEVERITY_NOTIFICATION:level = MSGL_V; break;
+ case GL_DEBUG_SEVERITY_LOW: level = MSGL_INFO; break;
+ case GL_DEBUG_SEVERITY_MEDIUM: level = MSGL_WARN; break;
+ case GL_DEBUG_SEVERITY_HIGH: level = MSGL_ERR; break;
+ }
+ MP_MSG(p, level, "GL: %s\n", message);
+}
+
void gl_video_set_debug(struct gl_video *p, bool enable)
{
+ GL *gl = p->gl;
+
p->gl_debug = enable;
+
+ if (p->debug_cb_set != enable && gl->debug_context &&
+ gl->DebugMessageCallback)
+ {
+ if (enable) {
+ gl->DebugMessageCallback(gl_debug_cb, p);
+ } else {
+ gl->DebugMessageCallback(NULL, NULL);
+ }
+ p->debug_cb_set = enable;
+ }
}
static void texture_size(struct gl_video *p, int w, int h, int *texw, int *texh)
@@ -2247,6 +2278,9 @@ void gl_video_uninit(struct gl_video *p)
mpgl_osd_destroy(p->osd);
+ if (p->debug_cb_set)
+ gl->DebugMessageCallback(NULL, NULL);
+
talloc_free(p);
}
@@ -2452,13 +2486,13 @@ struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct osd_state *osd
.osd_state = osd,
.opts = gl_video_opts_def,
.gl_target = GL_TEXTURE_2D,
- .gl_debug = true,
.scalers = {
{ .index = 0, .name = "bilinear" },
{ .index = 1, .name = "bilinear" },
},
.scratch = talloc_zero_array(p, char *, 1),
};
+ gl_video_set_debug(p, true);
init_gl(p);
recreate_osd(p);
return p;
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index 67cd3ce9dd..d9067d9567 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -127,7 +127,7 @@ static void flip_page(struct vo *vo)
p->glctx->swapGlBuffers(p->glctx);
p->frames_rendered++;
- if (p->frames_rendered > 5)
+ if (p->frames_rendered > 5 && !p->use_gl_debug)
gl_video_set_debug(p->renderer, false);
if (p->use_glFinish)
diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c
index c292668651..f431880ecb 100644
--- a/video/out/vo_opengl_cb.c
+++ b/video/out/vo_opengl_cb.c
@@ -214,6 +214,7 @@ int mpv_opengl_cb_render(struct mpv_opengl_cb_context *ctx, int fbo, int vp[4])
gl_video_config(ctx->renderer, &ctx->img_params);
struct vo_priv *p = vo->priv;
gl_video_set_options(ctx->renderer, p->renderer_opts);
+ ctx->gl->debug_context = p->use_gl_debug;
gl_video_set_debug(ctx->renderer, p->use_gl_debug);
}