diff options
author | Niklas Haas <git@haasn.xyz> | 2021-04-18 11:48:35 +0200 |
---|---|---|
committer | Niklas Haas <github-daiK1o@haasn.dev> | 2021-11-03 14:09:27 +0100 |
commit | 432581b60485433d5497d461730960fa3a2af402 (patch) | |
tree | 2500cf6d6f2e1abd9d3e8256c1843f9beb8a39c0 /video/out/gpu/context.c | |
parent | 5512f53722a46dd7b4844ca8f7e47b5fed2d7259 (diff) | |
download | mpv-432581b60485433d5497d461730960fa3a2af402.tar.bz2 mpv-432581b60485433d5497d461730960fa3a2af402.tar.xz |
vo_gpu: lift ra_ctx_* opts to a global struct
So I can re-use them for vo_gpu_next.
Diffstat (limited to 'video/out/gpu/context.c')
-rw-r--r-- | video/out/gpu/context.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/video/out/gpu/context.c b/video/out/gpu/context.c index 6e58cce485..e0beb845c2 100644 --- a/video/out/gpu/context.c +++ b/video/out/gpu/context.c @@ -112,8 +112,8 @@ static const struct ra_ctx_fns *contexts[] = { #endif }; -int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt, - struct bstr name) +static int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt, + struct bstr name) { mp_info(log, "GPU APIs (contexts):\n"); mp_info(log, " auto (autodetect)\n"); @@ -122,8 +122,8 @@ int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt, return M_OPT_EXIT; } -int ra_ctx_validate_api(struct mp_log *log, const struct m_option *opt, - struct bstr name, const char **value) +static int ra_ctx_validate_api(struct mp_log *log, const struct m_option *opt, + struct bstr name, const char **value) { struct bstr param = bstr0(*value); if (bstr_equals0(param, "auto")) @@ -135,8 +135,8 @@ int ra_ctx_validate_api(struct mp_log *log, const struct m_option *opt, return M_OPT_INVALID; } -int ra_ctx_context_help(struct mp_log *log, const struct m_option *opt, - struct bstr name) +static int ra_ctx_context_help(struct mp_log *log, const struct m_option *opt, + struct bstr name) { mp_info(log, "GPU contexts (APIs):\n"); mp_info(log, " auto (autodetect)\n"); @@ -145,8 +145,8 @@ int ra_ctx_context_help(struct mp_log *log, const struct m_option *opt, return M_OPT_EXIT; } -int ra_ctx_validate_context(struct mp_log *log, const struct m_option *opt, - struct bstr name, const char **value) +static int ra_ctx_validate_context(struct mp_log *log, const struct m_option *opt, + struct bstr name, const char **value) { struct bstr param = bstr0(*value); if (bstr_equals0(param, "auto")) @@ -160,11 +160,10 @@ int ra_ctx_validate_context(struct mp_log *log, const struct m_option *opt, // Create a VO window and create a RA context on it. // vo_flags: passed to the backend's create window function -struct ra_ctx *ra_ctx_create(struct vo *vo, const char *context_type, - const char *context_name, struct ra_ctx_opts opts) +struct ra_ctx *ra_ctx_create(struct vo *vo, struct ra_ctx_opts opts) { - bool api_auto = !context_type || strcmp(context_type, "auto") == 0; - bool ctx_auto = !context_name || strcmp(context_name, "auto") == 0; + bool api_auto = !opts.context_type || strcmp(opts.context_type, "auto") == 0; + bool ctx_auto = !opts.context_name || strcmp(opts.context_name, "auto") == 0; if (ctx_auto) { MP_VERBOSE(vo, "Probing for best GPU context.\n"); @@ -177,9 +176,9 @@ struct ra_ctx *ra_ctx_create(struct vo *vo, const char *context_type, vo->probing = opts.probing; for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) { - if (!opts.probing && strcmp(contexts[i]->name, context_name) != 0) + if (!opts.probing && strcmp(contexts[i]->name, opts.context_name) != 0) continue; - if (!api_auto && strcmp(contexts[i]->type, context_type) != 0) + if (!api_auto && strcmp(contexts[i]->type, opts.context_type) != 0) continue; struct ra_ctx *ctx = talloc_ptrtype(NULL, ctx); @@ -223,3 +222,19 @@ void ra_ctx_destroy(struct ra_ctx **ctx_ptr) *ctx_ptr = NULL; } + +#define OPT_BASE_STRUCT struct ra_ctx_opts +const struct m_sub_options ra_ctx_conf = { + .opts = (const m_option_t[]) { + {"gpu-context", + OPT_STRING_VALIDATE(context_name, ra_ctx_validate_context), + .help = ra_ctx_context_help}, + {"gpu-api", + OPT_STRING_VALIDATE(context_type, ra_ctx_validate_api), + .help = ra_ctx_api_help}, + {"gpu-debug", OPT_FLAG(debug)}, + {"gpu-sw", OPT_FLAG(allow_sw)}, + {0} + }, + .size = sizeof(struct ra_ctx_opts), +}; |