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
57/* No API */57/* No API */
58extern const struct ra_ctx_fns ra_ctx_wldmabuf;58extern const struct ra_ctx_fns ra_ctx_wldmabuf;
59 59
60/* Autoprobe dummy. Always fails to create. */
61static bool dummy_init(struct ra_ctx *ctx)
62{
63 return false;
64}
65
66static void dummy_uninit(struct ra_ctx *ctx)
67{
68}
69
70static 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
60static const struct ra_ctx_fns *contexts[] = {78static const struct ra_ctx_fns *contexts[] = {
79 &ra_ctx_dummy,
80// Direct3D contexts:
61#if HAVE_D3D1181#if HAVE_D3D11
62 &ra_ctx_d3d11,82 &ra_ctx_d3d11,
63#endif83#endif
@@ -113,6 +133,7 @@ static const struct ra_ctx_fns *contexts[] = { · 49 unmodified lines
113};133};
114 134
115static const struct ra_ctx_fns *no_api_contexts[] = {135static const struct ra_ctx_fns *no_api_contexts[] = {
136 &ra_ctx_dummy,
116/* No API contexts: */137/* No API contexts: */
117#if HAVE_DMABUF_WAYLAND138#if HAVE_DMABUF_WAYLAND
118 &ra_ctx_wldmabuf,139 &ra_ctx_wldmabuf,
@@ -133,8 +154,6 @@ static bool get_desc(struct m_obj_desc *dst, int index) · 14 unmodified lines
133static bool check_unknown_entry(const char *name)154static bool check_unknown_entry(const char *name)
134{155{
135 struct bstr param = bstr0(name);156 struct bstr param = bstr0(name);
136 if (bstr_equals0(param, "auto"))
137 return true;
138 for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {157 for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
139 if (bstr_equals0(param, contexts[i]->name))158 if (bstr_equals0(param, contexts[i]->name))
140 return true;159 return true;
@@ -155,7 +174,6 @@ static int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt, · 14 unmodified lines
155 struct bstr name)174 struct bstr name)
156{175{
157 mp_info(log, "GPU APIs (contexts):\n");176 mp_info(log, "GPU APIs (contexts):\n");
158 mp_info(log, " auto (autodetect)\n");
159 for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++) {177 for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++) {
160 mp_info(log, " %s (%s)\n", contexts[n]->type, contexts[n]->name);178 mp_info(log, " %s (%s)\n", contexts[n]->type, contexts[n]->name);
161 }179 }
@@ -165,8 +183,6 @@ static int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt, · 3 unmodified lines
165static inline OPT_STRING_VALIDATE_FUNC(ra_ctx_validate_api)183static inline OPT_STRING_VALIDATE_FUNC(ra_ctx_validate_api)
166{184{
167 struct bstr param = bstr0(*value);185 struct bstr param = bstr0(*value);
168 if (bstr_equals0(param, "auto"))
169 return 1;
170 for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {186 for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
171 if (bstr_equals0(param, contexts[i]->type))187 if (bstr_equals0(param, contexts[i]->type))
172 return 1;188 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