Mesa (master): egl: Fix context API check and be verbose.

Chia-I Wu olv at kemper.freedesktop.org
Fri Aug 20 11:30:02 UTC 2010


Module: Mesa
Branch: master
Commit: 5eb33596a0db26586957365ab27fc6afdebfe057
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5eb33596a0db26586957365ab27fc6afdebfe057

Author: Chia-I Wu <olv at lunarg.com>
Date:   Fri Aug 20 13:19:10 2010 +0800

egl: Fix context API check and be verbose.

The API of the context was not checked against EGL_RENDERABLE_TYPE when there
was no attribute list.  Move the check to _eglInitContext, and be verbose about
common mistakes (EGL_RENDERABLE_TYPE not set, EGL_CONTEXT_CLIENT_VERSION not
set, or eglBindAPI not called).

---

 src/egl/main/eglconfig.c  |    7 +++++--
 src/egl/main/eglcontext.c |   20 +++++++++++---------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index ea8e47d..01e7144 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -460,11 +460,14 @@ _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria)
       }
 
       if (!matched) {
-#ifdef DEBUG
+#ifndef DEBUG
+         /* only print the common errors when DEBUG is not defined */
+         if (attr != EGL_RENDERABLE_TYPE)
+            break;
+#endif
          _eglLog(_EGL_DEBUG,
                "the value (0x%x) of attribute 0x%04x did not meet the criteria (0x%x)",
                val, attr, cmp);
-#endif
          break;
       }
    }
diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index 9fc5296..e72664c 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -83,15 +83,6 @@ _eglParseContextAttribList(_EGLContext *ctx, const EGLint *attrib_list)
       }
    }
 
-   if (err == EGL_SUCCESS && ctx->Config) {
-      EGLint renderable_type, api_bit;
-
-      renderable_type = GET_CONFIG_ATTRIB(ctx->Config, EGL_RENDERABLE_TYPE);
-      api_bit = _eglGetContextAPIBit(ctx);
-      if (!(renderable_type & api_bit))
-         err = EGL_BAD_CONFIG;
-   }
-
    return err;
 }
 
@@ -121,6 +112,17 @@ _eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, _EGLConfig *conf,
    ctx->ClientVersion = 1; /* the default, per EGL spec */
 
    err = _eglParseContextAttribList(ctx, attrib_list);
+   if (err == EGL_SUCCESS && ctx->Config) {
+      EGLint renderable_type, api_bit;
+
+      renderable_type = GET_CONFIG_ATTRIB(ctx->Config, EGL_RENDERABLE_TYPE);
+      api_bit = _eglGetContextAPIBit(ctx);
+      if (!(renderable_type & api_bit)) {
+         _eglLog(_EGL_DEBUG, "context api is 0x%x while config supports 0x%x",
+               api_bit, renderable_type);
+         err = EGL_BAD_CONFIG;
+      }
+   }
    if (err != EGL_SUCCESS)
       return _eglError(err, "eglCreateContext");
 




More information about the mesa-commit mailing list