+
+ case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR:
+ if (!disp->Extensions.KHR_create_context) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ /* The EGL_KHR_create_context spec says:
+ *
+ * "[EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR] is only meaningful for
+ * OpenGL contexts, and specifying it for other types of
+ * contexts, including OpenGL ES contexts, will generate an
+ * error."
+ */
+ if (api != EGL_OPENGL_API) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ ctx->Profile = val;
+ break;
+
+ case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR:
+ /* The EGL_KHR_create_context spec says:
+ *
+ * "[EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR] is only
+ * meaningful for OpenGL contexts, and specifying it for other
+ * types of contexts, including OpenGL ES contexts, will generate
+ * an error."
+ *
+ * EGL 1.5 defines EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY
+ * (without a suffix) which has the same value as the KHR token,
+ * and specifies that it now works with both GL and ES contexts:
+ *
+ * "This attribute is supported only for OpenGL and OpenGL ES
+ * contexts."
+ */
+ if (!(disp->Extensions.KHR_create_context && api == EGL_OPENGL_API)
+ && !(disp->Version >= 15 && (api == EGL_OPENGL_API ||
+ api == EGL_OPENGL_ES_API))) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ 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 (!disp->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 (!disp->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 (disp->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 (disp->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 (disp->Version < 15) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ if (val == EGL_TRUE)
+ ctx->Flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
+ break;
+
+ case EGL_CONTEXT_OPENGL_NO_ERROR_KHR:
+ if (disp->Version < 14 ||
+ !disp->Extensions.KHR_create_context_no_error) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ /* The KHR_no_error spec only applies against OpenGL 2.0+ and
+ * OpenGL ES 2.0+
+ */
+ if ((api != EGL_OPENGL_API && api != EGL_OPENGL_ES_API) ||
+ ctx->ClientMajorVersion < 2) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ /* Canonicalize value to EGL_TRUE/EGL_FALSE definitions */
+ ctx->NoError = !!val;
+ break;
+
+ case EGL_CONTEXT_PRIORITY_LEVEL_IMG:
+ /* The EGL_IMG_context_priority spec says:
+ *
+ * "EGL_CONTEXT_PRIORITY_LEVEL_IMG determines the priority level of
+ * the context to be created. This attribute is a hint, as an
+ * implementation may not support multiple contexts at some
+ * priority levels and system policy may limit access to high
+ * priority contexts to appropriate system privilege level. The
+ * default value for EGL_CONTEXT_PRIORITY_LEVEL_IMG is
+ * EGL_CONTEXT_PRIORITY_MEDIUM_IMG."
+ */
+ {
+ int bit;
+
+ switch (val) {
+ case EGL_CONTEXT_PRIORITY_HIGH_IMG:
+ bit = __EGL_CONTEXT_PRIORITY_HIGH_BIT;
+ break;
+ case EGL_CONTEXT_PRIORITY_MEDIUM_IMG:
+ bit = __EGL_CONTEXT_PRIORITY_MEDIUM_BIT;
+ break;
+ case EGL_CONTEXT_PRIORITY_LOW_IMG:
+ bit = __EGL_CONTEXT_PRIORITY_LOW_BIT;
+ break;
+ default:
+ bit = -1;
+ break;
+ }
+
+ if (bit < 0) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ /* "This extension allows an EGLContext to be created with a
+ * priority hint. It is possible that an implementation will not
+ * honour the hint, especially if there are constraints on the
+ * number of high priority contexts available in the system, or
+ * system policy limits access to high priority contexts to
+ * appropriate system privilege level. A query is provided to find
+ * the real priority level assigned to the context after creation."
+ *
+ * We currently assume that the driver applies the priority hint
+ * and filters out any it cannot handle during the screen setup,
+ * e.g. dri2_setup_screen(). As such we can mask any change that
+ * the driver would fail, and ctx->ContextPriority matches the
+ * hint applied to the driver/hardware backend.
+ */
+ if (disp->Extensions.IMG_context_priority & (1 << bit))
+ ctx->ContextPriority = val;
+
+ break;
+ }
+
+ case EGL_CONTEXT_RELEASE_BEHAVIOR_KHR:
+ if (val == EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR ||
+ val == EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR) {
+ ctx->ReleaseBehavior = val;
+ } else {
+ err = EGL_BAD_ATTRIBUTE;
+ }
+ break;
+