summaryrefslogtreecommitdiffstats
path: root/src/glx/create_context.c
diff options
context:
space:
mode:
authorAdam Jackson <[email protected]>2017-11-07 11:36:53 -0500
committerAdam Jackson <[email protected]>2017-11-09 09:35:30 -0500
commit5293b96b160b904c0e53cbce93679c3aa090f846 (patch)
tree9f5c119dacb8cfe7a150f7f4fd599199130a68cb /src/glx/create_context.c
parent3f66d54a2a59b6f295671ea03aa9f83ce1aee34a (diff)
glx: Implement GLX_EXT_no_config_context (v2)
This more or less ports EGL_KHR_no_config_context to GLX. v2: Enable the extension only for those backends that support it. Khronos: https://github.com/KhronosGroup/OpenGL-Registry/pull/102 Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Adam Jackson <[email protected]>
Diffstat (limited to 'src/glx/create_context.c')
-rw-r--r--src/glx/create_context.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/glx/create_context.c b/src/glx/create_context.c
index 38e949ab4cd..eab6511ad87 100644
--- a/src/glx/create_context.c
+++ b/src/glx/create_context.c
@@ -47,28 +47,41 @@ 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)
+ if (dpy == NULL)
return NULL;
+ /* Count the number of attributes specified by the application. All
+ * attributes appear in pairs, except the terminating None.
+ */
+ if (attrib_list != NULL) {
+ for (/* empty */; attrib_list[num_attribs * 2] != 0; num_attribs++)
+ /* 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, cfg->screen);
+ psc = GetGLXScreenConfigs(dpy, screen);
if (psc == NULL)
return NULL;
- assert(cfg->screen == psc->scr);
+ assert(screen == psc->scr);
- /* Count the number of attributes specified by the application. All
- * attributes appear in pairs, except the terminating None.
- */
- if (attrib_list != NULL) {
- for (/* empty */; attrib_list[num_attribs * 2] != 0; num_attribs++)
- /* empty */ ;
- }
+ if (!cfg && !__glXExtensionBitIsEnabled(psc, EXT_no_config_context_bit))
+ return NULL;
if (direct && psc->vtable->create_context_attribs) {
/* GLX drops the error returned by the driver. The expectation is that
@@ -104,8 +117,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,