[Mesa-dev] [PATCH 1/3] egl/x11: Honor the EGL_PLATFORM_X11_SCREEN_EXT attribute

Adam Jackson ajax at redhat.com
Wed May 3 15:57:43 UTC 2017


Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 src/egl/drivers/dri2/platform_x11.c |  2 +-
 src/egl/main/egldisplay.c           | 19 ++++++++++++-------
 src/egl/main/egldisplay.h           |  1 +
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 2f1086e28f..c78656a5be 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1191,7 +1191,7 @@ dri2_get_xcb_connection(_EGLDriver *drv, _EGLDisplay *disp,
                         struct dri2_egl_display *dri2_dpy)
 {
    xcb_screen_iterator_t s;
-   int screen = 0;
+   int screen = (uintptr_t)disp->Options.Platform;
    const char *msg;
 
    disp->DriverData = (void *) dri2_dpy;
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index 37711bd869..b047a5de42 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -472,7 +472,7 @@ _eglUnlinkResource(_EGLResource *res, _EGLResourceType type)
 
 #ifdef HAVE_X11_PLATFORM
 static EGLBoolean
-_eglParseX11DisplayAttribList(const EGLint *attrib_list)
+_eglParseX11DisplayAttribList(_EGLDisplay *display, const EGLint *attrib_list)
 {
    int i;
 
@@ -486,11 +486,10 @@ _eglParseX11DisplayAttribList(const EGLint *attrib_list)
 
       /* EGL_EXT_platform_x11 recognizes exactly one attribute,
        * EGL_PLATFORM_X11_SCREEN_EXT, which is optional.
-       * 
-       * Mesa supports connecting to only the default screen, so we reject
-       * screen != 0.
        */
-      if (attrib != EGL_PLATFORM_X11_SCREEN_EXT || value != 0) {
+      if (attrib == EGL_PLATFORM_X11_SCREEN_EXT) {
+         display->Options.Platform = (void *)value;
+      } else {
          _eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
          return EGL_FALSE;
       }
@@ -503,11 +502,17 @@ _EGLDisplay*
 _eglGetX11Display(Display *native_display,
                   const EGLint *attrib_list)
 {
-   if (!_eglParseX11DisplayAttribList(attrib_list)) {
+   _EGLDisplay *display = _eglFindDisplay(_EGL_PLATFORM_X11,
+                                          native_display);
+
+   if (!display)
+      _eglError(EGL_BAD_ALLOC, "eglGetPlatformDisplay");
+
+   if (!_eglParseX11DisplayAttribList(display, attrib_list)) {
       return NULL;
    }
 
-   return _eglFindDisplay(_EGL_PLATFORM_X11, native_display);
+   return display;
 }
 #endif /* HAVE_X11_PLATFORM */
 
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 6c1049d23c..4d3d96e174 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -151,6 +151,7 @@ struct _egl_display
    struct {
       EGLBoolean TestOnly;    /**< Driver should not set fields when true */
       EGLBoolean UseFallback; /**< Use fallback driver (sw or less features) */
+      void *Platform;         /**< Platform-specific options */
    } Options;
 
    /* these fields are set by the driver during init */
-- 
2.12.2



More information about the mesa-dev mailing list