Mesa (staging/20.1): dri2: do not conflate unbind and bindContext() failure

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 21 21:34:58 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: daf762636d69c338cbb4745d028e2cf382a6f0fd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=daf762636d69c338cbb4745d028e2cf382a6f0fd

Author: Luigi Santivetti <luigi.santivetti at imgtec.com>
Date:   Tue Jun 30 11:32:49 2020 +0100

dri2: do not conflate unbind and bindContext() failure

dri2_make_current() has become hard to follow, address this by
splitting the semantic of needing a call to bindContext() and
its failure.

Cc: mesa-stable
Signed-off-by: Luigi Santivetti <luigi.santivetti at imgtec.com>
Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5707>
(cherry picked from commit 8b0b6f907d7ba304cea02bdb81fbb914d6077cb9)

---

 .pick_status.json               |  2 +-
 src/egl/drivers/dri2/egl_dri2.c | 51 ++++++++++++++++++++---------------------
 2 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 5833165c5b6..8c618b93f53 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -76,7 +76,7 @@
         "description": "dri2: do not conflate unbind and bindContext() failure",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index fd27f1d7776..12b563d8e2f 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1767,7 +1767,6 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
    _EGLSurface *tmp_dsurf, *tmp_rsurf;
    __DRIdrawable *ddraw, *rdraw;
    __DRIcontext *cctx;
-   EGLBoolean unbind;
 
    if (!dri2_dpy)
       return _eglError(EGL_NOT_INITIALIZED, "eglMakeCurrent");
@@ -1799,41 +1798,41 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
    ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL;
    rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL;
    cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
-   unbind = (cctx == NULL && ddraw == NULL && rdraw == NULL);
 
-   if (!unbind && !dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) {
-      /* undo the previous _eglBindContext */
-      _eglBindContext(old_ctx, old_dsurf, old_rsurf, &ctx, &tmp_dsurf, &tmp_rsurf);
-      assert(&dri2_ctx->base == ctx &&
-             tmp_dsurf == dsurf &&
-             tmp_rsurf == rsurf);
+   if (cctx || ddraw || rdraw) {
+      if (!dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) {
+         /* undo the previous _eglBindContext */
+         _eglBindContext(old_ctx, old_dsurf, old_rsurf, &ctx, &tmp_dsurf, &tmp_rsurf);
+         assert(&dri2_ctx->base == ctx &&
+                tmp_dsurf == dsurf &&
+                tmp_rsurf == rsurf);
+
+         if (old_dsurf && _eglSurfaceInSharedBufferMode(old_dsurf) &&
+             old_dri2_dpy->vtbl->set_shared_buffer_mode) {
+            old_dri2_dpy->vtbl->set_shared_buffer_mode(old_disp, old_dsurf, true);
+         }
 
-      if (old_dsurf && _eglSurfaceInSharedBufferMode(old_dsurf) &&
-          old_dri2_dpy->vtbl->set_shared_buffer_mode) {
-         old_dri2_dpy->vtbl->set_shared_buffer_mode(old_disp, old_dsurf, true);
-      }
+         _eglPutSurface(dsurf);
+         _eglPutSurface(rsurf);
+         _eglPutContext(ctx);
 
-      _eglPutSurface(dsurf);
-      _eglPutSurface(rsurf);
-      _eglPutContext(ctx);
+         _eglPutSurface(old_dsurf);
+         _eglPutSurface(old_rsurf);
+         _eglPutContext(old_ctx);
 
-      _eglPutSurface(old_dsurf);
-      _eglPutSurface(old_rsurf);
-      _eglPutContext(old_ctx);
+         /* 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");
+      }
 
-      /* 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");
+      dri2_dpy->ref_count++;
    }
 
    dri2_destroy_surface(drv, disp, old_dsurf);
    dri2_destroy_surface(drv, disp, old_rsurf);
 
-   if (!unbind)
-      dri2_dpy->ref_count++;
-
    if (old_ctx) {
       dri2_destroy_context(drv, disp, old_ctx);
       dri2_display_release(old_disp);



More information about the mesa-commit mailing list