History

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.

nanahi committed 2 years ago

Commit a6ff3341 parent 96e1f1d1 file · +21 −5Browse files

Unified · Split

video/out/gpu/context.c+21−5
@@ -57,7 +57,27 @@ extern const struct ra_ctx_fns ra_ctx_d3d11; · 56 unmodified lines
5757 /* No API */
5858 extern const struct ra_ctx_fns ra_ctx_wldmabuf;
5959
60+/* Autoprobe dummy. Always fails to create. */
61+static bool dummy_init(struct ra_ctx *ctx)
62+{
63+ return false;
64+}
65+
66+static void dummy_uninit(struct ra_ctx *ctx)
67+{
68+}
69+
70+static const struct ra_ctx_fns ra_ctx_dummy = {
71+ .type = "auto",
72+ .name = "auto",
73+ .description = "Auto detect",
74+ .init = dummy_init,
75+ .uninit = dummy_uninit,
76+};
77+
6078 static const struct ra_ctx_fns *contexts[] = {
79+ &ra_ctx_dummy,
80+// Direct3D contexts:
6181 #if HAVE_D3D11
6282 &ra_ctx_d3d11,
6383 #endif
@@ -113,6 +133,7 @@ static const struct ra_ctx_fns *contexts[] = { · 49 unmodified lines
113133 };
114134
115135 static const struct ra_ctx_fns *no_api_contexts[] = {
136+ &ra_ctx_dummy,
116137 /* No API contexts: */
117138 #if HAVE_DMABUF_WAYLAND
118139 &ra_ctx_wldmabuf,
@@ -133,8 +154,6 @@ static bool get_desc(struct m_obj_desc *dst, int index) · 14 unmodified lines
133154 static bool check_unknown_entry(const char *name)
134155 {
135156 struct bstr param = bstr0(name);
136− if (bstr_equals0(param, "auto"))
137− return true;
138157 for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
139158 if (bstr_equals0(param, contexts[i]->name))
140159 return true;
@@ -155,7 +174,6 @@ static int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt, · 14 unmodified lines
155174 struct bstr name)
156175 {
157176 mp_info(log, "GPU APIs (contexts):\n");
158− mp_info(log, " auto (autodetect)\n");
159177 for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++) {
160178 mp_info(log, " %s (%s)\n", contexts[n]->type, contexts[n]->name);
161179 }
@@ -165,8 +183,6 @@ static int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt, · 3 unmodified lines
165183 static inline OPT_STRING_VALIDATE_FUNC(ra_ctx_validate_api)
166184 {
167185 struct bstr param = bstr0(*value);
168− if (bstr_equals0(param, "auto"))
169− return 1;
170186 for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
171187 if (bstr_equals0(param, contexts[i]->type))
172188 return 1;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t