diff options
author | wm4 <wm4@nowhere> | 2016-11-25 21:00:39 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-11-25 21:17:25 +0100 |
commit | 1a2319f3e4cc42c680e2fd3ba30022c7a9adf3fe (patch) | |
tree | 37261ccac2acc614777ba4c790cfed78b96fb58f /video/out/vo_opengl.c | |
parent | 98a257b3a871587a97f51ef1b09800959a94ed1e (diff) | |
download | mpv-1a2319f3e4cc42c680e2fd3ba30022c7a9adf3fe.tar.bz2 mpv-1a2319f3e4cc42c680e2fd3ba30022c7a9adf3fe.tar.xz |
options: remove deprecated sub-option handling for --vo and --ao
Long planned. Leads to some sanity.
There still are some rather gross things. Especially g_groups is ugly,
and a hack that can hopefully be removed. (There is a plan for it, but
whether it's implemented depends on how much energy is left.)
Diffstat (limited to 'video/out/vo_opengl.c')
-rw-r--r-- | video/out/vo_opengl.c | 110 |
1 files changed, 45 insertions, 65 deletions
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c index 2517ba7412..508ba9cda9 100644 --- a/video/out/vo_opengl.c +++ b/video/out/vo_opengl.c @@ -62,40 +62,13 @@ struct vo_opengl_opts { int pattern[2]; }; -#define OPT_BASE_STRUCT struct vo_opengl_opts -static const struct m_sub_options vo_opengl_conf = { - .opts = (const m_option_t[]) { - OPT_FLAG("opengl-glfinish", use_glFinish, 0), - OPT_FLAG("opengl-waitvsync", waitvsync, 0), - OPT_INT("opengl-swapinterval", swap_interval, 0), - OPT_CHOICE("opengl-dwmflush", dwm_flush, 0, - ({"no", -1}, {"auto", 0}, {"windowed", 1}, {"yes", 2})), - OPT_FLAG("opengl-dcomposition", allow_direct_composition, 0), - OPT_FLAG("opengl-debug", use_gl_debug, 0), - OPT_STRING_VALIDATE("opengl-backend", backend, 0, - mpgl_validate_backend_opt), - OPT_FLAG("opengl-sw", allow_sw, 0), - OPT_CHOICE("opengl-es", es, 0, ({"no", -1}, {"auto", 0}, {"yes", 1})), - OPT_INTPAIR("opengl-check-pattern", pattern, 0), - OPT_INTRANGE("opengl-vsync-fences", vsync_fences, 0, - 0, NUM_VSYNC_FENCES), - - {0} - }, - .defaults = &(const struct vo_opengl_opts){ - .swap_interval = 1, - .allow_direct_composition = 1, - }, - .size = sizeof(struct vo_opengl_opts), -}; - struct gl_priv { struct vo *vo; struct mp_log *log; MPGLContext *glctx; GL *gl; - struct vo_opengl_opts *opts; + struct vo_opengl_opts opts; struct gl_video *renderer; @@ -133,7 +106,7 @@ static void resize(struct gl_priv *p) static void check_pattern(struct vo *vo, int item) { struct gl_priv *p = vo->priv; - int expected = p->opts->pattern[p->last_pattern]; + int expected = p->opts.pattern[p->last_pattern]; if (item == expected) { p->last_pattern++; if (p->last_pattern >= 2) @@ -151,7 +124,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) struct gl_priv *p = vo->priv; GL *gl = p->gl; - if (gl->FenceSync && p->num_vsync_fences < p->opts->vsync_fences) { + if (gl->FenceSync && p->num_vsync_fences < p->opts.vsync_fences) { GLsync fence = gl->FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);; if (fence) p->vsync_fences[p->num_vsync_fences++] = fence; @@ -159,7 +132,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) gl_video_render_frame(p->renderer, frame, gl->main_fb); - if (p->opts->use_glFinish) + if (p->opts.use_glFinish) gl->Finish(); } @@ -171,30 +144,30 @@ static void flip_page(struct vo *vo) mpgl_swap_buffers(p->glctx); p->frames_rendered++; - if (p->frames_rendered > 5 && !p->opts->use_gl_debug) + if (p->frames_rendered > 5 && !p->opts.use_gl_debug) gl_video_set_debug(p->renderer, false); - if (p->opts->use_glFinish) + if (p->opts.use_glFinish) gl->Finish(); - if (p->opts->waitvsync || p->opts->pattern[0]) { + if (p->opts.waitvsync || p->opts.pattern[0]) { if (gl->GetVideoSync) { unsigned int n1 = 0, n2 = 0; gl->GetVideoSync(&n1); - if (p->opts->waitvsync) + if (p->opts.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->opts->pattern[0]) + if (p->opts.pattern[0]) check_pattern(vo, step); } else { MP_WARN(vo, "GLX_SGI_video_sync not available, disabling.\n"); - p->opts->waitvsync = 0; - p->opts->pattern[0] = 0; + p->opts.waitvsync = 0; + p->opts.pattern[0] = 0; } } - while (p->opts->vsync_fences > 0 && p->num_vsync_fences >= p->opts->vsync_fences) { + while (p->opts.vsync_fences > 0 && p->num_vsync_fences >= p->opts.vsync_fences) { gl->ClientWaitSync(p->vsync_fences[0], GL_SYNC_FLUSH_COMMANDS_BIT, 1e9); gl->DeleteSync(p->vsync_fences[0]); MP_TARRAY_REMOVE_AT(p->vsync_fences, p->num_vsync_fences, 0); @@ -389,7 +362,6 @@ static int preinit(struct vo *vo) struct gl_priv *p = vo->priv; p->vo = vo; p->log = vo->log; - p->opts = mp_get_config_group(vo, vo->global, &vo_opengl_conf); int vo_flags = 0; @@ -399,29 +371,29 @@ static int preinit(struct vo *vo) if (alpha_mode == 1) vo_flags |= VOFLAG_ALPHA; - if (p->opts->use_gl_debug) + if (p->opts.use_gl_debug) vo_flags |= VOFLAG_GL_DEBUG; - if (p->opts->es == 1) + if (p->opts.es == 1) vo_flags |= VOFLAG_GLES; - if (p->opts->es == -1) + if (p->opts.es == -1) vo_flags |= VOFLAG_NO_GLES; - if (p->opts->allow_sw) + if (p->opts.allow_sw) vo_flags |= VOFLAG_SW; - if (p->opts->allow_direct_composition) + if (p->opts.allow_direct_composition) vo_flags |= VOFLAG_ANGLE_DCOMP; - p->glctx = mpgl_init(vo, p->opts->backend, vo_flags); + p->glctx = mpgl_init(vo, p->opts.backend, vo_flags); if (!p->glctx) goto err_out; p->gl = p->glctx->gl; - p->glctx->dwm_flush_opt = p->opts->dwm_flush; + p->glctx->dwm_flush_opt = p->opts.dwm_flush; if (p->gl->SwapInterval) { - p->gl->SwapInterval(p->opts->swap_interval); + p->gl->SwapInterval(p->opts.swap_interval); } else { MP_VERBOSE(vo, "swap_control extension missing.\n"); } @@ -454,21 +426,7 @@ err_out: return -1; } -static const struct m_option legacy_options[] = { - OPT_SUBOPT_LEGACY("glfinish", "opengl-glfinish"), - OPT_SUBOPT_LEGACY("waitvsync", "opengl-waitvsync"), - OPT_SUBOPT_LEGACY("swapinterval", "opengl-swapinterval"), - OPT_SUBOPT_LEGACY("dwmflush", "opengl-dwmflush"), - OPT_SUBOPT_LEGACY("dcomposition", "opengl-dcomposition"), - OPT_SUBOPT_LEGACY("debug", "opengl-debug"), - OPT_SUBOPT_LEGACY("backend", "opengl-backend"), - OPT_SUBOPT_LEGACY("sw", "opengl-sw"), - OPT_SUBOPT_LEGACY("es", "opengl-es"), - OPT_SUBOPT_LEGACY("check-pattern", "opengl-check-pattern"), - OPT_SUBOPT_LEGACY("vsync-fences", "opengl-vsync-fences"), - OPT_SUBSTRUCT_LEGACY("", gl_video_conf_legacy), - {0}, -}; +#define OPT_BASE_STRUCT struct gl_priv const struct vo_driver video_out_opengl = { .description = "Extended OpenGL Renderer", @@ -484,6 +442,28 @@ const struct vo_driver video_out_opengl = { .wakeup = wakeup, .uninit = uninit, .priv_size = sizeof(struct gl_priv), - .options = legacy_options, - .global_opts = &vo_opengl_conf, + .options = (const m_option_t[]) { + OPT_FLAG("opengl-glfinish", opts.use_glFinish, 0), + OPT_FLAG("opengl-waitvsync", opts.waitvsync, 0), + OPT_INT("opengl-swapinterval", opts.swap_interval, 0), + OPT_CHOICE("opengl-dwmflush", opts.dwm_flush, 0, + ({"no", -1}, {"auto", 0}, {"windowed", 1}, {"yes", 2})), + OPT_FLAG("opengl-dcomposition", opts.allow_direct_composition, 0), + OPT_FLAG("opengl-debug", opts.use_gl_debug, 0), + OPT_STRING_VALIDATE("opengl-backend", opts.backend, 0, + mpgl_validate_backend_opt), + OPT_FLAG("opengl-sw", opts.allow_sw, 0), + OPT_CHOICE("opengl-es", opts.es, 0, ({"no", -1}, {"auto", 0}, {"yes", 1})), + OPT_INTPAIR("opengl-check-pattern", opts.pattern, 0), + OPT_INTRANGE("opengl-vsync-fences", opts.vsync_fences, 0, + 0, NUM_VSYNC_FENCES), + + {0} + }, + .priv_defaults = &(const struct gl_priv){ + .opts = { + .swap_interval = 1, + .allow_direct_composition = 1, + }, + }, }; |