[Mesa-dev,v3] egl/dri2: dri2_make_current: Set EGL error if bindContext fails

Submitted by Nicolas Boichat on July 15, 2016, 8:24 a.m.


Message ID 1468571060-35354-1-git-send-email-drinkcat@google.com
State Accepted
Series "egl/dri2: dri2_make_current: Set EGL error if bindContext fails"
Commit 9bebef4034c79d0f223a6e61943dd44bcb6442ee
Headers show

Commit Message

Nicolas Boichat July 15, 2016, 8:24 a.m.
From: Nicolas Boichat <drinkcat@chromium.org>

Without this, if a configuration is, say, available only on GLES2/3, but
not on GLES1, and is rejected by the dri module's bindContext call,
eglMakeCurrent fails with error "EGL_SUCCESS".

In this patch, we set error to EGL_BAD_MATCH, which is what CTS/dEQP
dEQP-EGL.functional.surfaceless_context expect.

Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>

Emil: Took the opportunity to at least document where eglError is set. I guess,
in an ideal world, functions returning EGLBoolean should be annotated to tell
if they set (or not) the EGL error, so that callers know what to do on error.

 src/egl/drivers/dri2/egl_dri2.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index bfde640..2e97d85 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1190,8 +1190,10 @@  dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
    __DRIcontext *cctx;
    /* make new bindings */
-   if (!_eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf))
+   if (!_eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf)) {
+      /* _eglBindContext already sets the EGL error (in _eglCheckMakeCurrent) */
       return EGL_FALSE;
+   }
    /* flush before context switch */
    if (old_ctx && dri2_drv->glFlush)
@@ -1231,7 +1233,11 @@  dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
-      return EGL_FALSE;
+      /* dri2_dpy->core->bindContext failed. We cannot tell for sure why, but
+       * setting the error to EGL_BAD_MATCH is surely better than leaving it
+       * as EGL_SUCCESS.
+       */
+      return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");