egl: Rewrite eglGetMscRateANGLE to avoid probes and handle multi-monitor
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 11 Jan 2023 23:37:22 +0000 (15:37 -0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 27 Jan 2023 04:35:08 +0000 (04:35 +0000)
commit41d5f0ee09ccc6406d9b57351fa95edf30b03298
treeaa0c20ae91662f7d5204862bc7212891ea0711ab
parent3170b63314f14f0031cb95bd5ee3a4726f26b43b
egl: Rewrite eglGetMscRateANGLE to avoid probes and handle multi-monitor

RRGetScreenInfo re-probes connector status, which may result in an EDID
transfer for every output, which according to Adam Jackson can be on the
order of 100ms for a single EDID block.  So our previous implementation
of this eglGetMscRateANGLE was blocking for excessive periods of time
instead of being a quick query of the refresh rate like users expect.

This changes our eglGetMscRateANGLE implementation from using
RRGetScreenInfo to RRGetScreenResourcesCurrent and RRGetCrtcInfo.
This obtains the same monitor info without re-probing connectors.

Fixes a severe performance regression in Chromium WebGL performance.

While we're re-implementing the extension, we also implement proper
multi-monitor support: if there are multiple active CRTCs, we determine
which contains the largest portion of the surface, as specified in the
EGL_ANGLE_sync_control_rate extension.

We also now report fractional refresh rates correctly rather than
rounding to the nearest Hz.

Fixes: 47526556494 ("egl/x11: implement ANGLE_sync_control_rate")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6996
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7038
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20665>
src/egl/drivers/dri2/egl_dri2.h
src/egl/drivers/dri2/platform_x11.c