diff options
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/opengl/video.c | 163 | ||||
-rw-r--r-- | video/out/opengl/video.h | 5 | ||||
-rw-r--r-- | video/out/vo.c | 3 | ||||
-rw-r--r-- | video/out/vo.h | 1 | ||||
-rw-r--r-- | video/out/vo_opengl.c | 199 | ||||
-rw-r--r-- | video/out/vo_opengl_cb.c | 78 |
6 files changed, 207 insertions, 242 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index 56005e77eb..44092897bf 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -170,6 +170,7 @@ struct gl_video { struct mp_log *log; struct gl_video_opts opts; struct gl_video_opts *opts_alloc; + struct m_config_cache *opts_cache; struct gl_lcms *cms; bool gl_debug; @@ -298,7 +299,7 @@ static const struct packed_fmt_entry mp_packed_formats[] = { {0}, }; -const struct gl_video_opts gl_video_opts_def = { +static const struct gl_video_opts gl_video_opts_def = { .dither_algo = DITHER_FRUIT, .dither_depth = -1, .dither_size = 6, @@ -324,35 +325,6 @@ const struct gl_video_opts gl_video_opts_def = { .tone_mapping_param = NAN, }; -const struct gl_video_opts gl_video_opts_hq_def = { - .dither_algo = DITHER_FRUIT, - .dither_depth = 0, - .dither_size = 6, - .temporal_dither_period = 1, - .fbo_format = 0, - .correct_downscaling = 1, - .sigmoid_center = 0.75, - .sigmoid_slope = 6.5, - .sigmoid_upscaling = 1, - .scaler = { - {{"spline36", .params={NAN, NAN}}, {.params = {NAN, NAN}}}, // scale - {{"mitchell", .params={NAN, NAN}}, {.params = {NAN, NAN}}}, // dscale - {{"spline36", .params={NAN, NAN}}, {.params = {NAN, NAN}}}, // cscale - {{"mitchell", .params={NAN, NAN}}, {.params = {NAN, NAN}}, - .clamp = 1, }, // tscale - }, - .scaler_resizes_only = 1, - .scaler_lut_size = 6, - .interpolation_threshold = 0.0001, - .alpha_mode = ALPHA_BLEND_TILES, - .background = {0, 0, 0, 255}, - .gamma = 1.0f, - .deband = 1, - .target_brightness = 250, - .hdr_tone_mapping = TONE_MAPPING_HABLE, - .tone_mapping_param = NAN, -}; - static int validate_scaler_opt(struct mp_log *log, const m_option_t *opt, struct bstr name, struct bstr param); @@ -374,8 +346,8 @@ static int validate_window_opt(struct mp_log *log, const m_option_t *opt, const struct m_sub_options gl_video_conf = { .opts = (const m_option_t[]) { - OPT_FLAG("dumb-mode", dumb_mode, 0), - OPT_FLOATRANGE("gamma", gamma, 0, 0.1, 2.0), + OPT_FLAG("opengl-dumb-mode", dumb_mode, 0), + OPT_FLOATRANGE("opengl-gamma", gamma, 0, 0.1, 2.0), OPT_FLAG("gamma-auto", gamma_auto, 0), OPT_CHOICE_C("target-prim", target_prim, 0, mp_csp_prim_names), OPT_CHOICE_C("target-trc", target_trc, 0, mp_csp_trc_names), @@ -387,7 +359,7 @@ const struct m_sub_options gl_video_conf = { {"gamma", TONE_MAPPING_GAMMA}, {"linear", TONE_MAPPING_LINEAR})), OPT_FLOAT("tone-mapping-param", tone_mapping_param, 0), - OPT_FLAG("pbo", pbo, 0), + OPT_FLAG("opengl-pbo", pbo, 0), SCALER_OPTS("scale", SCALER_SCALE), SCALER_OPTS("dscale", SCALER_DSCALE), SCALER_OPTS("cscale", SCALER_CSCALE), @@ -399,7 +371,7 @@ const struct m_sub_options gl_video_conf = { OPT_FLAG("sigmoid-upscaling", sigmoid_upscaling, 0), OPT_FLOATRANGE("sigmoid-center", sigmoid_center, 0, 0.0, 1.0), OPT_FLOATRANGE("sigmoid-slope", sigmoid_slope, 0, 1.0, 20.0), - OPT_CHOICE("fbo-format", fbo_format, 0, + OPT_CHOICE("opengl-fbo-format", fbo_format, 0, ({"rgb8", GL_RGB8}, {"rgba8", GL_RGBA8}, {"rgb10", GL_RGB10}, @@ -426,7 +398,7 @@ const struct m_sub_options gl_video_conf = { {"yes", ALPHA_YES}, {"blend", ALPHA_BLEND}, {"blend-tiles", ALPHA_BLEND_TILES})), - OPT_FLAG("rectangle-textures", use_rectangle, 0), + OPT_FLAG("opengl-rectangle-textures", use_rectangle, 0), OPT_COLOR("background", background, 0), OPT_FLAG("interpolation", interpolation, 0), OPT_FLOAT("interpolation-threshold", interpolation_threshold, 0), @@ -434,42 +406,105 @@ const struct m_sub_options gl_video_conf = { ({"no", BLEND_SUBS_NO}, {"yes", BLEND_SUBS_YES}, {"video", BLEND_SUBS_VIDEO})), - OPT_STRINGLIST("user-shaders", user_shaders, 0), + OPT_STRINGLIST("opengl-shaders", user_shaders, 0), OPT_FLAG("deband", deband, 0), OPT_SUBSTRUCT("deband", deband_opts, deband_conf, 0), OPT_FLOAT("sharpen", unsharp, 0), OPT_SUBSTRUCT("", icc_opts, mp_icc_conf, 0), + {0} + }, + .size = sizeof(struct gl_video_opts), + .defaults = &gl_video_opts_def, +}; + +#define LEGACY_SCALER_OPTS(n) \ + OPT_SUBOPT_LEGACY(n, n), \ + OPT_SUBOPT_LEGACY(n"-param1", n"-param1"), \ + OPT_SUBOPT_LEGACY(n"-param2", n"-param2"), \ + OPT_SUBOPT_LEGACY(n"-blur", n"-blur"), \ + OPT_SUBOPT_LEGACY(n"-wparam", n"-wparam"), \ + OPT_SUBOPT_LEGACY(n"-clamp", n"-clamp"), \ + OPT_SUBOPT_LEGACY(n"-radius", n"-radius"), \ + OPT_SUBOPT_LEGACY(n"-antiring", n"-antiring"), \ + OPT_SUBOPT_LEGACY(n"-window", n"-window") + +const struct m_sub_options gl_video_conf_legacy = { + .opts = (const m_option_t[]) { + OPT_SUBOPT_LEGACY("dumb-mode", "opengl-dumb-mode"), + OPT_SUBOPT_LEGACY("gamma", "opengl-gamma"), + OPT_SUBOPT_LEGACY("gamma-auto", "gamma-auto"), + OPT_SUBOPT_LEGACY("target-prim", "target-prim"), + OPT_SUBOPT_LEGACY("target-trc", "target-trc"), + OPT_SUBOPT_LEGACY("target-brightness", "target-brightness"), + OPT_SUBOPT_LEGACY("hdr-tone-mapping", "hdr-tone-mapping"), + OPT_SUBOPT_LEGACY("tone-mapping-param", "tone-mapping-param"), + OPT_SUBOPT_LEGACY("pbo", "opengl-pbo"), + LEGACY_SCALER_OPTS("scale"), + LEGACY_SCALER_OPTS("dscale"), + LEGACY_SCALER_OPTS("cscale"), + LEGACY_SCALER_OPTS("tscale"), + OPT_SUBOPT_LEGACY("scaler-lut-size", "scaler-lut-size"), + OPT_SUBOPT_LEGACY("scaler-resizes-only", "scaler-resizes-only"), + OPT_SUBOPT_LEGACY("linear-scaling", "linear-scaling"), + OPT_SUBOPT_LEGACY("correct-downscaling", "correct-downscaling"), + OPT_SUBOPT_LEGACY("sigmoid-upscaling", "sigmoid-upscaling"), + OPT_SUBOPT_LEGACY("sigmoid-center", "sigmoid-center"), + OPT_SUBOPT_LEGACY("sigmoid-slope", "sigmoid-slope"), + OPT_SUBOPT_LEGACY("fbo-format", "opengl-fbo-format"), + OPT_SUBOPT_LEGACY("dither-depth", "dither-depth"), + OPT_SUBOPT_LEGACY("dither", "dither"), + OPT_SUBOPT_LEGACY("dither-size-fruit", "dither-size-fruit"), + OPT_SUBOPT_LEGACY("temporal-dither", "temporal-dither"), + OPT_SUBOPT_LEGACY("temporal-dither-period", "temporal-dither-period"), + OPT_SUBOPT_LEGACY("alpha", "alpha"), + OPT_SUBOPT_LEGACY("rectangle-textures", "opengl-rectangle-textures"), + OPT_SUBOPT_LEGACY("background", "background"), + OPT_SUBOPT_LEGACY("interpolation", "interpolation"), + OPT_SUBOPT_LEGACY("interpolation-threshold", "interpolation-threshold"), + OPT_SUBOPT_LEGACY("blend-subtitles", "blend-subtitles"), + OPT_SUBOPT_LEGACY("user-shaders", "opengl-shaders"), + OPT_SUBOPT_LEGACY("deband", "deband"), + OPT_SUBOPT_LEGACY("deband-iterations", "deband-iterations"), + OPT_SUBOPT_LEGACY("deband-threshold", "deband-threshold"), + OPT_SUBOPT_LEGACY("deband-range", "deband-range"), + OPT_SUBOPT_LEGACY("deband-grain", "deband-grain"), + OPT_SUBOPT_LEGACY("sharpen", "sharpen"), + OPT_SUBOPT_LEGACY("icc-profile", "icc-profile"), + OPT_SUBOPT_LEGACY("icc-profile-auto", "icc-profile-auto"), + OPT_SUBOPT_LEGACY("icc-cache-dir", "icc-cache-dir"), + OPT_SUBOPT_LEGACY("icc-intent", "icc-intent"), + OPT_SUBOPT_LEGACY("icc-contrast", "icc-contrast"), + OPT_SUBOPT_LEGACY("3dlut-size", "icc-3dlut-size"), + OPT_REMOVED("approx-gamma", "this is always enabled now"), OPT_REMOVED("cscale-down", "chroma is never downscaled"), OPT_REMOVED("scale-sep", "this is set automatically whenever sane"), OPT_REMOVED("indirect", "this is set automatically whenever sane"), OPT_REMOVED("srgb", "use target-prim=bt709:target-trc=srgb instead"), OPT_REMOVED("source-shader", "use :deband to enable debanding"), - OPT_REMOVED("prescale-luma", "use user shaders for prescaling"), - OPT_REMOVED("scale-shader", "use user-shaders instead"), - OPT_REMOVED("pre-shaders", "use user-shaders instead"), - OPT_REMOVED("post-shaders", "use user-shaders instead"), - - OPT_REPLACED("lscale", "scale"), - OPT_REPLACED("lscale-down", "scale-down"), - OPT_REPLACED("lparam1", "scale-param1"), - OPT_REPLACED("lparam2", "scale-param2"), - OPT_REPLACED("lradius", "scale-radius"), - OPT_REPLACED("lantiring", "scale-antiring"), - OPT_REPLACED("cparam1", "cscale-param1"), - OPT_REPLACED("cparam2", "cscale-param2"), - OPT_REPLACED("cradius", "cscale-radius"), - OPT_REPLACED("cantiring", "cscale-antiring"), - OPT_REPLACED("smoothmotion", "interpolation"), - OPT_REPLACED("smoothmotion-threshold", "tscale-param1"), - OPT_REPLACED("scale-down", "dscale"), - OPT_REPLACED("fancy-downscaling", "correct-downscaling"), + OPT_REMOVED("prescale-luma", "use opengl-shaders for prescaling"), + OPT_REMOVED("scale-shader", "use opengl-shaders instead"), + OPT_REMOVED("pre-shaders", "use opengl-shaders instead"), + OPT_REMOVED("post-shaders", "use opengl-shaders instead"), + + OPT_SUBOPT_LEGACY("lscale", "scale"), + OPT_SUBOPT_LEGACY("lscale-down", "scale-down"), + OPT_SUBOPT_LEGACY("lparam1", "scale-param1"), + OPT_SUBOPT_LEGACY("lparam2", "scale-param2"), + OPT_SUBOPT_LEGACY("lradius", "scale-radius"), + OPT_SUBOPT_LEGACY("lantiring", "scale-antiring"), + OPT_SUBOPT_LEGACY("cparam1", "cscale-param1"), + OPT_SUBOPT_LEGACY("cparam2", "cscale-param2"), + OPT_SUBOPT_LEGACY("cradius", "cscale-radius"), + OPT_SUBOPT_LEGACY("cantiring", "cscale-antiring"), + OPT_SUBOPT_LEGACY("smoothmotion", "interpolation"), + OPT_SUBOPT_LEGACY("smoothmotion-threshold", "tscale-param1"), + OPT_SUBOPT_LEGACY("scale-down", "dscale"), + OPT_SUBOPT_LEGACY("fancy-downscaling", "correct-downscaling"), {0} }, - .size = sizeof(struct gl_video_opts), - .defaults = &gl_video_opts_def, }; static void uninit_rendering(struct gl_video *p); @@ -3382,8 +3417,10 @@ struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct mpv_global *g) .cms = gl_lcms_init(p, log, g), .texture_16bit_depth = 16, .sc = gl_sc_create(gl, log), + .opts_cache = m_config_cache_alloc(p, g, &gl_video_conf), }; - set_options(p, NULL); + set_options(p, p->opts_cache->opts); + gl_lcms_set_options(p->cms, p->opts.icc_opts); for (int n = 0; n < SCALER_COUNT; n++) p->scaler[n] = (struct scaler){.index = n}; gl_video_set_debug(p, true); @@ -3417,12 +3454,12 @@ static void set_options(struct gl_video *p, struct gl_video_opts *src) p->opts = *p->opts_alloc; } -// Set the options, and possibly update the filter chain too. -// Note: assumes all options are valid and verified by the option parser. -void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts) +void gl_video_update_options(struct gl_video *p) { - set_options(p, opts); - reinit_from_options(p); + if (m_config_cache_update(p->opts_cache)) { + set_options(p, p->opts_cache->opts); + reinit_from_options(p); + } } static void reinit_from_options(struct gl_video *p) diff --git a/video/out/opengl/video.h b/video/out/opengl/video.h index b21112ac9f..a6c7ca2898 100644 --- a/video/out/opengl/video.h +++ b/video/out/opengl/video.h @@ -138,8 +138,7 @@ struct gl_video_opts { }; extern const struct m_sub_options gl_video_conf; -extern const struct gl_video_opts gl_video_opts_hq_def; -extern const struct gl_video_opts gl_video_opts_def; +extern const struct m_sub_options gl_video_conf_legacy; struct gl_video; struct vo_frame; @@ -147,7 +146,7 @@ struct vo_frame; struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct mpv_global *g); void gl_video_uninit(struct gl_video *p); void gl_video_set_osd_source(struct gl_video *p, struct osd_state *osd); -void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts); +void gl_video_update_options(struct gl_video *p); bool gl_video_check_format(struct gl_video *p, int mp_format); void gl_video_config(struct gl_video *p, struct mp_image_params *params); void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b); diff --git a/video/out/vo.c b/video/out/vo.c index b8b55ca58e..ee554f0e6d 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -48,7 +48,6 @@ extern const struct vo_driver video_out_x11; extern const struct vo_driver video_out_vdpau; extern const struct vo_driver video_out_xv; extern const struct vo_driver video_out_opengl; -extern const struct vo_driver video_out_opengl_hq; extern const struct vo_driver video_out_opengl_cb; extern const struct vo_driver video_out_null; extern const struct vo_driver video_out_image; @@ -105,7 +104,6 @@ const struct vo_driver *const video_out_drivers[] = &video_out_lavc, #endif #if HAVE_GL - &video_out_opengl_hq, &video_out_opengl_cb, #endif NULL @@ -188,7 +186,6 @@ const struct m_obj_list vo_obj_list = { .description = "video outputs", .aliases = { {"gl", "opengl"}, - {"gl3", "opengl-hq"}, {0} }, .allow_unknown_entries = true, diff --git a/video/out/vo.h b/video/out/vo.h index 96de569bc1..3714fbf9ca 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -102,6 +102,7 @@ enum mp_voctrl { VOCTRL_SCREENSHOT_WIN, // struct mp_image** VOCTRL_SET_COMMAND_LINE, // char** + VOCTRL_UPDATE_RENDER_OPTS, VOCTRL_GET_ICC_PROFILE, // bstr* VOCTRL_GET_AMBIENT_LUX, // int* diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c index 300a3a76d0..83f5840caa 100644 --- a/video/out/vo_opengl.c +++ b/video/out/vo_opengl.c @@ -48,39 +48,65 @@ #define NUM_VSYNC_FENCES 10 +struct vo_opengl_opts { + int use_glFinish; + int waitvsync; + int use_gl_debug; + int allow_sw; + int swap_interval; + int dwm_flush; + int allow_direct_composition; + int vsync_fences; + char *backend; + int es; + int pattern[2]; +}; + +#define OPT_BASE_STRUCT struct vo_opengl_opts +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 gl_video *renderer; struct gl_hwdec *hwdec; int events; - void *original_opts; - - // Options - struct gl_video_opts *renderer_opts; - int use_glFinish; - int waitvsync; - int use_gl_debug; - int allow_sw; - int swap_interval; - int dwm_flush; - int allow_direct_composition; - int opt_vsync_fences; - - char *backend; - int es; - 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; @@ -107,7 +133,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->opt_pattern[p->last_pattern]; + int expected = p->opts->pattern[p->last_pattern]; if (item == expected) { p->last_pattern++; if (p->last_pattern >= 2) @@ -125,7 +151,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->opt_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; @@ -133,7 +159,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) gl_video_render_frame(p->renderer, frame, gl->main_fb); - if (p->use_glFinish) + if (p->opts->use_glFinish) gl->Finish(); } @@ -145,30 +171,30 @@ static void flip_page(struct vo *vo) mpgl_swap_buffers(p->glctx); p->frames_rendered++; - if (p->frames_rendered > 5 && !p->use_gl_debug) + if (p->frames_rendered > 5 && !p->opts->use_gl_debug) gl_video_set_debug(p->renderer, false); - if (p->use_glFinish) + if (p->opts->use_glFinish) gl->Finish(); - if (p->waitvsync || p->opt_pattern[0]) { + if (p->opts->waitvsync || p->opts->pattern[0]) { if (gl->GetVideoSync) { unsigned int n1 = 0, n2 = 0; gl->GetVideoSync(&n1); - if (p->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->opt_pattern[0]) + if (p->opts->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; + p->opts->waitvsync = 0; + p->opts->pattern[0] = 0; } } - while (p->opt_vsync_fences > 0 && p->num_vsync_fences >= p->opt_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); @@ -248,34 +274,6 @@ static void get_and_update_ambient_lighting(struct gl_priv *p) } } -static const struct m_option options[]; - -static const struct m_sub_options opengl_conf = { - .opts = options, - .size = sizeof(struct gl_priv), -}; - -static bool reparse_cmdline(struct vo *vo, char *args) -{ - struct gl_priv *p = vo->priv; - int r = 0; - - struct gl_priv *opts = p; - - if (strcmp(args, "-") == 0) { - opts = p->original_opts; - } else { - r = m_config_parse_suboptions(vo->config, "opengl", args); - } - - gl_video_set_options(p->renderer, opts->renderer_opts); - get_and_update_icc_profile(p); - gl_video_configure_queue(p->renderer, p->vo); - p->vo->want_redraw = true; - - return r >= 0; -} - static int control(struct vo *vo, uint32_t request, void *data) { struct gl_priv *p = vo->priv; @@ -316,9 +314,12 @@ static int control(struct vo *vo, uint32_t request, void *data) case VOCTRL_LOAD_HWDEC_API: request_hwdec_api(vo, data); return true; - case VOCTRL_SET_COMMAND_LINE: { - char *arg = data; - return reparse_cmdline(vo, arg); + case VOCTRL_UPDATE_RENDER_OPTS: { + gl_video_update_options(p->renderer); + get_and_update_icc_profile(p); + gl_video_configure_queue(p->renderer, p->vo); + p->vo->want_redraw = true; + return true; } case VOCTRL_RESET: gl_video_reset(p->renderer); @@ -390,35 +391,39 @@ 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; - if (p->renderer_opts->alpha_mode == 1) + int alpha_mode; + mp_read_option_raw(vo->global, "alpha", &m_option_type_choice, &alpha_mode); + + if (alpha_mode == 1) vo_flags |= VOFLAG_ALPHA; - if (p->use_gl_debug) + if (p->opts->use_gl_debug) vo_flags |= VOFLAG_GL_DEBUG; - if (p->es == 1) + if (p->opts->es == 1) vo_flags |= VOFLAG_GLES; - if (p->es == -1) + if (p->opts->es == -1) vo_flags |= VOFLAG_NO_GLES; - if (p->allow_sw) + if (p->opts->allow_sw) vo_flags |= VOFLAG_SW; - if (p->allow_direct_composition) + if (p->opts->allow_direct_composition) vo_flags |= VOFLAG_ANGLE_DCOMP; - p->glctx = mpgl_init(vo, p->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->dwm_flush; + p->glctx->dwm_flush_opt = p->opts->dwm_flush; if (p->gl->SwapInterval) { - p->gl->SwapInterval(p->swap_interval); + p->gl->SwapInterval(p->opts->swap_interval); } else { MP_VERBOSE(vo, "swap_control extension missing.\n"); } @@ -427,7 +432,6 @@ static int preinit(struct vo *vo) if (!p->renderer) goto err_out; gl_video_set_osd_source(p->renderer, vo->osd); - gl_video_set_options(p->renderer, p->renderer_opts); gl_video_configure_queue(p->renderer, vo); get_and_update_icc_profile(p); @@ -445,8 +449,6 @@ static int preinit(struct vo *vo) gl_video_set_hwdec(p->renderer, p->hwdec); } - p->original_opts = m_sub_options_copy(p, &opengl_conf, p); - return 0; err_out: @@ -454,31 +456,26 @@ err_out: return -1; } -#define OPT_BASE_STRUCT struct gl_priv -static const struct m_option options[] = { - OPT_FLAG("glfinish", use_glFinish, 0), - OPT_FLAG("waitvsync", waitvsync, 0), - OPT_INT("swapinterval", swap_interval, 0, OPTDEF_INT(1)), - OPT_CHOICE("dwmflush", dwm_flush, 0, - ({"no", -1}, {"auto", 0}, {"windowed", 1}, {"yes", 2})), - OPT_FLAG("dcomposition", allow_direct_composition, 0, OPTDEF_INT(1)), - OPT_FLAG("debug", use_gl_debug, 0), - OPT_STRING_VALIDATE("backend", backend, 0, mpgl_validate_backend_opt), - OPT_FLAG("sw", allow_sw, 0), - OPT_CHOICE("es", es, 0, ({"no", -1}, {"auto", 0}, {"yes", 1})), - OPT_INTPAIR("check-pattern", opt_pattern, 0), - OPT_INTRANGE("vsync-fences", opt_vsync_fences, 0, 0, NUM_VSYNC_FENCES), - - OPT_SUBSTRUCT("", renderer_opts, gl_video_conf, 0), +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 CAPS VO_CAP_ROTATE90 - const struct vo_driver video_out_opengl = { .description = "Extended OpenGL Renderer", .name = "opengl", - .caps = CAPS, + .caps = VO_CAP_ROTATE90, .preinit = preinit, .query_format = query_format, .reconfig = reconfig, @@ -489,25 +486,5 @@ const struct vo_driver video_out_opengl = { .wakeup = wakeup, .uninit = uninit, .priv_size = sizeof(struct gl_priv), - .options = options, -}; - -const struct vo_driver video_out_opengl_hq = { - .description = "Extended OpenGL Renderer (high quality rendering preset)", - .name = "opengl-hq", - .caps = CAPS, - .preinit = preinit, - .query_format = query_format, - .reconfig = reconfig, - .control = control, - .draw_frame = draw_frame, - .flip_page = flip_page, - .wait_events = wait_events, - .wakeup = wakeup, - .uninit = uninit, - .priv_size = sizeof(struct gl_priv), - .priv_defaults = &(const struct gl_priv){ - .renderer_opts = (struct gl_video_opts *)&gl_video_opts_hq_def, - }, - .options = options, + .options = legacy_options, }; diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c index 776d4485ba..c2d3be78e6 100644 --- a/video/out/vo_opengl_cb.c +++ b/video/out/vo_opengl_cb.c @@ -47,13 +47,7 @@ */ struct vo_priv { - struct vo *vo; - struct mpv_opengl_cb_context *ctx; - - // Immutable after VO init - int use_gl_debug; - struct gl_video_opts *renderer_opts; }; struct mpv_opengl_cb_context { @@ -82,8 +76,6 @@ struct mpv_opengl_cb_context { bool imgfmt_supported[IMGFMT_END - IMGFMT_START]; struct mp_vo_opts vo_opts; bool update_new_opts; - struct vo_priv *new_opts; // use these options, instead of the VO ones - struct m_config *new_opts_cfg; bool eq_changed; struct mp_csp_equalizer eq; struct vo *active; @@ -234,9 +226,6 @@ int mpv_opengl_cb_uninit_gl(struct mpv_opengl_cb_context *ctx) ctx->hwdec_devs = NULL; talloc_free(ctx->gl); ctx->gl = NULL; - talloc_free(ctx->new_opts_cfg); - ctx->new_opts = NULL; - ctx->new_opts_cfg = NULL; return 0; } @@ -275,15 +264,14 @@ int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int vp_w, int vp_h) ctx->eq_changed = true; } if (ctx->update_new_opts) { - struct vo_priv *p = vo ? vo->priv : NULL; - struct vo_priv *opts = ctx->new_opts ? ctx->new_opts : p; - if (opts) { - gl_video_set_options(ctx->renderer, opts->renderer_opts); - if (vo) - gl_video_configure_queue(ctx->renderer, vo); - ctx->gl->debug_context = opts->use_gl_debug; - gl_video_set_debug(ctx->renderer, opts->use_gl_debug); - } + gl_video_update_options(ctx->renderer); + if (vo) + gl_video_configure_queue(ctx->renderer, vo); + int debug; + mp_read_option_raw(ctx->global, "opengl-debug", &m_option_type_flag, + &debug); + ctx->gl->debug_context = debug; + gl_video_set_debug(ctx->renderer, debug); if (gl_video_icc_auto_enabled(ctx->renderer)) MP_ERR(ctx, "icc-profile-auto is not available with opengl-cb\n"); } @@ -445,41 +433,6 @@ static int reconfig(struct vo *vo, struct mp_image_params *params) return 0; } -// list of options which can be changed at runtime -#define OPT_BASE_STRUCT struct vo_priv -static const struct m_option change_opts[] = { - OPT_FLAG("debug", use_gl_debug, 0), - OPT_SUBSTRUCT("", renderer_opts, gl_video_conf, 0), - {0} -}; -#undef OPT_BASE_STRUCT - -static bool reparse_cmdline(struct vo_priv *p, char *args) -{ - struct m_config *cfg = NULL; - struct vo_priv *opts = NULL; - int r = 0; - - pthread_mutex_lock(&p->ctx->lock); - const struct vo_priv *vodef = p->vo->driver->priv_defaults; - cfg = m_config_new(NULL, p->vo->log, sizeof(*opts), vodef, change_opts); - opts = cfg->optstruct; - r = m_config_parse_suboptions(cfg, "opengl-cb", args); - - if (r >= 0) { - talloc_free(p->ctx->new_opts_cfg); - p->ctx->new_opts = opts; - p->ctx->new_opts_cfg = cfg; - p->ctx->update_new_opts = true; - cfg = NULL; - update(p); - } - - talloc_free(cfg); - pthread_mutex_unlock(&p->ctx->lock); - return r >= 0; -} - static int control(struct vo *vo, uint32_t request, void *data) { struct vo_priv *p = vo->priv; @@ -522,10 +475,12 @@ static int control(struct vo *vo, uint32_t request, void *data) update(p); pthread_mutex_unlock(&p->ctx->lock); return VO_TRUE; - case VOCTRL_SET_COMMAND_LINE: { - char *arg = data; - return reparse_cmdline(p, arg); - } + case VOCTRL_UPDATE_RENDER_OPTS: + pthread_mutex_lock(&p->ctx->lock); + p->ctx->update_new_opts = true; + update(p); + pthread_mutex_unlock(&p->ctx->lock); + return VO_TRUE; } return VO_NOTIMPL; @@ -547,7 +502,6 @@ static void uninit(struct vo *vo) static int preinit(struct vo *vo) { struct vo_priv *p = vo->priv; - p->vo = vo; p->ctx = vo->extra.opengl_cb_context; if (!p->ctx) { MP_FATAL(vo, "No context set.\n"); @@ -575,8 +529,8 @@ static int preinit(struct vo *vo) #define OPT_BASE_STRUCT struct vo_priv static const struct m_option options[] = { - OPT_FLAG("debug", use_gl_debug, 0), - OPT_SUBSTRUCT("", renderer_opts, gl_video_conf, 0), + OPT_SUBOPT_LEGACY("debug", "opengl-debug"), + OPT_SUBSTRUCT_LEGACY("", gl_video_conf_legacy), {0}, }; |