egl/dri2: short-circuit dri2_make_current when possible
authorLucas Stach <l.stach@pengutronix.de>
Mon, 3 Jan 2022 18:57:14 +0000 (19:57 +0100)
committerMarge Bot <emma+marge@anholt.net>
Mon, 17 Jan 2022 10:32:01 +0000 (10:32 +0000)
commit0d65f229c5c3a0eb2cc7da742ee0aca1e5c72fc7
tree6035a676a01717a7ad0e776035752f5bc5f83bed
parentb33ed5406a9379dba98e2ae1b8ff47fa22e8cb6a
egl/dri2: short-circuit dri2_make_current when possible

If an application calls eglMakeCurrent with the same context and the same
draw and read surfaces as the current ones, there is no need to go
through all the work of unbinding/flushing the old context and binding
the new one.

While the EGL spec is a bit ambiguous here, it seems that the implicit
flush of the outgoing context only needs to be done when the context is
actually changed.

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