opengl: add --egl-config-id
This commit is contained in:
1 parent
fe709c986b
commit
cd74f8f7c5
5 files changed
+48
-10
No files matched your search
@@ -0,0 +1 @@
|
||||
add `--egl-config-id` option
|
||||
@@ -5716,6 +5716,12 @@ them.
|
||||
results, as can missing or incorrect display FPS information (see
|
||||
``--display-fps-override``).
|
||||
|
||||
``--egl-config-id=<ID>``
|
||||
(EGL only)
|
||||
Select EGLConfig with specific EGL_CONFIG_ID.
|
||||
Rendering surfaces and contexts will be created using this EGLConfig.
|
||||
You can use ``--msg-level=vo=trace`` to obtain a list of available configs.
|
||||
|
||||
``--vulkan-device=<device name|UUID>``
|
||||
The name or UUID of the Vulkan device to use for rendering and presentation. Use
|
||||
``--vulkan-device=help`` to see the list of available devices and their
|
||||
|
||||
@@ -100,6 +100,7 @@ extern const struct m_sub_options macos_conf;
|
||||
extern const struct m_sub_options wayland_conf;
|
||||
extern const struct m_sub_options wingl_conf;
|
||||
extern const struct m_sub_options vaapi_conf;
|
||||
extern const struct m_sub_options egl_conf;
|
||||
|
||||
static const struct m_sub_options screenshot_conf = {
|
||||
.opts = image_writer_opts,
|
||||
@@ -903,6 +904,10 @@ static const m_option_t mp_opts[] = {
|
||||
{"", OPT_SUBSTRUCT(opengl_opts, opengl_conf)},
|
||||
#endif
|
||||
|
||||
#if HAVE_EGL || HAVE_EGL_ANDROID || HAVE_EGL_ANGLE_WIN32
|
||||
{"", OPT_SUBSTRUCT(egl_opts, egl_conf)},
|
||||
#endif
|
||||
|
||||
#if HAVE_VULKAN
|
||||
{"", OPT_SUBSTRUCT(vulkan_opts, vulkan_conf)},
|
||||
#if HAVE_VK_KHR_DISPLAY
|
||||
|
||||
@@ -389,6 +389,7 @@ typedef struct MPOpts {
|
||||
struct vaapi_opts *vaapi_opts;
|
||||
struct sws_opts *sws_opts;
|
||||
struct zimg_opts *zimg_opts;
|
||||
struct egl_opts *egl_opts;
|
||||
|
||||
int cuda_device;
|
||||
} MPOpts;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "options/m_config.h"
|
||||
|
||||
#if HAVE_LIBDL
|
||||
#include <dlfcn.h>
|
||||
@@ -100,8 +101,21 @@ static void *mpegl_get_proc_address(void *ctx, const char *name)
|
||||
return p;
|
||||
}
|
||||
|
||||
struct egl_opts {
|
||||
int config_id;
|
||||
};
|
||||
|
||||
#define OPT_BASE_STRUCT struct egl_opts
|
||||
const struct m_sub_options egl_conf = {
|
||||
.opts = (const struct m_option[]) {
|
||||
{"egl-config-id", OPT_INT(config_id)},
|
||||
{0},
|
||||
},
|
||||
.size = sizeof(struct egl_opts),
|
||||
};
|
||||
|
||||
static bool create_context(struct ra_ctx *ctx, EGLDisplay display,
|
||||
bool es, struct mpegl_cb cb,
|
||||
bool es, struct mpegl_cb cb, struct egl_opts *opts,
|
||||
EGLContext *out_context, EGLConfig *out_config)
|
||||
{
|
||||
int msgl = ctx->opts.probing ? MSGL_V : MSGL_FATAL;
|
||||
@@ -136,6 +150,11 @@ static bool create_context(struct ra_ctx *ctx, EGLDisplay display,
|
||||
EGL_RENDERABLE_TYPE, rend,
|
||||
EGL_NONE
|
||||
};
|
||||
if (opts->config_id) {
|
||||
attributes[0] = EGL_CONFIG_ID;
|
||||
attributes[1] = opts->config_id;
|
||||
attributes[2] = EGL_NONE;
|
||||
}
|
||||
|
||||
EGLint num_configs;
|
||||
if (!eglChooseConfig(display, attributes, NULL, 0, &num_configs))
|
||||
@@ -243,17 +262,23 @@ bool mpegl_create_context_cb(struct ra_ctx *ctx, EGLDisplay display,
|
||||
|
||||
enum gles_mode mode = ra_gl_ctx_get_glesmode(ctx);
|
||||
|
||||
if ((mode == GLES_NO || mode == GLES_AUTO) &&
|
||||
create_context(ctx, display, false, cb, out_context, out_config))
|
||||
return true;
|
||||
void *tmp = talloc_new(NULL);
|
||||
struct egl_opts *opts = mp_get_config_group(tmp, ctx->global, &egl_conf);
|
||||
|
||||
if ((mode == GLES_YES || mode == GLES_AUTO) &&
|
||||
create_context(ctx, display, true, cb, out_context, out_config))
|
||||
return true;
|
||||
bool r = false;
|
||||
if (!r && (mode == GLES_NO || mode == GLES_AUTO))
|
||||
r = create_context(ctx, display, false, cb, opts, out_context, out_config);
|
||||
if (!r && (mode == GLES_YES || mode == GLES_AUTO))
|
||||
r = create_context(ctx, display, true, cb, opts, out_context, out_config);
|
||||
|
||||
int msgl = ctx->opts.probing ? MSGL_V : MSGL_ERR;
|
||||
MP_MSG(ctx, msgl, "Could not create a GL context.\n");
|
||||
return false;
|
||||
talloc_free(tmp);
|
||||
|
||||
if (!r) {
|
||||
int msgl = ctx->opts.probing ? MSGL_V : MSGL_ERR;
|
||||
MP_MSG(ctx, msgl, "Could not create a GL context.\n");
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int GLAPIENTRY swap_interval(int interval)
|
||||
|
||||
Reference in new issue
Block a user