summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-16 20:54:42 +0100
committerwm4 <wm4@nowhere>2019-11-16 20:55:03 +0100
commitaacc1942fb5fb44a0ea92e11e2c18fd24f29c097 (patch)
tree59e77cd0d5852521aba78ced1e4f227132a7bebe
parent73c3dc0a7bc70cba374508d698d57a311b70f175 (diff)
downloadmpv-aacc1942fb5fb44a0ea92e11e2c18fd24f29c097.tar.bz2
mpv-aacc1942fb5fb44a0ea92e11e2c18fd24f29c097.tar.xz
x11: require EGL 1.5 and use eglGetPlatformDisplay()
eglGetPlatform() is a broken API, since it takes a windowing specific argument, yet is supposed to work for multiple APIs at the same time. On Linux, it can take both a X11 "Display" and a "wl_display". Obviously there is no way to specify what kind of display the argument is (it's just a void*). Mesa has _eglNativePlatformDetectNativeDisplay, which does funny stuff to try to guess the display type, including trying to call mincore() to determine whether the pointer can be accessed at all. I guess this recently accidentally broke (as a bug), but on the other hand, maybe it's time to do this properly. The fix is using eglGetPlaformDisplay(). This requires EGL 1.5, plus Mesa needs to support the associated platform extension (EGL_KHR_platform_x11). Since I see no reasonable way to do this in a compatible way, just require that EGL 1.5 is available. The problem is that EGL 1.4 seems to require you to create a display to query EGL version and extension, and you have a chicken-and-egg problem. It's very stupid. Maybe you could jump through some more hoops to get something compatible, but fuck that. Users on "too old" Mesa will fall back to GLX (which we keep around for a regrettable company known by the name of Nvidia). I think Wayland and GBM should do the same. They're sufficiently bleeding-edge that you can expect them to have EGL 1.5. On the other hand, the cursed RPI code will have to stay with a eglGetDisplay(). Speculative fix for #7154. (Rant about EGL follows. Actually I deleted it.)
-rw-r--r--video/out/opengl/context_x11egl.c8
-rw-r--r--wscript12
2 files changed, 12 insertions, 8 deletions
diff --git a/video/out/opengl/context_x11egl.c b/video/out/opengl/context_x11egl.c
index f0cfe378f1..e86b99bb36 100644
--- a/video/out/opengl/context_x11egl.c
+++ b/video/out/opengl/context_x11egl.c
@@ -21,11 +21,6 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#ifndef EGL_VERSION_1_5
-#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD
-#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001
-#endif
-
#include "common/common.h"
#include "video/out/x11_common.h"
#include "context.h"
@@ -109,7 +104,8 @@ static bool mpegl_init(struct ra_ctx *ctx)
if (!vo_x11_init(vo))
goto uninit;
- p->egl_display = eglGetDisplay(vo->x11->display);
+ p->egl_display = eglGetPlatformDisplay(EGL_PLATFORM_X11_KHR,
+ vo->x11->display, NULL);
if (!eglInitialize(p->egl_display, NULL, NULL)) {
MP_MSG(ctx, msgl, "Could not initialize EGL.\n");
goto uninit;
diff --git a/wscript b/wscript
index 24e30b2613..74ece8234a 100644
--- a/wscript
+++ b/wscript
@@ -647,11 +647,19 @@ video_output_features = [
check_cc(fragment=load_fragment('gl_x11.c'),
use=['x11', 'libdl', 'pthreads']))
} , {
+ 'name': '--egl15',
+ 'desc': 'EGL 1.5',
+ 'groups': [ 'gl' ],
+ 'func': compose_checks(
+ check_pkg_config('egl'),
+ check_statement(['EGL/egl.h'], 'int x[EGL_VERSION_1_5]')
+ ),
+ } , {
'name': '--egl-x11',
'desc': 'OpenGL X11 EGL Backend',
- 'deps': 'x11',
+ 'deps': 'x11 && egl15',
'groups': [ 'gl' ],
- 'func': check_pkg_config('egl'),
+ 'func': check_true,
} , {
'name': '--egl-drm',
'desc': 'OpenGL DRM EGL Backend',