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@imgtec.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5707>
This commit is contained in:
Luigi Santivetti
2020-06-30 11:32:49 +01:00
committed by Marge Bot
parent 6b12999ef7
commit 8b0b6f907d

View File

@@ -1768,7 +1768,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");
@@ -1800,9 +1799,9 @@ 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)) {
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 &&
@@ -1829,12 +1828,12 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
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);