diff options
author | José Fonseca <[email protected]> | 2014-11-12 12:18:41 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2014-11-12 19:03:50 +0000 |
commit | 9247509a8d62cb728f469d664cbd6e8a70aa8548 (patch) | |
tree | f3b5e6fdeb5cc3cc1bcac370ca4262c1787a24a0 /src/gallium/state_trackers | |
parent | 0cae7ea2719a939cf91de03a1bfeeeca08ec98a4 (diff) |
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 <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/glx/xlib/glx_api.c | 5 | ||||
-rw-r--r-- | src/gallium/state_trackers/glx/xlib/xm_api.c | 86 |
2 files changed, 54 insertions, 37 deletions
diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 976791b5ea7..810910ef921 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -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 */ } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 1b77729fc48..2aa5ac4f860 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -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; } |