st/glx: Implement GLX_EXT_create_context_es2_profile.

apitrace now supports it, and it makes it much easier to test
tracing/replaying on OpenGL ES contexts since
GLX_EXT_create_context_{es2,es}_profile are widely available.

Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
José Fonseca
2014-11-12 12:18:41 +00:00
parent 0cae7ea271
commit 9247509a8d
2 changed files with 54 additions and 37 deletions
@@ -56,6 +56,8 @@
"GLX_ARB_create_context " \
"GLX_ARB_create_context_profile " \
"GLX_ARB_get_proc_address " \
"GLX_EXT_create_context_es_profile " \
"GLX_EXT_create_context_es2_profile " \
"GLX_EXT_texture_from_pixmap " \
"GLX_EXT_visual_info " \
"GLX_EXT_visual_rating " \
@@ -2718,7 +2720,8 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
/* check profileMask */
if (profileMask != GLX_CONTEXT_CORE_PROFILE_BIT_ARB &&
profileMask != GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) {
profileMask != GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB &&
profileMask != GLX_CONTEXT_ES_PROFILE_BIT_EXT) {
return NULL; /* generate BadValue X Error */
}
+50 -36
View File
@@ -866,12 +866,12 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list,
XMesaContext c;
if (!xmdpy)
return NULL;
goto no_xmesa_context;
/* Note: the XMesaContext contains a Mesa struct gl_context struct (inheritance) */
c = (XMesaContext) CALLOC_STRUCT(xmesa_context);
if (!c)
return NULL;
goto no_xmesa_context;
c->xm_visual = v;
c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */
@@ -888,40 +888,56 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list,
if (contextFlags & GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB)
attribs.flags |= ST_CONTEXT_FLAG_ROBUST_ACCESS;
/* There are no profiles before OpenGL 3.2. The
* GLX_ARB_create_context_profile spec says:
*
* "If the requested OpenGL version is less than 3.2,
* GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality of the
* context is determined solely by the requested version."
*
* The spec also says:
*
* "The default value for GLX_CONTEXT_PROFILE_MASK_ARB is
* GLX_CONTEXT_CORE_PROFILE_BIT_ARB."
*
* The spec also says:
*
* "If version 3.1 is requested, the context returned may implement
* any of the following versions:
*
* * Version 3.1. The GL_ARB_compatibility extension may or may not
* be implemented, as determined by the implementation.
* * The core profile of version 3.2 or greater."
*
* and because Mesa doesn't support GL_ARB_compatibility, the only chance to
* honour a 3.1 context is through core profile.
*/
attribs.profile = ST_PROFILE_DEFAULT;
if (((major > 3 || (major == 3 && minor >= 2))
&& ((profileMask & GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) == 0)) ||
(major == 3 && minor == 1))
attribs.profile = ST_PROFILE_OPENGL_CORE;
switch (profileMask) {
case GLX_CONTEXT_CORE_PROFILE_BIT_ARB:
/* There are no profiles before OpenGL 3.2. The
* GLX_ARB_create_context_profile spec says:
*
* "If the requested OpenGL version is less than 3.2,
* GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality
* of the context is determined solely by the requested version."
*/
if (major > 3 || (major == 3 && minor >= 2)) {
attribs.profile = ST_PROFILE_OPENGL_CORE;
break;
}
/* fall-through */
case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:
/*
* The spec also says:
*
* "If version 3.1 is requested, the context returned may implement
* any of the following versions:
*
* * Version 3.1. The GL_ARB_compatibility extension may or may not
* be implemented, as determined by the implementation.
* * The core profile of version 3.2 or greater."
*
* and because Mesa doesn't support GL_ARB_compatibility, the only chance to
* honour a 3.1 context is through core profile.
*/
if (major == 3 && minor == 1) {
attribs.profile = ST_PROFILE_OPENGL_CORE;
} else {
attribs.profile = ST_PROFILE_DEFAULT;
}
break;
case GLX_CONTEXT_ES_PROFILE_BIT_EXT:
if (major >= 2) {
attribs.profile = ST_PROFILE_OPENGL_ES2;
} else {
attribs.profile = ST_PROFILE_OPENGL_ES1;
}
break;
default:
assert(0);
goto no_st;
}
c->st = stapi->create_context(stapi, xmdpy->smapi, &attribs,
&ctx_err, (share_list) ? share_list->st : NULL);
if (c->st == NULL)
goto fail;
goto no_st;
c->st->st_manager_private = (void *) c;
@@ -929,11 +945,9 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list,
return c;
fail:
if (c->st)
c->st->destroy(c->st);
no_st:
free(c);
no_xmesa_context:
return NULL;
}