summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-07-03 16:59:38 +0200
committerNiklas Haas <git@haasn.xyz>2017-07-03 17:14:06 +0200
commit5df3576856b4f985b9724d5b79b1c9ffdfb403ee (patch)
tree63f724078f1420365802fa821cb4a3662c81bf94
parent4a2f268f67b1505630724b6f8df960fce25770f0 (diff)
downloadmpv-5df3576856b4f985b9724d5b79b1c9ffdfb403ee.tar.bz2
mpv-5df3576856b4f985b9724d5b79b1c9ffdfb403ee.tar.xz
vo_opengl: make the pass info mechanism more robust
- change asserts to silent exits - check all pointers before use - move the p->pass initialization code to the right place This should hopefully cut down on the amount of crashing by making the code fundamentally more robust, while also fixing a concrete issue where opengl-cb failed to initialize p->pass.
-rw-r--r--video/out/opengl/video.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index d0d80e94c9..9823f1066d 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -894,9 +894,6 @@ static void init_video(struct gl_video *p)
debug_check_gl(p, "after video texture creation");
gl_video_setup_hooks(p);
-
- // make sure this variable is initialized to *something*
- p->pass = p->pass_fresh;
}
// Release any texture mappings associated with the current frame.
@@ -958,7 +955,9 @@ static void uninit_video(struct gl_video *p)
static void pass_record(struct gl_video *p, struct mp_pass_perf perf)
{
- assert(p->pass_idx < PASS_INFO_MAX);
+ if (!p->pass || p->pass_idx == PASS_INFO_MAX)
+ return;
+
struct pass_info *pass = &p->pass[p->pass_idx];
pass->perf = perf;
@@ -970,7 +969,9 @@ static void pass_record(struct gl_video *p, struct mp_pass_perf perf)
static void pass_describe(struct gl_video *p, const char *textf, ...)
{
- assert(p->pass_idx < PASS_INFO_MAX);
+ if (!p->pass || p->pass_idx == PASS_INFO_MAX)
+ return;
+
struct pass_info *pass = &p->pass[p->pass_idx];
if (pass->desc.len > 0)
@@ -993,6 +994,23 @@ static void pass_info_reset(struct gl_video *p, bool is_redraw)
}
}
+static void pass_report_performance(struct gl_video *p)
+{
+ if (!p->pass)
+ return;
+
+ for (int i = 0; i < PASS_INFO_MAX; i++) {
+ struct pass_info *pass = &p->pass[i];
+ if (pass->desc.len) {
+ MP_DBG(p, "pass '%.*s': last %dus avg %dus peak %dus\n",
+ BSTR_P(pass->desc),
+ (int)pass->perf.last/1000,
+ (int)pass->perf.avg/1000,
+ (int)pass->perf.peak/1000);
+ }
+ }
+}
+
static void pass_prepare_src_tex(struct gl_video *p)
{
struct gl_shader_cache *sc = p->sc;
@@ -2912,18 +2930,7 @@ done:
}
p->frames_rendered++;
-
- // Report performance metrics
- for (int i = 0; i < PASS_INFO_MAX; i++) {
- struct pass_info *pass = &p->pass[i];
- if (pass->desc.len) {
- MP_DBG(p, "pass '%.*s': last %dus avg %dus peak %dus\n",
- BSTR_P(pass->desc),
- (int)pass->perf.last/1000,
- (int)pass->perf.avg/1000,
- (int)pass->perf.peak/1000);
- }
- }
+ pass_report_performance(p);
}
// vp_w/vp_h is the implicit size of the target framebuffer.
@@ -3410,6 +3417,8 @@ struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct mpv_global *g)
.sc = gl_sc_create(gl, log),
.opts_cache = m_config_cache_alloc(p, g, &gl_video_conf),
};
+ // make sure this variable is initialized to *something*
+ p->pass = p->pass_fresh;
struct gl_video_opts *opts = p->opts_cache->opts;
p->cms = gl_lcms_init(p, log, g, opts->icc_opts),
p->opts = *opts;