x11/window: Add tracing for X11 synchronization events

Add tracing and data gathering for processing related to
_NET_WM_FRAME_DRAWN and _NET_WM_FRAME_TIMINGS, used by some X11 clients
for synchronized rendering.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
This commit is contained in:
Jonas Ådahl 2021-02-02 23:57:23 +01:00
parent 6d64a43b1f
commit ffb88bffc5
2 changed files with 49 additions and 0 deletions

View File

@ -167,6 +167,9 @@ do_send_frame_drawn (MetaWindowActorX11 *actor_x11,
XClientMessageEvent ev = { 0, };
COGL_TRACE_BEGIN (MetaWindowActorX11FrameDrawn,
"X11: Send _NET_WM_FRAME_DRAWN");
now_us = g_get_monotonic_time ();
frame->frame_drawn_time =
meta_compositor_monotonic_to_high_res_xserver_time (display->compositor,
@ -186,6 +189,19 @@ do_send_frame_drawn (MetaWindowActorX11 *actor_x11,
XSendEvent (xdisplay, ev.window, False, 0, (XEvent *) &ev);
XFlush (xdisplay);
meta_x11_error_trap_pop (display->x11_display);
if (G_UNLIKELY (cogl_is_tracing_enabled ()))
{
g_autofree char *description = NULL;
description = g_strdup_printf ("frame drawn time: %" G_GINT64_FORMAT ", "
"sync request serial: %" G_GINT64_FORMAT,
frame->frame_drawn_time,
frame->sync_request_serial);
COGL_TRACE_DESCRIBE (MetaWindowActorX11FrameDrawn,
description);
COGL_TRACE_END (MetaWindowActorX11FrameDrawn);
}
}
static void
@ -201,6 +217,9 @@ do_send_frame_timings (MetaWindowActorX11 *actor_x11,
XClientMessageEvent ev = { 0, };
COGL_TRACE_BEGIN (MetaWindowActorX11FrameTimings,
"X11: Send _NET_WM_FRAME_TIMINGS");
ev.type = ClientMessage;
ev.window = meta_window_get_xwindow (window);
ev.message_type = display->x11_display->atom__NET_WM_FRAME_TIMINGS;
@ -231,6 +250,21 @@ do_send_frame_timings (MetaWindowActorX11 *actor_x11,
XSendEvent (xdisplay, ev.window, False, 0, (XEvent *) &ev);
XFlush (xdisplay);
meta_x11_error_trap_pop (display->x11_display);
if (G_UNLIKELY (cogl_is_tracing_enabled ()))
{
g_autofree char *description = NULL;
description =
g_strdup_printf ("refresh interval: %d, "
"presentation time: %" G_GINT64_FORMAT ", "
"sync request serial: %" G_GINT64_FORMAT,
refresh_interval,
frame->sync_request_serial,
presentation_time);
COGL_TRACE_DESCRIBE (MetaWindowActorX11FrameTimings, description);
COGL_TRACE_END (MetaWindowActorX11FrameTimings);
}
}
static void

View File

@ -4025,6 +4025,8 @@ meta_window_x11_update_sync_request_counter (MetaWindow *window,
gboolean needs_frame_drawn = FALSE;
gboolean no_delay_frame = FALSE;
COGL_TRACE_BEGIN (MetaWindowSyncRequestCounter, "X11: Sync request counter");
if (window->extended_sync_request_counter && new_counter_value % 2 == 0)
{
needs_frame_drawn = TRUE;
@ -4071,6 +4073,19 @@ meta_window_x11_update_sync_request_counter (MetaWindow *window,
if (needs_frame_drawn)
meta_compositor_queue_frame_drawn (window->display->compositor, window,
no_delay_frame);
if (G_UNLIKELY (cogl_is_tracing_enabled ()))
{
g_autofree char *description = NULL;
description =
g_strdup_printf ("sync request serial: %" G_GINT64_FORMAT ", "
"needs frame drawn: %s",
new_counter_value,
needs_frame_drawn ? "yes" : "no");
COGL_TRACE_DESCRIBE (MetaWindowSyncRequestCounter, description);
COGL_TRACE_END (MetaWindowSyncRequestCounter);
}
}
Window