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

Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8999>
This commit is contained in:
Adam Jackson
2017-11-14 15:13:06 -05:00
committed by Marge Bot
parent f9d57207a3
commit 01ba8a8d02
14 changed files with 60 additions and 30 deletions

View File

@@ -57,7 +57,6 @@ glx/glx_ext_import_context/imported context has same context id: fail
glx/glx_ext_import_context/make current, multi process: fail glx/glx_ext_import_context/make current, multi process: fail
glx/glx_ext_import_context/make current, single process: fail glx/glx_ext_import_context/make current, single process: fail
glx/glx_ext_import_context/query context info: fail glx/glx_ext_import_context/query context info: fail
glx/glx_ext_no_config_context/no fbconfig: skip
hiz/hiz-depth-read-fbo-d24-s8: skip hiz/hiz-depth-read-fbo-d24-s8: skip
hiz/hiz-depth-stencil-test-fbo-d24-s8: skip hiz/hiz-depth-stencil-test-fbo-d24-s8: skip
hiz/hiz-depth-test-fbo-d24-s8: skip hiz/hiz-depth-test-fbo-d24-s8: skip

View File

@@ -58,7 +58,6 @@ glx/glx_ext_import_context/imported context has same context id: fail
glx/glx_ext_import_context/make current, multi process: fail glx/glx_ext_import_context/make current, multi process: fail
glx/glx_ext_import_context/make current, single process: fail glx/glx_ext_import_context/make current, single process: fail
glx/glx_ext_import_context/query context info: fail glx/glx_ext_import_context/query context info: fail
glx/glx_ext_no_config_context/no fbconfig: skip
hiz/hiz-depth-read-fbo-d24-s8: skip hiz/hiz-depth-read-fbo-d24-s8: skip
hiz/hiz-depth-read-window-stencil0: crash hiz/hiz-depth-read-window-stencil0: crash
hiz/hiz-depth-read-window-stencil1: crash hiz/hiz-depth-read-window-stencil1: crash

View File

@@ -130,6 +130,9 @@ applegl_create_context(struct glx_screen *psc,
/* TODO: Integrate this with apple_glx_create_context and make /* TODO: Integrate this with apple_glx_create_context and make
* struct apple_glx_context inherit from struct glx_context. */ * struct apple_glx_context inherit from struct glx_context. */
if (!config)
return NULL;
gc = calloc(1, sizeof(*gc)); gc = calloc(1, sizeof(*gc));
if (gc == NULL) if (gc == NULL)
return NULL; return NULL;

View File

@@ -48,20 +48,11 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
xcb_void_cookie_t cookie; xcb_void_cookie_t cookie;
unsigned dummy_err = 0; unsigned dummy_err = 0;
uint32_t xid, share_xid; uint32_t xid, share_xid;
int screen = -1;
if (dpy == NULL || cfg == NULL) if (dpy == NULL)
return 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)
return NULL;
assert(cfg->screen == psc->scr);
/* Count the number of attributes specified by the application. All /* Count the number of attributes specified by the application. All
* attributes appear in pairs, except the terminating None. * attributes appear in pairs, except the terminating None.
*/ */
@@ -70,6 +61,29 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
/* empty */ ; /* 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) { if (direct && psc->vtable->create_context_attribs) {
/* GLX drops the error returned by the driver. The expectation is that /* 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 * an error will also be returned by the server. The server's error
@@ -104,8 +118,8 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
cookie = cookie =
xcb_glx_create_context_attribs_arb_checked(c, xcb_glx_create_context_attribs_arb_checked(c,
xid, xid,
cfg->fbconfigID, cfg ? cfg->fbconfigID : 0,
cfg->screen, screen,
share_xid, share_xid,
gc ? gc->isDirect : direct, gc ? gc->isDirect : direct,
num_attribs, num_attribs,

View File

@@ -1082,6 +1082,7 @@ dri2BindExtensions(struct dri2_screen *psc, struct glx_display * priv,
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context"); __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile"); __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
__glXEnableDirectExtension(&psc->base, "GLX_EXT_no_config_context");
if ((mask & ((1 << __DRI_API_GLES) | if ((mask & ((1 << __DRI_API_GLES) |
(1 << __DRI_API_GLES2) | (1 << __DRI_API_GLES2) |

View File

@@ -740,6 +740,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");
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile"); __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
__glXEnableDirectExtension(&psc->base, "GLX_EXT_no_config_context");
if ((mask & ((1 << __DRI_API_GLES) | if ((mask & ((1 << __DRI_API_GLES) |
(1 << __DRI_API_GLES2) | (1 << __DRI_API_GLES2) |

View File

@@ -506,6 +506,10 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
return false; return false;
} }
break; break;
case GLX_SCREEN:
/* Implies GLX_EXT_no_config_context */
*render_type = GLX_DONT_CARE;
break;
default: default:
/* If an unknown attribute is received, fail. /* If an unknown attribute is received, fail.
*/ */

View File

