| @@ -16,6 +16,7 @@ · 15 unmodified lines |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | #include "config.h" |
| 19 | +#include "options/m_config.h" |
| 19 | 20 | |
| 20 | 21 | #if HAVE_LIBDL |
| 21 | 22 | #include <dlfcn.h> |
| @@ -100,8 +101,21 @@ static void *mpegl_get_proc_address(void *ctx, const char *name) · 78 unmodified lines |
| 100 | 101 | return p; |
| 101 | 102 | } |
| 102 | 103 | |
| 104 | +struct egl_opts { |
| 105 | + int config_id; |
| 106 | +}; |
| 107 | + |
| 108 | +#define OPT_BASE_STRUCT struct egl_opts |
| 109 | +const struct m_sub_options egl_conf = { |
| 110 | + .opts = (const struct m_option[]) { |
| 111 | + {"egl-config-id", OPT_INT(config_id)}, |
| 112 | + {0}, |
| 113 | + }, |
| 114 | + .size = sizeof(struct egl_opts), |
| 115 | +}; |
| 116 | + |
| 103 | 117 | static bool create_context(struct ra_ctx *ctx, EGLDisplay display, |
| 104 | | − bool es, struct mpegl_cb cb, |
| 118 | + bool es, struct mpegl_cb cb, struct egl_opts *opts, |
| 105 | 119 | EGLContext *out_context, EGLConfig *out_config) |
| 106 | 120 | { |
| 107 | 121 | int msgl = ctx->opts.probing ? MSGL_V : MSGL_FATAL; |
| @@ -136,6 +150,11 @@ static bool create_context(struct ra_ctx *ctx, EGLDisplay display, · 28 unmodified lines |
| 136 | 150 | EGL_RENDERABLE_TYPE, rend, |
| 137 | 151 | EGL_NONE |
| 138 | 152 | }; |
| 153 | + if (opts->config_id) { |
| 154 | + attributes[0] = EGL_CONFIG_ID; |
| 155 | + attributes[1] = opts->config_id; |
| 156 | + attributes[2] = EGL_NONE; |
| 157 | + } |
| 139 | 158 | |
| 140 | 159 | EGLint num_configs; |
| 141 | 160 | if (!eglChooseConfig(display, attributes, NULL, 0, &num_configs)) |
| @@ -243,17 +262,23 @@ bool mpegl_create_context_cb(struct ra_ctx *ctx, EGLDisplay display, · 101 unmodified lines |
| 243 | 262 | |
| 244 | 263 | enum gles_mode mode = ra_gl_ctx_get_glesmode(ctx); |
| 245 | 264 | |
| 246 | | − if ((mode == GLES_NO || mode == GLES_AUTO) && |
| 247 | | − create_context(ctx, display, false, cb, out_context, out_config)) |
| 248 | | − return true; |
| 265 | + void *tmp = talloc_new(NULL); |
| 266 | + struct egl_opts *opts = mp_get_config_group(tmp, ctx->global, &egl_conf); |
| 267 | + |
| 268 | + bool r = false; |
| 269 | + if (!r && (mode == GLES_NO || mode == GLES_AUTO)) |
| 270 | + r = create_context(ctx, display, false, cb, opts, out_context, out_config); |
| 271 | + if (!r && (mode == GLES_YES || mode == GLES_AUTO)) |
| 272 | + r = create_context(ctx, display, true, cb, opts, out_context, out_config); |
| 249 | 273 | |
| 250 | | − if ((mode == GLES_YES || mode == GLES_AUTO) && |
| 251 | | − create_context(ctx, display, true, cb, out_context, out_config)) |
| 252 | | − return true; |
| 274 | + talloc_free(tmp); |
| 275 | + |
| 276 | + if (!r) { |
| 277 | + int msgl = ctx->opts.probing ? MSGL_V : MSGL_ERR; |
| 278 | + MP_MSG(ctx, msgl, "Could not create a GL context.\n"); |
| 279 | + } |
| 253 | 280 | |
| 254 | | − int msgl = ctx->opts.probing ? MSGL_V : MSGL_ERR; |
| 255 | | − MP_MSG(ctx, msgl, "Could not create a GL context.\n"); |
| 256 | | − return false; |
| 281 | + return r; |
| 257 | 282 | } |
| 258 | 283 | |
| 259 | 284 | static int GLAPIENTRY swap_interval(int interval) |