History

opengl: add --egl-config-id

Misaki Kasumi committed 2 years ago

Commit cd74f8f1 parent fe709c95 files · +48 −10Browse files

Unified · Split

5 files
  1. DOCS/interface-changes/egl-output-format.txt +1 −0
  2. DOCS/man/options.rst +6 −0
  3. options/options.c +5 −0
  4. options/options.h +1 −0
  5. video/out/opengl/egl_helpers.c +35 −10
DOCS/interface-changes/egl-output-format.txt+1−0
@@ -0,0 +1 @@
1+add `--egl-config-id` option
DOCS/man/options.rst+6−0
@@ -5716,6 +5716,12 @@ them. · 5715 unmodified lines
57165716 results, as can missing or incorrect display FPS information (see
57175717 ``--display-fps-override``).
57185718
5719+``--egl-config-id=<ID>``
5720+ (EGL only)
5721+ Select EGLConfig with specific EGL_CONFIG_ID.
5722+ Rendering surfaces and contexts will be created using this EGLConfig.
5723+ You can use ``--msg-level=vo=trace`` to obtain a list of available configs.
5724+
57195725 ``--vulkan-device=<device name|UUID>``
57205726 The name or UUID of the Vulkan device to use for rendering and presentation. Use
57215727 ``--vulkan-device=help`` to see the list of available devices and their
options/options.c+5−0
@@ -100,6 +100,7 @@ extern const struct m_sub_options macos_conf; · 99 unmodified lines
100100 extern const struct m_sub_options wayland_conf;
101101 extern const struct m_sub_options wingl_conf;
102102 extern const struct m_sub_options vaapi_conf;
103+extern const struct m_sub_options egl_conf;
103104
104105 static const struct m_sub_options screenshot_conf = {
105106 .opts = image_writer_opts,
@@ -903,6 +904,10 @@ static const m_option_t mp_opts[] = { · 797 unmodified lines
903904 {"", OPT_SUBSTRUCT(opengl_opts, opengl_conf)},
904905 #endif
905906
907+#if HAVE_EGL || HAVE_EGL_ANDROID || HAVE_EGL_ANGLE_WIN32
908+ {"", OPT_SUBSTRUCT(egl_opts, egl_conf)},
909+#endif
910+
906911 #if HAVE_VULKAN
907912 {"", OPT_SUBSTRUCT(vulkan_opts, vulkan_conf)},
908913 #if HAVE_VK_KHR_DISPLAY
options/options.h+1−0
@@ -389,6 +389,7 @@ typedef struct MPOpts { · 388 unmodified lines
389389 struct vaapi_opts *vaapi_opts;
390390 struct sws_opts *sws_opts;
391391 struct zimg_opts *zimg_opts;
392+ struct egl_opts *egl_opts;
392393
393394 int cuda_device;
394395 } MPOpts;
video/out/opengl/egl_helpers.c+35−10
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 */
1717
1818 #include "config.h"
19+#include "options/m_config.h"
1920
2021 #if HAVE_LIBDL
2122 #include <dlfcn.h>
@@ -100,8 +101,21 @@ static void *mpegl_get_proc_address(void *ctx, const char *name) · 78 unmodified lines
100101 return p;
101102 }
102103
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+
103117 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,
105119 EGLContext *out_context, EGLConfig *out_config)
106120 {
107121 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
136150 EGL_RENDERABLE_TYPE, rend,
137151 EGL_NONE
138152 };
153+ if (opts->config_id) {
154+ attributes[0] = EGL_CONFIG_ID;
155+ attributes[1] = opts->config_id;
156+ attributes[2] = EGL_NONE;
157+ }
139158
140159 EGLint num_configs;
141160 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
243262
244263 enum gles_mode mode = ra_gl_ctx_get_glesmode(ctx);
245264
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);
249273
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+ }
253280
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;
257282 }
258283
259284 static int GLAPIENTRY swap_interval(int interval)

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