egl: add and enable EGL_KHR_config_attribs
[mesa.git] / src / egl / main / eglcontext.c
index ebc004d8cf2b839122c452a2a918d7aea8284fdd..60625f64705c67d90c00964ac26f4bfd45ef5542 100644 (file)
@@ -457,6 +457,16 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
 /**
  * Initialize the given _EGLContext object to defaults and/or the values
  * in the attrib_list.
+ *
+ * According to EGL 1.5 Section 3.7:
+ *
+ *     "EGL_OPENGL_API and EGL_OPENGL_ES_API are interchangeable for all
+ *     purposes except eglCreateContext."
+ *
+ * And since we only support GL and GLES, this is the only place where the
+ * bound API matters at all. We look up the current API from the current
+ * thread, and stash that in the context we're initializing. Our caller is
+ * responsible for determining whether that's an API it supports.
  */
 EGLBoolean
 _eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, _EGLConfig *conf,
@@ -528,9 +538,14 @@ _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *c,
 
    switch (attribute) {
    case EGL_CONFIG_ID:
-      if (!c->Config)
-         return _eglError(EGL_BAD_ATTRIBUTE, "eglQueryContext");
-      *value = c->Config->ConfigID;
+      /*
+       * From EGL_KHR_no_config_context:
+       *
+       *    "Querying EGL_CONFIG_ID returns the ID of the EGLConfig with
+       *     respect to which the context was created, or zero if created
+       *     without respect to an EGLConfig."
+       */
+      *value = c->Config ? c->Config->ConfigID : 0;
       break;
    case EGL_CONTEXT_CLIENT_VERSION:
       *value = c->ClientMajorVersion;
@@ -627,9 +642,9 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read)
           (read && read->Config != ctx->Config))
          return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
    } else {
-      /* Otherwise we must be using the EGL_MESA_configless_context
+      /* Otherwise we must be using the EGL_KHR_no_config_context
        * extension */
-      assert(dpy->Extensions.MESA_configless_context);
+      assert(dpy->Extensions.KHR_no_config_context);
 
       /* The extension doesn't permit binding draw and read buffers with
        * differing contexts */