mirror of https://github.com/mpv-player/mpv
video/out/gpu/context: don't use hidden flag for contexts
For contexts that have no API, just use a separate list for them. This keeps validate func for the main contexts simpler.
This commit is contained in:
parent
fefa1b6645
commit
d5ec069829
|
@ -110,7 +110,9 @@ static const struct ra_ctx_fns *contexts[] = {
|
|||
&ra_ctx_vulkan_mac,
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
static const struct ra_ctx_fns *no_api_contexts[] = {
|
||||
/* No API contexts: */
|
||||
#if HAVE_DMABUF_WAYLAND
|
||||
&ra_ctx_wldmabuf,
|
||||
|
@ -123,8 +125,7 @@ static int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt,
|
|||
mp_info(log, "GPU APIs (contexts):\n");
|
||||
mp_info(log, " auto (autodetect)\n");
|
||||
for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++) {
|
||||
if (!contexts[n]->hidden)
|
||||
mp_info(log, " %s (%s)\n", contexts[n]->type, contexts[n]->name);
|
||||
mp_info(log, " %s (%s)\n", contexts[n]->type, contexts[n]->name);
|
||||
}
|
||||
return M_OPT_EXIT;
|
||||
}
|
||||
|
@ -135,7 +136,7 @@ static inline OPT_STRING_VALIDATE_FUNC(ra_ctx_validate_api)
|
|||
if (bstr_equals0(param, "auto"))
|
||||
return 1;
|
||||
for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
|
||||
if (bstr_equals0(param, contexts[i]->type) && !contexts[i]->hidden)
|
||||
if (bstr_equals0(param, contexts[i]->type))
|
||||
return 1;
|
||||
}
|
||||
return M_OPT_INVALID;
|
||||
|
@ -147,8 +148,7 @@ static int ra_ctx_context_help(struct mp_log *log, const struct m_option *opt,
|
|||
mp_info(log, "GPU contexts (APIs):\n");
|
||||
mp_info(log, " auto (autodetect)\n");
|
||||
for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++) {
|
||||
if (!contexts[n]->hidden)
|
||||
mp_info(log, " %s (%s)\n", contexts[n]->name, contexts[n]->type);
|
||||
mp_info(log, " %s (%s)\n", contexts[n]->name, contexts[n]->type);
|
||||
}
|
||||
return M_OPT_EXIT;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ static inline OPT_STRING_VALIDATE_FUNC(ra_ctx_validate_context)
|
|||
if (bstr_equals0(param, "auto"))
|
||||
return 1;
|
||||
for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
|
||||
if (bstr_equals0(param, contexts[i]->name) && !contexts[i]->hidden)
|
||||
if (bstr_equals0(param, contexts[i]->name))
|
||||
return 1;
|
||||
}
|
||||
return M_OPT_INVALID;
|
||||
|
@ -183,8 +183,6 @@ struct ra_ctx *ra_ctx_create(struct vo *vo, struct ra_ctx_opts opts)
|
|||
vo->probing = opts.probing;
|
||||
|
||||
for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
|
||||
if (contexts[i]->hidden)
|
||||
continue;
|
||||
if (!opts.probing && strcmp(contexts[i]->name, opts.context_name) != 0)
|
||||
continue;
|
||||
if (!api_auto && strcmp(contexts[i]->type, opts.context_type) != 0)
|
||||
|
@ -218,28 +216,40 @@ struct ra_ctx *ra_ctx_create(struct vo *vo, struct ra_ctx_opts opts)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct ra_ctx *ra_ctx_create_by_name(struct vo *vo, const char *name)
|
||||
static struct ra_ctx *create_in_contexts(struct vo *vo, const char *name,
|
||||
const struct ra_ctx_fns *ctxs[],
|
||||
size_t size)
|
||||
{
|
||||
for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
|
||||
if (strcmp(name, contexts[i]->name) != 0)
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (strcmp(name, ctxs[i]->name) != 0)
|
||||
continue;
|
||||
|
||||
struct ra_ctx *ctx = talloc_ptrtype(NULL, ctx);
|
||||
*ctx = (struct ra_ctx) {
|
||||
.vo = vo,
|
||||
.global = vo->global,
|
||||
.log = mp_log_new(ctx, vo->log, contexts[i]->type),
|
||||
.fns = contexts[i],
|
||||
.log = mp_log_new(ctx, vo->log, ctxs[i]->type),
|
||||
.fns = ctxs[i],
|
||||
};
|
||||
|
||||
MP_VERBOSE(ctx, "Initializing GPU context '%s'\n", ctx->fns->name);
|
||||
if (contexts[i]->init(ctx))
|
||||
if (ctxs[i]->init(ctx))
|
||||
return ctx;
|
||||
talloc_free(ctx);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct ra_ctx *ra_ctx_create_by_name(struct vo *vo, const char *name)
|
||||
{
|
||||
struct ra_ctx *ctx = create_in_contexts(vo, name, contexts,
|
||||
MP_ARRAY_SIZE(contexts));
|
||||
if (ctx)
|
||||
return ctx;
|
||||
return create_in_contexts(vo, name, no_api_contexts,
|
||||
MP_ARRAY_SIZE(no_api_contexts));
|
||||
}
|
||||
|
||||
void ra_ctx_destroy(struct ra_ctx **ctx_ptr)
|
||||
{
|
||||
struct ra_ctx *ctx = *ctx_ptr;
|
||||
|
|
|
@ -35,8 +35,6 @@ struct ra_ctx_fns {
|
|||
const char *type; // API type (for --gpu-api)
|
||||
const char *name; // name (for --gpu-context)
|
||||
|
||||
bool hidden; // hide the ra_ctx from users
|
||||
|
||||
// Resize the window, or create a new window if there isn't one yet.
|
||||
// Currently, there is an unfortunate interaction with ctx->vo, and
|
||||
// display size etc. are determined by it.
|
||||
|
|
|
@ -37,7 +37,6 @@ static bool init(struct ra_ctx *ctx)
|
|||
const struct ra_ctx_fns ra_ctx_wldmabuf = {
|
||||
.type = "none",
|
||||
.name = "wldmabuf",
|
||||
.hidden = true,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue