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.
Unified · Split
| @@ -57,7 +57,27 @@ extern const struct ra_ctx_fns ra_ctx_d3d11; · 56 unmodified lines | ||
| 57 | 57 | /* No API */ |
| 58 | 58 | extern const struct ra_ctx_fns ra_ctx_wldmabuf; |
| 59 | 59 | |
| 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 | + | |
| 60 | 78 | static const struct ra_ctx_fns *contexts[] = { |
| 79 | + &ra_ctx_dummy, | |
| 80 | +// Direct3D contexts: | |
| 61 | 81 | #if HAVE_D3D11 |
| 62 | 82 | &ra_ctx_d3d11, |
| 63 | 83 | #endif |
| @@ -113,6 +133,7 @@ static const struct ra_ctx_fns *contexts[] = { · 49 unmodified lines | ||
| 113 | 133 | }; |
| 114 | 134 | |
| 115 | 135 | static const struct ra_ctx_fns *no_api_contexts[] = { |
| 136 | + &ra_ctx_dummy, | |
| 116 | 137 | /* No API contexts: */ |
| 117 | 138 | #if HAVE_DMABUF_WAYLAND |
| 118 | 139 | &ra_ctx_wldmabuf, |
| @@ -133,8 +154,6 @@ static bool get_desc(struct m_obj_desc *dst, int index) · 14 unmodified lines | ||
| 133 | 154 | static bool check_unknown_entry(const char *name) |
| 134 | 155 | { |
| 135 | 156 | struct bstr param = bstr0(name); |
| 136 | − if (bstr_equals0(param, "auto")) | |
| 137 | − return true; | |
| 138 | 157 | for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) { |
| 139 | 158 | if (bstr_equals0(param, contexts[i]->name)) |
| 140 | 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 | 174 | struct bstr name) |
| 156 | 175 | { |
| 157 | 176 | mp_info(log, "GPU APIs (contexts):\n"); |
| 158 | − mp_info(log, " auto (autodetect)\n"); | |
| 159 | 177 | for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++) { |
| 160 | 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 | ||
| 165 | 183 | static inline OPT_STRING_VALIDATE_FUNC(ra_ctx_validate_api) |
| 166 | 184 | { |
| 167 | 185 | struct bstr param = bstr0(*value); |
| 168 | − if (bstr_equals0(param, "auto")) | |
| 169 | − return 1; | |
| 170 | 186 | for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) { |
| 171 | 187 | if (bstr_equals0(param, contexts[i]->type)) |
| 172 | 188 | return 1; |