[Mesa-dev] [PATCH 2/2] glx: Implement GLX_EXT_no_config_context

Adam Jackson ajax at redhat.com
Thu Sep 21 19:59:55 UTC 2017


This more or less ports EGL_KHR_no_config_context to GLX.

This is currently a draft extension, under review at:

https://github.com/KhronosGroup/OpenGL-Registry/pull/102

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 src/glx/create_context.c | 37 +++++++++++++++++++++++--------------
 src/glx/glxextensions.c  |  1 +
 src/glx/glxextensions.h  |  1 +
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/src/glx/create_context.c b/src/glx/create_context.c
index 38e949ab4c..d855699743 100644
--- a/src/glx/create_context.c
+++ b/src/glx/create_context.c
@@ -47,21 +47,11 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
    xcb_generic_error_t *err;
    xcb_void_cookie_t cookie;
    unsigned dummy_err = 0;
+   int screen = -1;
 
-
-   if (dpy == NULL || cfg == NULL)
-      return NULL;
-
-   /* This means that either the caller passed the wrong display pointer or
-    * one of the internal GLX data structures (probably the fbconfig) has an
-    * error.  There is nothing sensible to do, so return an error.
-    */
-   psc = GetGLXScreenConfigs(dpy, cfg->screen);
-   if (psc == NULL)
+   if (dpy == NULL)
       return NULL;
 
-   assert(cfg->screen == psc->scr);
-
    /* Count the number of attributes specified by the application.  All
     * attributes appear in pairs, except the terminating None.
     */
@@ -70,6 +60,25 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
 	 /* empty */ ;
    }
 
+   if (cfg) {
+      screen = cfg->screen;
+   } else {
+      int i;
+      for (i = 0; i < num_attribs; i++)
+         if (attrib_list[i * 2] == GLX_SCREEN)
+            screen = attrib_list[i * 2 + 1];
+   }
+
+   /* This means that either the caller passed the wrong display pointer or
+    * one of the internal GLX data structures (probably the fbconfig) has an
+    * error.  There is nothing sensible to do, so return an error.
+    */
+   psc = GetGLXScreenConfigs(dpy, screen);
+   if (psc == NULL)
+      return NULL;
+
+   assert(screen == psc->scr);
+
    if (direct && psc->vtable->create_context_attribs) {
       /* GLX drops the error returned by the driver.  The expectation is that
        * an error will also be returned by the server.  The server's error
@@ -104,8 +113,8 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
    cookie =
       xcb_glx_create_context_attribs_arb_checked(c,
 						 gc->xid,
-						 cfg->fbconfigID,
-						 cfg->screen,
+						 cfg ? cfg->fbconfigID : 0,
+						 screen,
 						 gc->share_xid,
 						 gc->isDirect,
 						 num_attribs,
diff --git a/src/glx/glxextensions.c b/src/glx/glxextensions.c
index 6882e442fe..64f8c2fe16 100644
--- a/src/glx/glxextensions.c
+++ b/src/glx/glxextensions.c
@@ -145,6 +145,7 @@ static const struct extension_info known_glx_extensions[] = {
    { GLX(EXT_fbconfig_packed_float),   VER(0,0), Y, Y, N, N },
    { GLX(EXT_framebuffer_sRGB),        VER(0,0), Y, Y, N, N },
    { GLX(EXT_import_context),          VER(0,0), Y, Y, N, N },
+   { GLX(EXT_no_config_context),       VER(0,0), Y, Y, N, Y },
    { GLX(EXT_texture_from_pixmap),     VER(0,0), Y, N, N, N },
    { GLX(EXT_visual_info),             VER(0,0), Y, Y, N, N },
    { GLX(EXT_visual_rating),           VER(0,0), Y, Y, N, N },
diff --git a/src/glx/glxextensions.h b/src/glx/glxextensions.h
index 6225742da5..52d7dc08eb 100644
--- a/src/glx/glxextensions.h
+++ b/src/glx/glxextensions.h
@@ -49,6 +49,7 @@ enum
    EXT_fbconfig_packed_float_bit,
    EXT_framebuffer_sRGB_bit,
    EXT_import_context_bit,
+   EXT_no_config_context_bit,
    EXT_texture_from_pixmap_bit,
    EXT_visual_info_bit,
    EXT_visual_rating_bit,
-- 
2.13.5



More information about the mesa-dev mailing list