+
+ /* There are no forward-compatible contexts before OpenGL 3.0. The
+ * GLX_ARB_create_context spec says:
+ *
+ * "Forward-compatible contexts are defined only for OpenGL versions
+ * 3.0 and later."
+ */
+ if (*major_ver < 3 && (*flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) {
+ *error = __DRI_CTX_ERROR_BAD_FLAG;
+ return false;
+ }
+
+ if (*major_ver >= 3 && *render_type == GLX_COLOR_INDEX_TYPE) {
+ *error = __DRI_CTX_ERROR_BAD_FLAG;
+ return false;
+ }
+
+ *error = __DRI_CTX_ERROR_SUCCESS;
+ return true;
+}
+
+_X_HIDDEN bool
+dri2_check_no_error(uint32_t flags, struct glx_context *share_context,
+ int major, unsigned *error)
+{
+ Bool noError = flags & __DRI_CTX_FLAG_NO_ERROR;
+
+ /* The KHR_no_error specs say:
+ *
+ * Requires OpenGL ES 2.0 or OpenGL 2.0.
+ */
+ if (noError && major < 2) {
+ *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
+ return false;
+ }
+
+ /* The GLX_ARB_create_context_no_error specs say:
+ *
+ * BadMatch is generated if the value of GLX_CONTEXT_OPENGL_NO_ERROR_ARB
+ * used to create <share_context> does not match the value of
+ * GLX_CONTEXT_OPENGL_NO_ERROR_ARB for the context being created.
+ */
+ if (share_context && !!share_context->noError != !!noError) {
+ *error = __DRI_CTX_ERROR_BAD_FLAG;
+ return false;
+ }
+
+ /* The GLX_ARB_create_context_no_error specs say:
+ *
+ * BadMatch is generated if the GLX_CONTEXT_OPENGL_NO_ERROR_ARB is TRUE at
+ * the same time as a debug or robustness context is specified.
+ *
+ */
+ if (noError && ((flags & __DRI_CTX_FLAG_DEBUG) ||
+ (flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS))) {
+ *error = __DRI_CTX_ERROR_BAD_FLAG;
+ return false;
+ }
+
+ return true;