summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/context_x11egl.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-30 20:48:30 +0100
committerwm4 <wm4@nowhere>2019-12-16 00:25:51 +0100
commite1586585b4c54b1f76379728e4f1478b2fd5b3ce (patch)
tree56f9ab11a71592d852c37ecc06b3d17873616064 /video/out/opengl/context_x11egl.c
parent4ae43a1c40b2e6f96ce2c62bc5f16d55f91436f5 (diff)
downloadmpv-e1586585b4c54b1f76379728e4f1478b2fd5b3ce.tar.bz2
mpv-e1586585b4c54b1f76379728e4f1478b2fd5b3ce.tar.xz
vo_gpu: opengl: make it work with EGL 1.4
This tries to deal with the crazy EGL situation. The summary is: - using eglGetDisplay() with multiple windowing platforms doesn't really work, but Mesa had an awful hack for it - this hack can be disabled at build time, and some distros sometimes accidentally or intentionally do so - Mesa will probably eventually disable it by default - we switched to eglGetPlatformDisplay(), but this requires EGL 1.5 - the very regrettable graphics company (also known as Nvidia) ships drivers (for old hardware I think) that are EGL 1.4 only - that means even though we "require" EGL 1.5 and link against it, the runtime EGL may be 1.4 - trying to run mpv there crashes in the dynamic linker - so we have to go through some more awful compatibility hacks This commit tries to do it "properly", but using EGL 1.4 as base. The plaform selection mechanism is a messy extension there, which got elevated to core API in 1.5 (but OF COURSE in incompatible ways). I'm not sure whether the EGL 1.5 code path (by parsing the EGL_VERSION) is really needed, but if you ask me, it feels slightly saner not to rely on an EGL 1.4 kludge forever. But maybe this is just an instance of self-harm, since they will most likely never drop or not provide this API. Also, unlike before, we actually check the extension string for the individual platform extensions, because who knows, some EGL implementations might curse us if we pass unknown platform parameters. (But actually, the more I think about this, the more bullshit it is.) X11 and Wayland were the only ones trying to call eglGetPlatformDisplay, so they're the only ones which are adjusted in this commit. Unfortunately, correct function of this commit is unconfirmed. It's possible that it crashes with the old drivers mentioned above. Why didn't they solve it like this: struct native_display { int platform_type; void *native_display; }; Could have kept eglGetDisplay() without all the obnoxious extension BS.
Diffstat (limited to 'video/out/opengl/context_x11egl.c')
-rw-r--r--video/out/opengl/context_x11egl.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/video/out/opengl/context_x11egl.c b/video/out/opengl/context_x11egl.c
index a829aad85e..812718a647 100644
--- a/video/out/opengl/context_x11egl.c
+++ b/video/out/opengl/context_x11egl.c
@@ -28,6 +28,8 @@
#include "oml_sync.h"
#include "utils.h"
+#define EGL_PLATFORM_X11_EXT 0x31D5
+
struct priv {
GL gl;
EGLDisplay egl_display;
@@ -101,8 +103,9 @@ static bool mpegl_init(struct ra_ctx *ctx)
if (!vo_x11_init(vo))
goto uninit;
- p->egl_display = eglGetPlatformDisplay(EGL_PLATFORM_X11_KHR,
- vo->x11->display, NULL);
+ p->egl_display = mpegl_get_display(EGL_PLATFORM_X11_EXT,
+ "EGL_EXT_platform_x11",
+ vo->x11->display);
if (!eglInitialize(p->egl_display, NULL, NULL)) {
MP_MSG(ctx, msgl, "Could not initialize EGL.\n");
goto uninit;