mirror of
https://github.com/mpv-player/mpv
synced 2025-03-21 18:57:35 +00:00
options: refactor how --opengl-dcomposition is declared
vo_opengl used to have it as sub-option, which made it very hard to pass down option values to backends in a generic way (even if these options were completely backend-specific). For --opengl-dcomposition we used a VOFLAG to deal with this. Fortunately, sub-options are gone, and we can just add it as global option. Move the option to context_angle.c and add it as global option. I thought about adding a mechanism to let backends declare options, which would get magically picked up my m_config instead of having to add them to the global option list manually (similar to VO vo_driver.options), but decided against this complexity just for 1 or 2 backends. Likewise, it could have been added as a single option to avoid the boilerplate of an option struct, but then again there are probably going to be more angle suboptions, and it's cleaner.
This commit is contained in:
parent
a35a5bb5f3
commit
d890e0731c
@ -88,6 +88,8 @@ extern const struct m_obj_list af_obj_list;
|
||||
extern const struct m_obj_list vo_obj_list;
|
||||
extern const struct m_obj_list ao_obj_list;
|
||||
|
||||
extern const struct m_sub_options angle_conf;
|
||||
|
||||
const struct m_opt_choice_alternatives mp_hwdec_names[] = {
|
||||
{"no", HWDEC_NONE},
|
||||
{"auto", HWDEC_AUTO},
|
||||
@ -691,6 +693,10 @@ const m_option_t mp_opts[] = {
|
||||
OPT_SUBSTRUCT("", gl_video_opts, gl_video_conf, 0),
|
||||
#endif
|
||||
|
||||
#if HAVE_EGL_ANGLE
|
||||
OPT_SUBSTRUCT("", angle_opts, angle_conf, 0),
|
||||
#endif
|
||||
|
||||
#if HAVE_ENCODING
|
||||
OPT_SUBSTRUCT("", encode_opts, encode_config, 0),
|
||||
#endif
|
||||
|
@ -320,6 +320,7 @@ typedef struct MPOpts {
|
||||
char *input_file;
|
||||
|
||||
struct gl_video_opts *gl_video_opts;
|
||||
struct angle_opts *angle_opts;
|
||||
struct dvd_opts *dvd_opts;
|
||||
} MPOpts;
|
||||
|
||||
|
@ -159,6 +159,7 @@ static MPGLContext *init_backend(struct vo *vo, const struct mpgl_driver *driver
|
||||
*ctx = (MPGLContext) {
|
||||
.gl = talloc_zero(ctx, GL),
|
||||
.vo = vo,
|
||||
.global = vo->global,
|
||||
.driver = driver,
|
||||
};
|
||||
if (probing)
|
||||
|
@ -32,7 +32,6 @@ enum {
|
||||
VOFLAG_GL_DEBUG = 1 << 2, // Hint to request debug OpenGL context
|
||||
VOFLAG_ALPHA = 1 << 3, // Hint to request alpha framebuffer
|
||||
VOFLAG_SW = 1 << 4, // Hint to accept a software GL renderer
|
||||
VOFLAG_ANGLE_DCOMP = 1 << 5, // Whether DirectComposition is allowed
|
||||
VOFLAG_PROBING = 1 << 6, // The backend is being auto-probed.
|
||||
};
|
||||
|
||||
@ -78,6 +77,7 @@ typedef struct MPGLContext {
|
||||
GL *gl;
|
||||
struct vo *vo;
|
||||
const struct mpgl_driver *driver;
|
||||
struct mpv_global *global;
|
||||
|
||||
// For hwdec_vaegl.c.
|
||||
const char *native_display_type;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "angle_dynamic.h"
|
||||
|
||||
#include "common/common.h"
|
||||
#include "options/m_config.h"
|
||||
#include "video/out/w32_common.h"
|
||||
#include "context.h"
|
||||
|
||||
@ -36,6 +37,22 @@
|
||||
// Windows 8 enum value, not present in mingw-w64 headers
|
||||
#define DXGI_ADAPTER_FLAG_SOFTWARE (2)
|
||||
|
||||
struct angle_opts {
|
||||
int allow_direct_composition;
|
||||
};
|
||||
|
||||
#define OPT_BASE_STRUCT struct angle_opts
|
||||
const struct m_sub_options angle_conf = {
|
||||
.opts = (const struct m_option[]) {
|
||||
OPT_FLAG("opengl-dcomposition", allow_direct_composition, 0),
|
||||
{0}
|
||||
},
|
||||
.defaults = &(const struct angle_opts) {
|
||||
.allow_direct_composition = 1,
|
||||
},
|
||||
.size = sizeof(struct angle_opts),
|
||||
};
|
||||
|
||||
struct priv {
|
||||
EGLDisplay egl_display;
|
||||
EGLContext egl_context;
|
||||
@ -43,6 +60,7 @@ struct priv {
|
||||
bool use_es2;
|
||||
bool sw_adapter_msg_shown;
|
||||
PFNEGLPOSTSUBBUFFERNVPROC eglPostSubBufferNV;
|
||||
struct angle_opts *opts;
|
||||
};
|
||||
|
||||
static void angle_uninit(MPGLContext *ctx)
|
||||
@ -217,6 +235,8 @@ static int angle_init(struct MPGLContext *ctx, int flags)
|
||||
struct priv *p = ctx->priv;
|
||||
struct vo *vo = ctx->vo;
|
||||
|
||||
p->opts = mp_get_config_group(ctx, ctx->global, &angle_conf);
|
||||
|
||||
if (!angle_load()) {
|
||||
MP_VERBOSE(vo, "Failed to load LIBEGL.DLL\n");
|
||||
goto fail;
|
||||
@ -309,7 +329,7 @@ static int angle_init(struct MPGLContext *ctx, int flags)
|
||||
// behavior with some drivers (Intel? symptom - whole desktop is black for
|
||||
// some seconds after spending some minutes in fullscreen and then leaving
|
||||
// fullscreen).
|
||||
if ((flags & VOFLAG_ANGLE_DCOMP) &&
|
||||
if (p->opts->allow_direct_composition &&
|
||||
strstr(exts, "EGL_ANGLE_direct_composition"))
|
||||
{
|
||||
MP_TARRAY_APPEND(NULL, window_attribs, window_attribs_len,
|
||||
|
@ -55,7 +55,6 @@ struct vo_opengl_opts {
|
||||
int allow_sw;
|
||||
int swap_interval;
|
||||
int dwm_flush;
|
||||
int allow_direct_composition;
|
||||
int vsync_fences;
|
||||
char *backend;
|
||||
int es;
|
||||
@ -383,9 +382,6 @@ static int preinit(struct vo *vo)
|
||||
if (p->opts.allow_sw)
|
||||
vo_flags |= VOFLAG_SW;
|
||||
|
||||
if (p->opts.allow_direct_composition)
|
||||
vo_flags |= VOFLAG_ANGLE_DCOMP;
|
||||
|
||||
p->glctx = mpgl_init(vo, p->opts.backend, vo_flags);
|
||||
if (!p->glctx)
|
||||
goto err_out;
|
||||
@ -444,7 +440,6 @@ const struct vo_driver video_out_opengl = {
|
||||
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),
|
||||
@ -459,7 +454,6 @@ const struct vo_driver video_out_opengl = {
|
||||
.priv_defaults = &(const struct gl_priv){
|
||||
.opts = {
|
||||
.swap_interval = 1,
|
||||
.allow_direct_composition = 1,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user