8aa464b
From c622887701c70dab7b39515e4d48b2ce70822f1a Mon Sep 17 00:00:00 2001
8aa464b
From: Adam Jackson <ajax@redhat.com>
8aa464b
Date: Tue, 4 Oct 2016 13:34:33 -0400
8aa464b
Subject: [PATCH 1/7] glamor: Use eglGetPlatformDisplayEXT not eglGetDisplay
8aa464b
8aa464b
eglGetDisplay forces the implementation to guess which kind of display
8aa464b
it's been handed. glvnd does something different from Mesa, and in
8aa464b
general it's impossible for the library to get this right. Instead use
8aa464b
the API where you specify what kind of display it is.
8aa464b
8aa464b
The explicit call to eglGetProcAddress is to work around a bug in
8aa464b
libepoxy 1.3, which does not understand EGL client extensions and so its
8aa464b
resolver code will crash.
8aa464b
8aa464b
Signed-off-by: Adam Jackson <ajax@redhat.com>
8aa464b
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
8aa464b
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
8aa464b
---
8aa464b
 glamor/glamor_egl.c           | 9 ++++++++-
8aa464b
 hw/xwayland/xwayland-glamor.c | 8 +++++++-
8aa464b
 2 files changed, 15 insertions(+), 2 deletions(-)
8aa464b
8aa464b
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
8aa464b
index 2b9e0e1..51d8147 100644
8aa464b
--- a/glamor/glamor_egl.c
8aa464b
+++ b/glamor/glamor_egl.c
8aa464b
@@ -736,6 +736,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
8aa464b
 {
8aa464b
     struct glamor_egl_screen_private *glamor_egl;
8aa464b
     const char *version;
8aa464b
+    PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay;
8aa464b
 
8aa464b
     EGLint config_attribs[] = {
8aa464b
 #ifdef GLAMOR_GLES2
8aa464b
@@ -768,7 +769,13 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
8aa464b
         ErrorF("couldn't get display device\n");
8aa464b
         goto error;
8aa464b
     }
8aa464b
-    glamor_egl->display = eglGetDisplay(glamor_egl->gbm);
8aa464b
+
8aa464b
+    getPlatformDisplay = (PFNEGLGETPLATFORMDISPLAYEXTPROC)
8aa464b
+        eglGetProcAddress("eglGetPlatformDisplayEXT");
8aa464b
+
8aa464b
+    if (getPlatformDisplay)
8aa464b
+        glamor_egl->display = getPlatformDisplay (EGL_PLATFORM_GBM_MESA,
8aa464b
+                                                  glamor_egl->gbm, NULL);
8aa464b
 #else
8aa464b
     glamor_egl->display = eglGetDisplay((EGLNativeDisplayType) (intptr_t) fd);
8aa464b
 #endif
8aa464b
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
8aa464b
index 068c224..23402f9 100644
8aa464b
--- a/hw/xwayland/xwayland-glamor.c
8aa464b
+++ b/hw/xwayland/xwayland-glamor.c
8aa464b
@@ -280,6 +280,7 @@ xwl_drm_init_egl(struct xwl_screen *xwl_screen)
8aa464b
         GLAMOR_GL_CORE_VER_MINOR,
8aa464b
         EGL_NONE
8aa464b
     };
8aa464b
+    PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay;
8aa464b
 
8aa464b
     if (xwl_screen->egl_display)
8aa464b
         return;
8aa464b
@@ -292,7 +293,12 @@ xwl_drm_init_egl(struct xwl_screen *xwl_screen)
8aa464b
         return;
8aa464b
     }
8aa464b
 
8aa464b
-    xwl_screen->egl_display = eglGetDisplay(xwl_screen->gbm);
8aa464b
+    getPlatformDisplay = (PFNEGLGETPLATFORMDISPLAYEXTPROC)
8aa464b
+        eglGetProcAddress("eglGetPlatformDisplayEXT");
8aa464b
+
8aa464b
+    if (getPlatformDisplay)
8aa464b
+        xwl_screen->egl_display = getPlatformDisplay(EGL_PLATFORM_GBM_MESA,
8aa464b
+                                                     xwl_screen->gbm, NULL);
8aa464b
     if (xwl_screen->egl_display == EGL_NO_DISPLAY) {
8aa464b
         ErrorF("eglGetDisplay() failed\n");
8aa464b
         return;
8aa464b
-- 
8aa464b
2.9.3
8aa464b