[Mesa-dev] [PATCH 3/3] glx: Implement GLX_EXT_no_config_context (v4)
Adam Jackson
ajax at redhat.com
Tue Dec 5 21:22:05 UTC 2017
This more or less ports EGL_KHR_no_config_context to GLX.
v2: Enable the extension only for those backends that support it.
v3: Fix glvnd path and dri2_convert_glx_attribs()
v4: Screeching signedness correctness, and disable a now
inappropriate test.
Khronos: https://github.com/KhronosGroup/OpenGL-Registry/pull/102
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Signed-off-by: Adam Jackson <ajax at redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/glx/applegl_glx.c | 3 +++
src/glx/create_context.c | 37 +++++++++++++++++++------------
src/glx/dri2_glx.c | 1 +
src/glx/dri3_glx.c | 1 +
src/glx/dri_common.c | 4 ++++
src/glx/drisw_glx.c | 1 +
src/glx/driwindows_glx.c | 2 +-
src/glx/g_glxglvnddispatchfuncs.c | 14 +++++++++++-
src/glx/glxcmds.c | 2 +-
src/glx/glxextensions.c | 1 +
src/glx/glxextensions.h | 1 +
src/glx/tests/create_context_unittest.cpp | 9 --------
12 files changed, 50 insertions(+), 26 deletions(-)
diff --git a/src/glx/applegl_glx.c b/src/glx/applegl_glx.c
index c086e5146a..85f70058c6 100644
--- a/src/glx/applegl_glx.c
+++ b/src/glx/applegl_glx.c
@@ -134,6 +134,9 @@ applegl_create_context(struct glx_screen *psc,
/* TODO: Integrate this with apple_glx_create_context and make
* struct apple_glx_context inherit from struct glx_context. */
+ if (!config)
+ return NULL;
+
gc = calloc(1, sizeof(*gc));
if (gc == NULL)
return NULL;
diff --git a/src/glx/create_context.c b/src/glx/create_context.c
index 38e949ab4c..bc39ffef1d 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 {
+ for (unsigned int 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/dri2_glx.c b/src/glx/dri2_glx.c
index 0f44635725..eeec4f0d60 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -1129,6 +1129,7 @@ dri2BindExtensions(struct dri2_screen *psc, struct glx_display * priv,
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
+ __glXEnableDirectExtension(&psc->base, "GLX_EXT_no_config_context");
if ((mask & ((1 << __DRI_API_GLES) |
(1 << __DRI_API_GLES2) |
diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index f280a8cef7..f0560edeb5 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -720,6 +720,7 @@ dri3_bind_extensions(struct dri3_screen *psc, struct glx_display * priv,
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
+ __glXEnableDirectExtension(&psc->base, "GLX_EXT_no_config_context");
if ((mask & ((1 << __DRI_API_GLES) |
(1 << __DRI_API_GLES2) |
diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index ab5d6c5bc0..4930ce35a9 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -562,6 +562,10 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
return false;
}
break;
+ case GLX_SCREEN:
+ /* Implies GLX_EXT_no_config_context */
+ *render_type = GLX_DONT_CARE;
+ break;
default:
/* If an unknown attribute is received, fail.
*/
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index df2467a5c2..e33ac4f2a9 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -628,6 +628,7 @@ driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions)
if (psc->swrast->base.version >= 3) {
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
+ __glXEnableDirectExtension(&psc->base, "GLX_EXT_no_config_context");
/* DRISW version >= 2 implies support for OpenGL ES.
*/
diff --git a/src/glx/driwindows_glx.c b/src/glx/driwindows_glx.c
index 85525431bf..b2dc810f8c 100644
--- a/src/glx/driwindows_glx.c
+++ b/src/glx/driwindows_glx.c
@@ -240,7 +240,7 @@ driwindows_create_context_attribs(struct glx_screen *base,
identical values, so far
*/
- if (!psc->base.driScreen)
+ if (!psc->base.driScreen || !config_base)
return NULL;
/* Check the renderType value */
diff --git a/src/glx/g_glxglvnddispatchfuncs.c b/src/glx/g_glxglvnddispatchfuncs.c
index 56d894eda7..04f6d8263a 100644
--- a/src/glx/g_glxglvnddispatchfuncs.c
+++ b/src/glx/g_glxglvnddispatchfuncs.c
@@ -164,7 +164,19 @@ static GLXContext dispatch_CreateContextAttribsARB(Display *dpy,
__GLXvendorInfo *dd;
GLXContext ret;
- dd = GetDispatchFromFBConfig(dpy, config);
+ if (config) {
+ dd = GetDispatchFromFBConfig(dpy, config);
+ } else if (attrib_list) {
+ int i, screen;
+
+ for (i = 0; attrib_list[i * 2] != None; i++) {
+ if (attrib_list[i * 2] == GLX_SCREEN) {
+ screen = attrib_list[i * 2 + 1];
+ dd = GetDispatchFromDrawable(dpy, RootWindow(dpy, screen));
+ break;
+ }
+ }
+ }
if (dd == NULL)
return None;
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index eee45d962d..bc5333588b 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -237,7 +237,7 @@ validate_renderType_against_config(const struct glx_config *config,
{
/* GLX_EXT_no_config_context supports any render type */
if (!config)
- return True;
+ return renderType == GLX_DONT_CARE;
switch (renderType) {
case GLX_RGBA_TYPE:
diff --git a/src/glx/glxextensions.c b/src/glx/glxextensions.c
index 638d8bcbbe..8cb4771869 100644
--- a/src/glx/glxextensions.c
+++ b/src/glx/glxextensions.c
@@ -146,6 +146,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, N, N, N },
{ 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 d73128bd0e..07cd3af0ff 100644
--- a/src/glx/glxextensions.h
+++ b/src/glx/glxextensions.h
@@ -50,6 +50,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,
diff --git a/src/glx/tests/create_context_unittest.cpp b/src/glx/tests/create_context_unittest.cpp
index a2590589db..d19271b47e 100644
--- a/src/glx/tests/create_context_unittest.cpp
+++ b/src/glx/tests/create_context_unittest.cpp
@@ -172,15 +172,6 @@ TEST_F(glXCreateContextAttribARB_test, NULL_display_returns_None)
EXPECT_EQ(0, fake_glx_context::contexts_allocated);
}
-TEST_F(glXCreateContextAttribARB_test, NULL_fbconfig_returns_None)
-{
- GLXContext ctx =
- glXCreateContextAttribsARB(this->dpy, NULL, 0, False, NULL);
-
- EXPECT_EQ(None, ctx);
- EXPECT_EQ(0, fake_glx_context::contexts_allocated);
-}
-
TEST_F(glXCreateContextAttribARB_test, NULL_screen_returns_None)
{
delete psc;
--
2.14.3
More information about the mesa-dev
mailing list