aboutsummaryrefslogtreecommitdiffstats
path: root/src/glx/create_context.c
diff options
context:
space:
mode:
authorAdam Jackson <[email protected]>2017-11-14 15:13:06 -0500
committerAdam Jackson <[email protected]>2019-09-23 20:39:01 -0400
commit0d635ccc912d7122f35f81eec27d8b2c0a2a7a28 (patch)
tree69828bd7c50e62140760e5464fc6947f324264a9 /src/glx/create_context.c
parent999c2aed8826f403b071f52b040ce25b56d35f9d (diff)
glx: Implement GLX_EXT_no_config_context
This is the GLX counterpart to EGL_KHR_no_config_context. Contexts may now be created without reference to an fbconfig, in which case it is treated as compatible with any fbconfig (and thus any GLX drawable). Khronos: https://github.com/KhronosGroup/OpenGL-Registry/pull/102 Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glx/create_context.c')
-rw-r--r--src/glx/create_context.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/src/glx/create_context.c b/src/glx/create_context.c
index 38e949ab4cd..fa15d551af0 100644
--- a/src/glx/create_context.c
+++ b/src/glx/create_context.c
@@ -33,6 +33,14 @@
#error This code requires sizeof(uint32_t) == sizeof(int).
#endif
+/* debian stretch still has ancient headers and we're apparently still
+ * using that for gitlab ci. please delete me when that's fixed.
+ */
+#ifndef X_GLXCreateContextAttribsARB
+#warning Please update your GLX protocol headers
+#define X_GLXCreateContextAttribsARB 34
+#endif
+
_X_HIDDEN GLXContext
glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
GLXContext share_context, Bool direct,
@@ -47,21 +55,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 +68,29 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
/* empty */ ;
}
+ if (cfg) {
+ screen = cfg->screen;
+ } else {
+ for (unsigned int i = 0; i < num_attribs; i++) {
+ if (attrib_list[i * 2] == GLX_SCREEN)
+ screen = attrib_list[i * 2 + 1];
+ }
+ if (screen == -1) {
+ __glXSendError(dpy, BadValue, 0, X_GLXCreateContextAttribsARB, True);
+ 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, 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 +125,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,