[PATCH 18/20] glx: Enable GLX_EXT_create_context_es2_profile
Ian Romanick
idr at freedesktop.org
Tue Dec 20 12:31:21 PST 2011
From: Ian Romanick <ian.d.romanick at intel.com>
This extension is only enabled if the underlying driver advertises
support for OpenGL ES 2.0. This happens either through the getAPIMask
function in version 2 of the DRI2 extension or implicity through
version 2 of the DRISW extension.
Since there is no OpenGL ES 2.0 protocol, this extension is marked as
only available with direct-rendering.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/glx/dri2_glx.c | 6 ++++++
src/glx/dri_common.c | 16 ++++++++++++++++
src/glx/drisw_glx.c | 5 +++++
src/glx/glxextensions.c | 11 +++++++++++
src/glx/glxextensions.h | 1 +
5 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 54fea6f..51d45c9 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -923,8 +923,14 @@ dri2BindExtensions(struct dri2_screen *psc, const __DRIextension **extensions)
__glXEnableDirectExtension(&psc->base, "INTEL_swap_event");
if (psc->dri2->base.version >= 3) {
+ const unsigned mask = psc->dri2->getAPIMask(psc->driScreen);
+
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
+
+ if ((mask & (1 << __DRI_API_GLES2)) != 0)
+ __glXEnableDirectExtension(&psc->base,
+ "GLX_EXT_create_context_es2_profile");
}
for (i = 0; extensions[i]; i++) {
diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index 5d50aa9..8feb587 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -488,6 +488,9 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:
*api = __DRI_API_OPENGL;
break;
+ case GLX_CONTEXT_ES2_PROFILE_BIT_EXT:
+ *api = __DRI_API_GLES2;
+ break;
default:
*error = __DRI_CTX_ERROR_BAD_API;
return false;
@@ -517,6 +520,19 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
return false;
}
+ /* The GLX_EXT_create_context_es2_profile spec says:
+ *
+ * "... If the version requested is 2.0, and the
+ * GLX_CONTEXT_ES2_PROFILE_BIT_EXT bit is set in the
+ * GLX_CONTEXT_PROFILE_MASK_ARB attribute (see below), then the context
+ * returned will implement OpenGL ES 2.0. This is the only way in which
+ * an implementation may request an OpenGL ES 2.0 context."
+ */
+ if (*api == __DRI_API_GLES2 && (*major_ver != 2 || *minor_ver != 0)) {
+ *error = __DRI_CTX_ERROR_BAD_API;
+ return false;
+ }
+
*error = __DRI_CTX_ERROR_SUCCESS;
return true;
}
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index cb7f79c..2d83a50 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -598,6 +598,11 @@ 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");
+
+ /* DRISW version >= 2 implies support for OpenGL ES 2.0.
+ */
+ __glXEnableDirectExtension(&psc->base,
+ "GLX_EXT_create_context_es2_profile");
}
/* FIXME: Figure out what other extensions can be ported here from dri2. */
diff --git a/src/glx/glxextensions.c b/src/glx/glxextensions.c
index df5ef5c..73b84dc 100644
--- a/src/glx/glxextensions.c
+++ b/src/glx/glxextensions.c
@@ -80,6 +80,7 @@ static const struct extension_info known_glx_extensions[] = {
{ GLX(EXT_visual_info), VER(0,0), Y, Y, N, N },
{ GLX(EXT_visual_rating), VER(0,0), Y, Y, N, N },
{ GLX(EXT_framebuffer_sRGB), VER(0,0), Y, Y, N, N },
+ { GLX(EXT_create_context_es2_profile), VER(0,0), Y, N, N, Y },
{ GLX(MESA_copy_sub_buffer), VER(0,0), Y, N, N, N },
{ GLX(MESA_multithread_makecurrent),VER(0,0), Y, N, Y, N },
{ GLX(MESA_swap_control), VER(0,0), Y, N, N, Y },
@@ -620,6 +621,16 @@ __glXCalculateUsableExtensions(struct glx_screen * psc,
}
}
+ /* This hack is necessary because GLX_ARB_create_context_profile depends on
+ * server support, but GLX_EXT_create_context_es2_profile is direct-only.
+ * Without this hack, it would be possible to advertise
+ * GLX_EXT_create_context_es2_profile without
+ * GLX_ARB_create_context_profile. That would be a problem.
+ */
+ if (!IS_SET(server_support, ARB_create_context_profile_bit)) {
+ CLR_BIT(usable, EXT_create_context_es2_profile_bit);
+ }
+
psc->effectiveGLXexts = __glXGetStringFromTable(known_glx_extensions,
usable);
}
diff --git a/src/glx/glxextensions.h b/src/glx/glxextensions.h
index f432fdb..cad69a8 100644
--- a/src/glx/glxextensions.h
+++ b/src/glx/glxextensions.h
@@ -42,6 +42,7 @@ enum
EXT_visual_rating_bit,
EXT_import_context_bit,
EXT_framebuffer_sRGB_bit,
+ EXT_create_context_es2_profile_bit,
MESA_copy_sub_buffer_bit,
MESA_depth_float_bit,
MESA_multithread_makecurrent_bit,
--
1.7.6.4
More information about the xorg-devel
mailing list