summaryrefslogtreecommitdiffstats
path: root/video/out/gpu/context.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/gpu/context.c')
-rw-r--r--video/out/gpu/context.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/video/out/gpu/context.c b/video/out/gpu/context.c
index 052e3cdc80..a7bb4175cc 100644
--- a/video/out/gpu/context.c
+++ b/video/out/gpu/context.c
@@ -124,8 +124,10 @@ 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++)
- mp_info(log, " %s (%s)\n", contexts[n]->type, contexts[n]->name);
+ 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);
+ }
return M_OPT_EXIT;
}
@@ -136,7 +138,7 @@ static int ra_ctx_validate_api(struct mp_log *log, const struct m_option *opt,
if (bstr_equals0(param, "auto"))
return 1;
for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
- if (bstr_equals0(param, contexts[i]->type))
+ if (bstr_equals0(param, contexts[i]->type) && !contexts[i]->hidden)
return 1;
}
return M_OPT_INVALID;
@@ -147,8 +149,10 @@ 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++)
- mp_info(log, " %s (%s)\n", contexts[n]->name, contexts[n]->type);
+ 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);
+ }
return M_OPT_EXIT;
}
@@ -159,7 +163,7 @@ static int ra_ctx_validate_context(struct mp_log *log, const struct m_option *op
if (bstr_equals0(param, "auto"))
return 1;
for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
- if (bstr_equals0(param, contexts[i]->name))
+ if (bstr_equals0(param, contexts[i]->name) && !contexts[i]->hidden)
return 1;
}
return M_OPT_INVALID;
@@ -183,6 +187,8 @@ 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)
@@ -215,6 +221,28 @@ 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)
+{
+ for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
+ if (strcmp(name, contexts[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],
+ };
+
+ MP_VERBOSE(ctx, "Initializing GPU context '%s'\n", ctx->fns->name);
+ if (contexts[i]->init(ctx))
+ return ctx;
+ talloc_free(ctx);
+ }
+ return NULL;
+}
+
void ra_ctx_destroy(struct ra_ctx **ctx_ptr)
{
struct ra_ctx *ctx = *ctx_ptr;