summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Versace <chad.versace@linux.intel.com>2012-11-09 14:06:41 -0800
committerChad Versace <chad.versace@linux.intel.com>2012-11-19 08:18:22 -0800
commit5cf8536690226b3bd19d19197fcec501a278703c (patch)
treed56e475147e0d6cbdc74bfab9d846c63af02a2d2
parent243cf7a924eaef78ce0d5150747fae6c3c4e6974 (diff)
egl/dri2: Set error code when dri2CreateContextAttribs fails
When dri2CreateContextContextAttribs failed, eglCreateContext returned NULL yet set the error code to EGL_SUCCESS! The problem was that eglCreateContext ignored the error code returned by driCreateContextAttribs. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=56706 Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index ae082f60fb..1f13d79c69 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -639,6 +639,69 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
return EGL_TRUE;
}
+/**
+ * Set the error code after a call to
+ * dri2_egl_display::dri2::createContextAttribs.
+ */
+static void
+dri2_create_context_attribs_error(int dri_error)
+{
+ EGLint egl_error;
+
+ switch (dri_error) {
+ case __DRI_CTX_ERROR_SUCCESS:
+ return;
+
+ case __DRI_CTX_ERROR_NO_MEMORY:
+ egl_error = EGL_BAD_ALLOC;
+ break;
+
+ /* From the EGL_KHR_create_context spec, section "Errors":
+ *
+ * * If <config> does not support a client API context compatible
+ * with the requested API major and minor version, [...] context flags,
+ * and context reset notification behavior (for client API types where
+ * these attributes are supported), then an EGL_BAD_MATCH error is
+ * generated.
+ *
+ * * If an OpenGL ES context is requested and the values for
+ * attributes EGL_CONTEXT_MAJOR_VERSION_KHR and
+ * EGL_CONTEXT_MINOR_VERSION_KHR specify an OpenGL ES version that
+ * is not defined, than an EGL_BAD_MATCH error is generated.
+ *
+ * * If an OpenGL context is requested, the requested version is
+ * greater than 3.2, and the value for attribute
+ * EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR has no bits set; has any
+ * bits set other than EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR and
+ * EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR; has more than
+ * one of these bits set; or if the implementation does not support
+ * the requested profile, then an EGL_BAD_MATCH error is generated.
+ */
+ case __DRI_CTX_ERROR_BAD_API:
+ case __DRI_CTX_ERROR_BAD_VERSION:
+ case __DRI_CTX_ERROR_BAD_FLAG:
+ egl_error = EGL_BAD_MATCH;
+ break;
+
+ /* From the EGL_KHR_create_context spec, section "Errors":
+ *
+ * * If an attribute name or attribute value in <attrib_list> is not
+ * recognized (including unrecognized bits in bitmask attributes),
+ * then an EGL_BAD_ATTRIBUTE error is generated."
+ */
+ case __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE:
+ case __DRI_CTX_ERROR_UNKNOWN_FLAG:
+ egl_error = EGL_BAD_ATTRIBUTE;
+ break;
+
+ default:
+ assert(0);
+ egl_error = EGL_BAD_MATCH;
+ break;
+ }
+
+ _eglError(egl_error, "dri2_create_context");
+}
/**
* Called via eglCreateContext(), drv->API.CreateContext().
@@ -769,6 +832,7 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
ctx_attribs,
& error,
dri2_ctx);
+ dri2_create_context_attribs_error(error);
} else {
dri2_ctx->dri_context =
dri2_dpy->dri2->createNewContextForAPI(dri2_dpy->dri_screen,