[Mesa-dev] [PATCH] xlib: add support for GLX_ARB_create_context
Roland Scheidegger
sroland at vmware.com
Tue Mar 29 17:13:18 UTC 2016
Am 26.03.2016 um 18:45 schrieb Brian Paul:
> This adds the glXCreateContextAttribsARB() function for the xlib/swrast
> driver. This allows more piglit tests to run with this driver.
>
> For example, without this patch we get:
> $ bin/fbo-generatemipmap-1d -auto
> piglit: error: waffle_config_choose failed due to WAFFLE_ERROR_UNSUPPORTED_
> ON_PLATFORM: GLX_ARB_create_context is required in order to request an OpenGL
> version not equal to the default value 1.0
> piglit: error: Failed to create waffle_config for OpenGL 2.0 Compatibility Context
> piglit: info: Failed to create any GL context
> PIGLIT: {"result": "skip" }
> ---
> src/mesa/drivers/x11/fakeglx.c | 52 ++++++++++++++++++++++++++++++++++++++++++
> src/mesa/drivers/x11/glxapi.c | 20 ++++++++++++++++
> src/mesa/drivers/x11/glxapi.h | 5 ++++
> 3 files changed, 77 insertions(+)
>
> diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
> index 9286f71..80b7176 100644
> --- a/src/mesa/drivers/x11/fakeglx.c
> +++ b/src/mesa/drivers/x11/fakeglx.c
> @@ -74,6 +74,7 @@
> "GLX_MESA_copy_sub_buffer " \
> "GLX_MESA_pixmap_colormap " \
> "GLX_MESA_release_buffers " \
> + "GLX_ARB_create_context " \
> "GLX_ARB_get_proc_address " \
> "GLX_EXT_texture_from_pixmap " \
> "GLX_EXT_visual_info " \
> @@ -2831,6 +2832,56 @@ Fake_glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer)
> }
>
>
> +static GLXContext
> +Fake_glXCreateContextAttribs(Display *dpy, GLXFBConfig config,
> + GLXContext share_context, Bool direct,
> + const int *attrib_list)
> +{
> + XMesaContext xmCtx;
> + XMesaVisual xmvis = (XMesaVisual) config;
> + int i;
> + int major = 0, minor = 0, ctxFlags = 0, profileFlags = 0;
> +
> + for (i = 0; attrib_list[i]; i += 2) {
> + switch (attrib_list[i]) {
> + case GLX_CONTEXT_MAJOR_VERSION_ARB:
> + major = attrib_list[i + 1];
> + break;
> + case GLX_CONTEXT_MINOR_VERSION_ARB:
> + minor = attrib_list[i + 1];
> + break;
> + case GLX_CONTEXT_FLAGS_ARB:
> + ctxFlags = attrib_list[i + 1];
> + break;
> + case GLX_CONTEXT_PROFILE_MASK_ARB:
> + profileFlags = attrib_list[i + 1];
> + break;
> + default:
> + fprintf(stderr, "Bad attribute in glXCreateContextAttribs()\n");
> + return 0;
> + }
> + }
> +
> + if (major * 10 + minor > 21) {
> + /* swrast only supports GL 2.1 and earlier */
> + return 0;
> + }
> +
> + /* These are ignored for now. We'd have to enhance XMesaCreateContext
> + * to take these flags and the version, at least.
> + */
> + (void) ctxFlags;
> + (void) profileFlags;
> +
> + /* deallocate unused windows/buffers */
> + XMesaGarbageCollect(dpy);
> +
> + xmCtx = XMesaCreateContext(xmvis, (XMesaContext) share_context);
> +
> + return (GLXContext) xmCtx;
> +}
> +
> +
> /* silence warning */
> extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
>
> @@ -2990,5 +3041,6 @@ _mesa_GetGLXDispatchTable(void)
> glx.BindTexImageEXT = Fake_glXBindTexImageEXT;
> glx.ReleaseTexImageEXT = Fake_glXReleaseTexImageEXT;
>
> + glx.CreateContextAttribs = Fake_glXCreateContextAttribs;
> return &glx;
> }
> diff --git a/src/mesa/drivers/x11/glxapi.c b/src/mesa/drivers/x11/glxapi.c
> index a870e94..cc1bb2a 100644
> --- a/src/mesa/drivers/x11/glxapi.c
> +++ b/src/mesa/drivers/x11/glxapi.c
> @@ -1319,6 +1319,9 @@ static struct name_address_pair GLX_functions[] = {
> { "glXBindTexImageEXT", (__GLXextFuncPtr) glXBindTexImageEXT },
> { "glXReleaseTexImageEXT", (__GLXextFuncPtr) glXReleaseTexImageEXT },
>
> + /*** GLX_ARB_create_context ***/
> + { "glXCreateContextAttribsARB", (__GLXextFuncPtr) glXCreateContextAttribsARB },
> +
> { NULL, NULL } /* end of list */
> };
>
> @@ -1370,3 +1373,20 @@ void PUBLIC
> {
> return glXGetProcAddressARB(procName);
> }
> +
> +
> +/**
> + * Added in GLX_ARB_create_context.
> + */
> +GLXContext PUBLIC
> +glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
> + GLXContext share_context, Bool direct,
> + const int *attrib_list)
> +{
> + struct _glxapi_table *t;
> + GET_DISPATCH(dpy, t);
> + if (!t)
> + return 0;
> + return (t->CreateContextAttribs)(dpy, config, share_context, direct,
> + attrib_list);
> +}
> diff --git a/src/mesa/drivers/x11/glxapi.h b/src/mesa/drivers/x11/glxapi.h
> index bd6e970..aff38f7 100644
> --- a/src/mesa/drivers/x11/glxapi.h
> +++ b/src/mesa/drivers/x11/glxapi.h
> @@ -201,6 +201,11 @@ struct _glxapi_table {
> void (*BindTexImageEXT)(Display *dpy, GLXDrawable drawable, int buffer,
> const int *attrib_list);
> void (*ReleaseTexImageEXT)(Display *dpy, GLXDrawable drawable, int buffer);
> +
> + /*** GLX_ARB_create_context ***/
> + GLXContext (*CreateContextAttribs)(Display *dpy, GLXFBConfig config,
> + GLXContext share_context, Bool direct,
> + const int *attrib_list);
> };
>
>
>
The idea looks right to me but I don't really know this code.
Acked-by: Roland Scheidegger <sroland at vmware.com>
More information about the mesa-dev
mailing list