summaryrefslogtreecommitdiffstats
path: root/video/out/gpu/context.c
diff options
context:
space:
mode:
authornanahi <130121847+na-na-hi@users.noreply.github.com>2024-04-17 20:26:06 -0400
committerKacper Michajłow <kasper93@gmail.com>2024-04-18 16:28:21 +0200
commita6ff33425dd29fa214ee21c6b32cd283f8a18f64 (patch)
treebdd1ebfc2b87af5a51a7dcdad3ed995931e83fce /video/out/gpu/context.c
parent96e1f1dfa587a4f21e8a7264ab9e28fad7e5739b (diff)
downloadmpv-a6ff33425dd29fa214ee21c6b32cd283f8a18f64.tar.bz2
mpv-a6ff33425dd29fa214ee21c6b32cd283f8a18f64.tar.xz
video/out/gpu/context: add auto dummy context
This adds a dummy context at the start of the context lists, which serves three purposes: - The "auto" option is listed for --gpu-context=help. - Some special handlings of "auto" string are removed. - Make sure that lists have at least one element, so MP_ARRAY_SIZE() works as intended.
Diffstat (limited to 'video/out/gpu/context.c')
-rw-r--r--video/out/gpu/context.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/video/out/gpu/context.c b/video/out/gpu/context.c
index 7eb8185fdc..d6c1eaa242 100644
--- a/video/out/gpu/context.c
+++ b/video/out/gpu/context.c
@@ -57,7 +57,27 @@ extern const struct ra_ctx_fns ra_ctx_d3d11;
/* No API */
extern const struct ra_ctx_fns ra_ctx_wldmabuf;
+/* Autoprobe dummy. Always fails to create. */
+static bool dummy_init(struct ra_ctx *ctx)
+{
+ return false;
+}
+
+static void dummy_uninit(struct ra_ctx *ctx)
+{
+}
+
+static const struct ra_ctx_fns ra_ctx_dummy = {
+ .type = "auto",
+ .name = "auto",
+ .description = "Auto detect",
+ .init = dummy_init,
+ .uninit = dummy_uninit,
+};
+
static const struct ra_ctx_fns *contexts[] = {
+ &ra_ctx_dummy,
+// Direct3D contexts:
#if HAVE_D3D11
&ra_ctx_d3d11,
#endif
@@ -113,6 +133,7 @@ static const struct ra_ctx_fns *contexts[] = {
};
static const struct ra_ctx_fns *no_api_contexts[] = {
+ &ra_ctx_dummy,
/* No API contexts: */
#if HAVE_DMABUF_WAYLAND
&ra_ctx_wldmabuf,
@@ -133,8 +154,6 @@ static bool get_desc(struct m_obj_desc *dst, int index)
static bool check_unknown_entry(const char *name)
{
struct bstr param = bstr0(name);
- if (bstr_equals0(param, "auto"))
- return true;
for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
if (bstr_equals0(param, contexts[i]->name))
return true;
@@ -155,7 +174,6 @@ 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");
for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++) {
mp_info(log, " %s (%s)\n", contexts[n]->type, contexts[n]->name);
}
@@ -165,8 +183,6 @@ static int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt,
static inline OPT_STRING_VALIDATE_FUNC(ra_ctx_validate_api)
{
struct bstr param = bstr0(*value);
- if (bstr_equals0(param, "auto"))
- return 1;
for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
if (bstr_equals0(param, contexts[i]->type))
return 1;