egl/dri2: remove superfluous flush when changing the context
authorLucas Stach <l.stach@pengutronix.de>
Thu, 6 Jan 2022 16:44:04 +0000 (17:44 +0100)
committerMarge Bot <emma+marge@anholt.net>
Mon, 17 Jan 2022 10:32:01 +0000 (10:32 +0000)
The flush of the outgoing GL context, as required by the EGL spec for
eglMakeCurrent and extended by KHR_context_flush_control, is already
performed in the unbindContext call. There is no need to pierce through
the layers and unconditionally call glFlush() here.

Getting the out-fence FD for explicit fencing needs to move behind the
unbindContext, to make sure we are getting the fence for the most
recently flushed commands.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14379>

src/egl/drivers/dri2/egl_dri2.c

index b1e4a9d..93030ad 100644 (file)
@@ -1788,12 +1788,6 @@ dri2_make_current(_EGLDisplay *disp, _EGLSurface *dsurf,
       old_disp = old_ctx->Resource.Display;
       old_dri2_dpy = dri2_egl_display(old_disp);
 
-      /* flush before context switch */
-      dri2_gl_flush();
-
-      if (old_dsurf)
-         dri2_surf_update_fence_fd(old_ctx, disp, old_dsurf);
-
       /* Disable shared buffer mode */
       if (old_dsurf && _eglSurfaceInSharedBufferMode(old_dsurf) &&
           old_dri2_dpy->vtbl->set_shared_buffer_mode) {
@@ -1801,6 +1795,9 @@ dri2_make_current(_EGLDisplay *disp, _EGLSurface *dsurf,
       }
 
       dri2_dpy->core->unbindContext(old_cctx);
+
+      if (old_dsurf)
+         dri2_surf_update_fence_fd(old_ctx, disp, old_dsurf);
    }
 
    ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL;