mirror of https://github.com/mpv-player/mpv
vo_opengl: add check-pattern suboption for testing
This uses glXGetVideoSyncSGI() to check how many vsyncs happened since the last flip_page() call. It allows checking a pattern of vsync increments of at most 2 elements. For example, to check ~24 fps playback on a ~60 Hz monitor, this can be used: --vo=opengl:check-pattern=[3-2]:waitvsync Whether the reported results are accurate or just plain wrong may depend on the driver and if the waitvsync sub-option is used. There are no guarantees. This option is undocumented, and may be removed again in the near or distant future.
This commit is contained in:
parent
aaadcef52f
commit
cd2e4db8a5
|
@ -76,6 +76,11 @@ struct gl_priv {
|
|||
|
||||
int frames_rendered;
|
||||
unsigned int prev_sgi_sync_count;
|
||||
|
||||
// check-pattern sub-option; for testing/debugging
|
||||
int opt_pattern[2];
|
||||
int last_pattern;
|
||||
int matches, mismatches;
|
||||
};
|
||||
|
||||
// Always called under mpgl_lock
|
||||
|
@ -95,6 +100,22 @@ static void resize(struct gl_priv *p)
|
|||
vo->want_redraw = true;
|
||||
}
|
||||
|
||||
static void check_pattern(struct vo *vo, int item)
|
||||
{
|
||||
struct gl_priv *p = vo->priv;
|
||||
int expected = p->opt_pattern[p->last_pattern];
|
||||
if (item == expected) {
|
||||
p->last_pattern++;
|
||||
if (p->last_pattern >= 2)
|
||||
p->last_pattern = 0;
|
||||
p->matches++;
|
||||
} else {
|
||||
p->mismatches++;
|
||||
MP_WARN(vo, "wrong pattern, exptected %d got %d (hit: %d, mis: %d)\n",
|
||||
expected, item, p->matches, p->mismatches);
|
||||
}
|
||||
}
|
||||
|
||||
static void flip_page(struct vo *vo)
|
||||
{
|
||||
struct gl_priv *p = vo->priv;
|
||||
|
@ -111,17 +132,21 @@ static void flip_page(struct vo *vo)
|
|||
if (p->use_glFinish)
|
||||
gl->Finish();
|
||||
|
||||
if (p->waitvsync) {
|
||||
if (p->waitvsync || p->opt_pattern[0]) {
|
||||
if (gl->GetVideoSync) {
|
||||
unsigned int n1 = 0, n2 = 0;
|
||||
gl->GetVideoSync(&n1);
|
||||
gl->WaitVideoSync(2, (n1 + 1) % 2, &n2);
|
||||
if (p->waitvsync)
|
||||
gl->WaitVideoSync(2, (n1 + 1) % 2, &n2);
|
||||
int step = n1 - p->prev_sgi_sync_count;
|
||||
p->prev_sgi_sync_count = n1;
|
||||
MP_DBG(vo, "Flip counts: %u->%u, step=%d\n", n1, n2, step);
|
||||
if (p->opt_pattern[0])
|
||||
check_pattern(vo, step);
|
||||
} else {
|
||||
MP_WARN(vo, "GLX_SGI_video_sync not available, disabling.\n");
|
||||
p->waitvsync = 0;
|
||||
p->opt_pattern[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,6 +501,7 @@ const struct m_option options[] = {
|
|||
OPT_FLAG("debug", use_gl_debug, 0),
|
||||
OPT_STRING_VALIDATE("backend", backend, 0, mpgl_validate_backend_opt),
|
||||
OPT_FLAG("sw", allow_sw, 0),
|
||||
OPT_INTPAIR("check-pattern", opt_pattern, 0),
|
||||
|
||||
OPT_SUBSTRUCT("", renderer_opts, gl_video_conf, 0),
|
||||
OPT_SUBSTRUCT("", icc_opts, mp_icc_conf, 0),
|
||||
|
|
Loading…
Reference in New Issue