backends/native: Get rendering and swap timings during scanout

Scanout doesn't go through the usual path of compositing and doing
eglSwapBuffers, therefore it doesn't hit the timestamp query placed in
that path. Instead, get the timings by binding the scanout buffer to an
FBO and doing a timestamp query on the FBO.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
This commit is contained in:
Ivan Molodetskikh
2021-01-06 15:42:33 +03:00
committed by Marge Bot
parent 5a0d3ed4dd
commit 1116b14f38
5 changed files with 179 additions and 0 deletions

View File

@ -1222,6 +1222,8 @@ meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen,
meta_backend_get_monitor_manager (backend);
MetaPowerSave power_save_mode;
ClutterFrame *frame = user_data;
MetaDrmBuffer *scanout_buffer;
GError *fill_timings_error = NULL;
MetaKmsCrtc *kms_crtc;
MetaKmsDevice *kms_device;
MetaKmsUpdateFlag flags;
@ -1255,6 +1257,33 @@ meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen,
g_set_object (&onscreen_native->gbm.next_fb, META_DRM_BUFFER (scanout));
/* Try to get a measurement of GPU rendering time on the scanout buffer.
*
* The successful operation here adds ~0.4 ms to a ~0.1 ms total frame clock
* dispatch duration when displaying an unredirected client, thus
* unfortunately bringing it more in line with duration of the regular
* non-unredirected frame clock dispatch. However, measuring GPU rendering
* time is important for computing accurate max render time without
* underestimating. Also this operation should be optimizable by caching
* EGLImage for each buffer instead of re-creating it every time it's needed.
* This should also help all other cases which convert the buffer to a
* EGLImage.
*/
if (META_IS_DRM_BUFFER (scanout))
{
scanout_buffer = META_DRM_BUFFER (scanout);
if (meta_drm_buffer_supports_fill_timings (scanout_buffer))
{
if (!meta_drm_buffer_fill_timings (scanout_buffer, frame_info,
&fill_timings_error))
{
g_warning ("Failed to fill timings for a scanout buffer: %s",
fill_timings_error->message);
g_error_free (fill_timings_error);
}
}
}
ensure_crtc_modes (onscreen);
meta_onscreen_native_flip_crtc (onscreen,
onscreen_native->view,