@@ -748,6 +748,7 @@ driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions)
if (psc->swrast->base.version >= 3) { if (psc->swrast->base.version >= 3) {
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context"); __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile"); __glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
__glXEnableDirectExtension(&psc->base, "GLX_EXT_no_config_context");
/* DRISW version >= 2 implies support for OpenGL ES. /* DRISW version >= 2 implies support for OpenGL ES.
*/ */

View File

@@ -200,7 +200,7 @@ driwindows_create_context_attribs(struct glx_screen *base,
identical values, so far identical values, so far
*/ */
if (!psc->base.driScreen) if (!psc->base.driScreen || !config_base)
return NULL; return NULL;
/* Check the renderType value */ /* Check the renderType value */

View File

@@ -161,7 +161,19 @@ static GLXContext dispatch_CreateContextAttribsARB(Display *dpy,
__GLXvendorInfo *dd; __GLXvendorInfo *dd;
GLXContext ret; GLXContext ret;
if (config) {
dd = GetDispatchFromFBConfig(dpy, 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) if (dd == NULL)
return None; return None;

View File

@@ -237,7 +237,7 @@ validate_renderType_against_config(const struct glx_config *config,
{ {
/* GLX_EXT_no_config_context supports any render type */ /* GLX_EXT_no_config_context supports any render type */
if (!config) if (!config)
return True; return renderType == GLX_DONT_CARE;
switch (renderType) { switch (renderType) {
case GLX_RGBA_TYPE: case GLX_RGBA_TYPE:
@@ -268,6 +268,9 @@ glx_context_init(struct glx_context *gc,
gc->isDirect = GL_TRUE; gc->isDirect = GL_TRUE;
gc->currentContextTag = -1; gc->currentContextTag = -1;
if (!config)
gc->renderType = GLX_DONT_CARE;
return True; return True;
} }
@@ -1361,7 +1364,7 @@ glXGetClientString(Display * dpy, int name)
case GLX_VERSION: case GLX_VERSION:
return (__glXGLXClientVersion); return (__glXGLXClientVersion);
case GLX_EXTENSIONS: case GLX_EXTENSIONS:
return (__glXGetClientExtensions()); return (__glXGetClientExtensions(dpy));
default: default:
return NULL; return NULL;
} }

View File

@@ -96,6 +96,7 @@ static const struct extension_info known_glx_extensions[] = {
{ GLX(EXT_fbconfig_packed_float), Y, N }, { GLX(EXT_fbconfig_packed_float), Y, N },
{ GLX(EXT_framebuffer_sRGB), Y, N }, { GLX(EXT_framebuffer_sRGB), Y, N },
{ GLX(EXT_import_context), Y, N }, { GLX(EXT_import_context), Y, N },
{ GLX(EXT_no_config_context), N, N },
{ GLX(EXT_swap_control), N, Y }, { GLX(EXT_swap_control), N, Y },
{ GLX(EXT_swap_control_tear), N, Y }, { GLX(EXT_swap_control_tear), N, Y },
{ GLX(EXT_texture_from_pixmap), N, N }, { GLX(EXT_texture_from_pixmap), N, N },
@@ -624,7 +625,7 @@ __glXGetStringFromTable(const struct extension_info *ext,
* Get the string of client library supported extensions. * Get the string of client library supported extensions.
*/ */
const char * const char *
__glXGetClientExtensions(void) __glXGetClientExtensions(Display *dpy)
{ {
if (__glXGLXClientExtensions == NULL) { if (__glXGLXClientExtensions == NULL) {
__glXExtensionsCtr(); __glXExtensionsCtr();

View File

@@ -51,6 +51,7 @@ enum
EXT_fbconfig_packed_float_bit, EXT_fbconfig_packed_float_bit,
EXT_framebuffer_sRGB_bit, EXT_framebuffer_sRGB_bit,
EXT_import_context_bit, EXT_import_context_bit,
EXT_no_config_context_bit,
EXT_swap_control_bit, EXT_swap_control_bit,
EXT_swap_control_tear_bit, EXT_swap_control_tear_bit,
EXT_texture_from_pixmap_bit, EXT_texture_from_pixmap_bit,
@@ -259,7 +260,7 @@ struct glx_context;
extern GLboolean __glXExtensionBitIsEnabled(struct glx_screen *psc, extern GLboolean __glXExtensionBitIsEnabled(struct glx_screen *psc,
unsigned bit); unsigned bit);
extern const char *__glXGetClientExtensions(void); extern const char *__glXGetClientExtensions(Display *dpy);
extern void __glXCalculateUsableExtensions(struct glx_screen *psc, extern void __glXCalculateUsableExtensions(struct glx_screen *psc,
GLboolean GLboolean
display_is_direct_capable, display_is_direct_capable,

View File

@@ -196,15 +196,6 @@ TEST_F(glXCreateContextAttribARB_test, NULL_display_returns_None)
EXPECT_EQ(0, fake_glx_context::contexts_allocated); 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) TEST_F(glXCreateContextAttribARB_test, NULL_screen_returns_None)
{ {
delete (fake_glx_screen *)psc; delete (fake_glx_screen *)psc;