Mesa (master): dri2: Fix bug in attribute handling for non-desktop OpenGL contexts

Ian Romanick idr at kemper.freedesktop.org
Mon Aug 6 22:38:49 UTC 2012


Module: Mesa
Branch: master
Commit: 63adb6b9eaa723f6bf9603f3f567e04451df857e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=63adb6b9eaa723f6bf9603f3f567e04451df857e

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Wed Jul 18 14:26:24 2012 -0700

dri2: Fix bug in attribute handling for non-desktop OpenGL contexts

Previously an error would be generated if any attributes were specified when
creating a non-desktop OpenGL context.  This was a mistake, and it will
prevent old drivers from working with new EGL libraries that add support for
the createContextAttribs interface.  Instead, match the behavior of
EGL_KHR_create_context: allow versions that make sense, reject non-zero flags.

NOTE: This is a candidate for the 8.0 branch.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Kristian Høgsberg <krh at bitplanet.net>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Chad Versace <chad.versace at linux.intel.com>

---

 src/mesa/drivers/dri/common/dri_util.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index f9b2a73..91ae186 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -197,12 +197,6 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api,
 	return NULL;
     }
 
-    if (mesa_api != API_OPENGL && num_attribs != 0) {
-	*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
-	assert(!"Should not get here.");
-	return NULL;
-    }
-
     for (unsigned i = 0; i < num_attribs; i++) {
 	switch (attribs[i * 2]) {
 	case __DRI_CTX_ATTRIB_MAJOR_VERSION:
@@ -224,6 +218,23 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api,
 	}
     }
 
+    /* The EGL_KHR_create_context spec says:
+     *
+     *     "Flags are only defined for OpenGL context creation, and specifying
+     *     a flags value other than zero for other types of contexts,
+     *     including OpenGL ES contexts, will generate an error."
+     *
+     * The GLX_EXT_create_context_es2_profile specification doesn't say
+     * anything specific about this case.  However, none of the known flags
+     * have any meaning in an ES context, so this seems safe.
+     */
+    if (mesa_api != __DRI_API_OPENGL
+        && mesa_api != __DRI_API_OPENGL_CORE
+        && flags != 0) {
+	*error = __DRI_CTX_ERROR_BAD_FLAG;
+	return NULL;
+    }
+
     /* There are no forward-compatible contexts before OpenGL 3.0.  The
      * GLX_ARB_create_context spec says:
      *




More information about the mesa-commit mailing list