/**************************************************************************
*
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008 VMware, Inc.
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
* Copyright 2010-2011 LunarG, Inc.
* All Rights Reserved.
case 2:
bit = EGL_OPENGL_ES2_BIT;
break;
+ case 3:
+ bit = EGL_OPENGL_ES3_BIT_KHR;
+ break;
default:
break;
}
switch (attr) {
case EGL_CONTEXT_CLIENT_VERSION:
+ /* The EGL 1.4 spec says:
+ *
+ * "attribute EGL_CONTEXT_CLIENT_VERSION is only valid when the
+ * current rendering API is EGL_OPENGL_ES_API"
+ *
+ * The EGL_KHR_create_context spec says:
+ *
+ * "EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
+ * (this token is an alias for EGL_CONTEXT_CLIENT_VERSION)"
+ *
+ * "The values for attributes EGL_CONTEXT_MAJOR_VERSION_KHR and
+ * EGL_CONTEXT_MINOR_VERSION_KHR specify the requested client API
+ * version. They are only meaningful for OpenGL and OpenGL ES
+ * contexts, and specifying them for other types of contexts will
+ * generate an error."
+ */
+ if ((api != EGL_OPENGL_ES_API &&
+ (!dpy->Extensions.KHR_create_context || api != EGL_OPENGL_API))) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
ctx->ClientMajorVersion = val;
break;
case EGL_CONTEXT_MINOR_VERSION_KHR:
- if (!dpy->Extensions.KHR_create_context) {
+ /* The EGL_KHR_create_context spec says:
+ *
+ * "The values for attributes EGL_CONTEXT_MAJOR_VERSION_KHR and
+ * EGL_CONTEXT_MINOR_VERSION_KHR specify the requested client API
+ * version. They are only meaningful for OpenGL and OpenGL ES
+ * contexts, and specifying them for other types of contexts will
+ * generate an error."
+ */
+ if (!dpy->Extensions.KHR_create_context ||
+ (api != EGL_OPENGL_ES_API && api != EGL_OPENGL_API)) {
err = EGL_BAD_ATTRIBUTE;
break;
}
/* 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."
+ * "If the EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR flag bit is set in
+ * EGL_CONTEXT_FLAGS_KHR, then a <debug context> will be created.
+ * [...]
+ * In some cases a debug context may be identical to a non-debug
+ * context. This bit is supported for OpenGL and OpenGL ES
+ * contexts."
*/
- if (api != EGL_OPENGL_API && val != 0) {
+ if ((val & EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR) &&
+ (api != EGL_OPENGL_API && api != EGL_OPENGL_ES_API)) {
err = EGL_BAD_ATTRIBUTE;
break;
}
- ctx->Flags = val;
+ /* The EGL_KHR_create_context spec says:
+ *
+ * "If the EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR flag bit
+ * is set in EGL_CONTEXT_FLAGS_KHR, then a <forward-compatible>
+ * context will be created. Forward-compatible contexts are
+ * defined only for OpenGL versions 3.0 and later. They must not
+ * support functionality marked as <deprecated> by that version of
+ * the API, while a non-forward-compatible context must support
+ * all functionality in that version, deprecated or not. This bit
+ * is supported for OpenGL contexts, and requesting a
+ * forward-compatible context for OpenGL versions less than 3.0
+ * will generate an error."
+ */
+ if ((val & EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR) &&
+ (api != EGL_OPENGL_API || ctx->ClientMajorVersion < 3)) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ /* The EGL_KHR_create_context_spec says:
+ *
+ * "If the EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR bit is set in
+ * EGL_CONTEXT_FLAGS_KHR, then a context supporting <robust buffer
+ * access> will be created. Robust buffer access is defined in the
+ * GL_ARB_robustness extension specification, and the resulting
+ * context must also support either the GL_ARB_robustness
+ * extension, or a version of OpenGL incorporating equivalent
+ * functionality. This bit is supported for OpenGL contexts.
+ */
+ if ((val & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) &&
+ (api != EGL_OPENGL_API ||
+ !dpy->Extensions.EXT_create_context_robustness)) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ ctx->Flags |= val;
break;
case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR:
ctx->ResetNotificationStrategy = val;
break;
+ case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
+ /* The EGL_EXT_create_context_robustness spec says:
+ *
+ * "[EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT] is only
+ * meaningful for OpenGL ES contexts, and specifying it for other
+ * types of contexts will generate an EGL_BAD_ATTRIBUTE error."
+ */
+ if (!dpy->Extensions.EXT_create_context_robustness
+ || api != EGL_OPENGL_ES_API) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ ctx->ResetNotificationStrategy = val;
+ break;
+
+ case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
+ if (!dpy->Extensions.EXT_create_context_robustness) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ if (val == EGL_TRUE)
+ ctx->Flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
+ break;
+
+ case EGL_CONTEXT_OPENGL_ROBUST_ACCESS:
+ if (dpy->Version < 15) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ if (val == EGL_TRUE)
+ ctx->Flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
+ break;
+
+ case EGL_CONTEXT_OPENGL_DEBUG:
+ if (dpy->Version < 15) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ if (val == EGL_TRUE)
+ ctx->Flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
+ break;
+
+ case EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE:
+ if (dpy->Version < 15) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ if (val == EGL_TRUE)
+ ctx->Flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
+ break;
+
default:
err = EGL_BAD_ATTRIBUTE;
break;
*
* "* If an OpenGL context is requested, the requested version
* is greater than 3.2, and the value for attribute
- * EGL_CONTEXT_PROFILE_MASK_KHR has no bits set; has any
- * bits set other than EGL_CONTEXT_CORE_PROFILE_BIT_KHR and
- * EGL_CONTEXT_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_PROFILE_KHR error is generated."
- *
- * However, it does not define EGL_BAD_PROFILE_KHR. For now use
- * EGL_BAD_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."
*/
- err = EGL_BAD_ATTRIBUTE;
+ err = EGL_BAD_MATCH;
break;
}
}
break;
case 2:
- default:
+ if (ctx->ClientMinorVersion > 0)
+ err = EGL_BAD_MATCH;
+ break;
+
+ case 3:
/* Don't put additional version checks here. We don't know that
- * there won't be versions > 2.0.
+ * there won't be versions > 3.0.
*/
break;
+
+ default:
+ err = EGL_BAD_MATCH;
+ break;
}
}
break;
}
- if ((ctx->Flags & (EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR
+ if ((ctx->Flags & ~(EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR
| EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR
| EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR)) != 0) {
err = EGL_BAD_ATTRIBUTE;
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
}
- /* simply require the configs to be equal */
- if ((draw && draw->Config != ctx->Config) ||
- (read && read->Config != ctx->Config))
- return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
+ /* If the context has a config then it must match that of the two
+ * surfaces */
+ if (ctx->Config) {
+ if ((draw && draw->Config != ctx->Config) ||
+ (read && read->Config != ctx->Config))
+ return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
+ } else {
+ /* Otherwise we must be using the EGL_MESA_configless_context
+ * extension */
+ assert(dpy->Extensions.MESA_configless_context);
+
+ /* The extension doesn't permit binding draw and read buffers with
+ * differing contexts */
+ if (draw && read && draw->Config != read->Config)
+ return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
+ }
switch (ctx->ClientAPI) {
/* OpenGL and OpenGL ES are conflicting */