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 @@
1add `--egl-config-id` option
DOCS/man/options.rst+6−0
@@ -5716,6 +5716,12 @@ them. · 5715 unmodified lines
5716 results, as can missing or incorrect display FPS information (see5716 results, as can missing or incorrect display FPS information (see
5717 ``--display-fps-override``).5717 ``--display-fps-override``).
5718 5718
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
5719``--vulkan-device=<device name|UUID>``5725``--vulkan-device=<device name|UUID>``
5720 The name or UUID of the Vulkan device to use for rendering and presentation. Use5726 The name or UUID of the Vulkan device to use for rendering and presentation. Use
5721 ``--vulkan-device=help`` to see the list of available devices and their5727 ``--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
100extern const struct m_sub_options wayland_conf;100extern const struct m_sub_options wayland_conf;
101extern const struct m_sub_options wingl_conf;101extern const struct m_sub_options wingl_conf;
102extern const struct m_sub_options vaapi_conf;102extern const struct m_sub_options vaapi_conf;
103extern const struct m_sub_options egl_conf;
103 104
104static const struct m_sub_options screenshot_conf = {105static const struct m_sub_options screenshot_conf = {
105 .opts = image_writer_opts,106 .opts = image_writer_opts,
@@ -903,6 +904,10 @@ static const m_option_t mp_opts[] = { · 797 unmodified lines
903 {"", OPT_SUBSTRUCT(opengl_opts, opengl_conf)},904 {"", OPT_SUBSTRUCT(opengl_opts, opengl_conf)},
904#endif905#endif
905 906
907#if HAVE_EGL || HAVE_EGL_ANDROID || HAVE_EGL_ANGLE_WIN32
908 {"", OPT_SUBSTRUCT(egl_opts, egl_conf)},
909#endif
910
906#if HAVE_VULKAN911#if HAVE_VULKAN
907 {"", OPT_SUBSTRUCT(vulkan_opts, vulkan_conf)},912 {"", OPT_SUBSTRUCT(vulkan_opts, vulkan_conf)},
908#if HAVE_VK_KHR_DISPLAY913#if HAVE_VK_KHR_DISPLAY
options/options.h+1−0
@@ -389,6 +389,7 @@ typedef struct MPOpts { · 388 unmodified lines
389 struct vaapi_opts *vaapi_opts;389 struct vaapi_opts *vaapi_opts;
390 struct sws_opts *sws_opts;390 struct sws_opts *sws_opts;
391 struct zimg_opts *zimg_opts;391 struct zimg_opts *zimg_opts;
392 struct egl_opts *egl_opts;
392 393
393 int cuda_device;394 int cuda_device;
394} MPOpts;395} MPOpts;
video/out/opengl/egl_helpers.c+35−10
@@ -16,6 +16,7 @@ · 15 unmodified lines
16 */16 */
17 17
18#include "config.h"18#include "config.h"
19#include "options/m_config.h"
19 20
20#if HAVE_LIBDL21#if HAVE_LIBDL
21#include <dlfcn.h>22#include <dlfcn.h>
@@ -100,8 +101,21 @@ static void *mpegl_get_proc_address(void *ctx, const char *name) · 78 unmodified lines
100 return p;101 return p;
101}102}
102 103
104struct egl_opts {
105 int config_id;
106};
107
108#define OPT_BASE_STRUCT struct egl_opts
109const 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
103static bool create_context(struct ra_ctx *ctx, EGLDisplay display,117static 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 EGLContext *out_context, EGLConfig *out_config)119 EGLContext *out_context, EGLConfig *out_config)
106{120{
107 int msgl = ctx->opts.probing ? MSGL_V : MSGL_FATAL;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 EGL_RENDERABLE_TYPE, rend,150 EGL_RENDERABLE_TYPE, rend,
137 EGL_NONE151 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 EGLint num_configs;159 EGLint num_configs;
141 if (!eglChooseConfig(display, attributes, NULL, 0, &num_configs))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 enum gles_mode mode = ra_gl_ctx_get_glesmode(ctx);263 enum gles_mode mode = ra_gl_ctx_get_glesmode(ctx);
245 264
246 if ((mode == GLES_NO || mode == GLES_AUTO) &&265 void *tmp = talloc_new(NULL);
247 create_context(ctx, display, false, cb, out_context, out_config))266 struct egl_opts *opts = mp_get_config_group(tmp, ctx->global, &egl_conf);
248 return true;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) &&274 talloc_free(tmp);
251 create_context(ctx, display, true, cb, out_context, out_config))275
252 return true;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;281 return r;
255 MP_MSG(ctx, msgl, "Could not create a GL context.\n");
256 return false;
257}282}
258 283
259static int GLAPIENTRY swap_interval(int interval)284static 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