wsi/wayland/perfetto: supply presentation clock to perfetto
Perfetto is allowed to choose it's own default clock, and before this we just assumed the presentation times reported by the compositor are the same as perfetto's internal clock, which is not always the case. I got a nasty trace where all the wayland presents were in the wrong location. This fixes that by asking the compositor which clock it uses, then passing that along to perfetto. A workaround for my compositor was setting use_monotonic_clock=true in the perfetto config, as my compositor (and I suspect most others) use the monotonic clock for presentation timestamps. However, asking the compositor is definitely the most correct solution. I added a clock param to `MESA_TRACE_TIMESTAMP_{BEGIN,END}`, as it's only use that I could see was in wsi_common_wayland, and in general it seems good to be careful about which clock tracing timestamps come from. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31779>
This commit is contained in:

committed by
Marge Bot

parent
2a34b492d8
commit
a871eabced
@@ -122,6 +122,8 @@ struct wsi_wl_display {
|
||||
|
||||
dev_t main_device;
|
||||
bool same_gpu;
|
||||
|
||||
clockid_t presentation_clock_id;
|
||||
};
|
||||
|
||||
struct wsi_wayland {
|
||||
@@ -814,6 +816,18 @@ static const struct wl_shm_listener shm_listener = {
|
||||
.format = shm_handle_format
|
||||
};
|
||||
|
||||
static void
|
||||
presentation_handle_clock_id(void* data, struct wp_presentation *wp_presentation, uint32_t clk_id)
|
||||
{
|
||||
struct wsi_wl_display *display = data;
|
||||
|
||||
display->presentation_clock_id = clk_id;
|
||||
}
|
||||
|
||||
static const struct wp_presentation_listener presentation_listener = {
|
||||
presentation_handle_clock_id,
|
||||
};
|
||||
|
||||
static void
|
||||
registry_handle_global(void *data, struct wl_registry *registry,
|
||||
uint32_t name, const char *interface, uint32_t version)
|
||||
@@ -841,6 +855,7 @@ registry_handle_global(void *data, struct wl_registry *registry,
|
||||
if (strcmp(interface, wp_presentation_interface.name) == 0) {
|
||||
display->wp_presentation_notwrapped =
|
||||
wl_registry_bind(registry, name, &wp_presentation_interface, 1);
|
||||
wp_presentation_add_listener(display->wp_presentation_notwrapped, &presentation_listener, display);
|
||||
} else if (strcmp(interface, wp_tearing_control_manager_v1_interface.name) == 0) {
|
||||
display->tearing_control_manager =
|
||||
wl_registry_bind(registry, name, &wp_tearing_control_manager_v1_interface, 1);
|
||||
@@ -893,6 +908,7 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl,
|
||||
if (!u_vector_init(&display->formats, 8, sizeof(struct wsi_wl_format)))
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
||||
display->presentation_clock_id = -1; // 0 is a valid clock ID
|
||||
display->wsi_wl = wsi_wl;
|
||||
display->wl_display = wl_display;
|
||||
display->sw = sw;
|
||||
@@ -1998,7 +2014,7 @@ trace_present(const struct wsi_wl_present_id *id,
|
||||
buffer_name = stringify_wayland_id(surface->analytics.presenting);
|
||||
MESA_TRACE_TIMESTAMP_END(buffer_name ? buffer_name : "Wayland buffer",
|
||||
surface->analytics.presentation_track_id,
|
||||
presentation_time);
|
||||
chain->wsi_wl_surface->display->presentation_clock_id, presentation_time);
|
||||
free(buffer_name);
|
||||
}
|
||||
|
||||
@@ -2009,7 +2025,7 @@ trace_present(const struct wsi_wl_present_id *id,
|
||||
MESA_TRACE_TIMESTAMP_BEGIN(buffer_name ? buffer_name : "Wayland buffer",
|
||||
surface->analytics.presentation_track_id,
|
||||
id->flow_id,
|
||||
presentation_time);
|
||||
chain->wsi_wl_surface->display->presentation_clock_id, presentation_time);
|
||||
free(buffer_name);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user