From 271c712146fc20df5f1f23f78ae850dbcf7d7aad Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Thu, 6 Feb 2025 08:21:16 -0600 Subject: [PATCH] wayland: Fix refresh interval reporting in presentation-time version 1 Version 1 of the presentation protocol requires that 0 be sent for the refresh rate for variable refresh rate. Fix this by checking the mode during the presentation event. Part-of: --- src/wayland/meta-wayland-outputs.c | 6 ++++++ src/wayland/meta-wayland-outputs.h | 2 ++ src/wayland/meta-wayland-presentation-time.c | 13 ++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/wayland/meta-wayland-outputs.c b/src/wayland/meta-wayland-outputs.c index 376047d9c..700b5d5c7 100644 --- a/src/wayland/meta-wayland-outputs.c +++ b/src/wayland/meta-wayland-outputs.c @@ -92,6 +92,12 @@ meta_wayland_output_get_monitor (MetaWaylandOutput *wayland_output) return wayland_output->monitor; } +MetaMonitorMode * +meta_wayland_output_get_monitor_mode (MetaWaylandOutput *wayland_output) +{ + return wayland_output->mode; +} + static void output_resource_destroy (struct wl_resource *res) { diff --git a/src/wayland/meta-wayland-outputs.h b/src/wayland/meta-wayland-outputs.h index f28b59122..d27948d15 100644 --- a/src/wayland/meta-wayland-outputs.h +++ b/src/wayland/meta-wayland-outputs.h @@ -33,6 +33,8 @@ const GList * meta_wayland_output_get_resources (MetaWaylandOutput *wayland_outp MetaMonitor * meta_wayland_output_get_monitor (MetaWaylandOutput *wayland_output); +MetaMonitorMode * meta_wayland_output_get_monitor_mode (MetaWaylandOutput *wayland_output); + void meta_wayland_outputs_finalize (MetaWaylandCompositor *compositor); void meta_wayland_outputs_init (MetaWaylandCompositor *compositor); diff --git a/src/wayland/meta-wayland-presentation-time.c b/src/wayland/meta-wayland-presentation-time.c index abddb63b1..13a98a984 100644 --- a/src/wayland/meta-wayland-presentation-time.c +++ b/src/wayland/meta-wayland-presentation-time.c @@ -323,6 +323,8 @@ meta_wayland_presentation_feedback_present (MetaWaylandPresentationFeedback *fee uint32_t seq_hi, seq_lo; uint32_t flags; const GList *l; + MetaMonitorMode *mode; + gboolean is_vrr; if (output == NULL) { @@ -337,7 +339,16 @@ meta_wayland_presentation_feedback_present (MetaWaylandPresentationFeedback *fee tv_sec_lo = time_s; tv_nsec = (uint32_t) us2ns (time_us - s2us (time_s)); - refresh_interval_ns = (uint32_t) (0.5 + s2ns (1) / frame_info->refresh_rate); + mode = meta_wayland_output_get_monitor_mode (output); + + is_vrr = meta_monitor_mode_get_refresh_rate_mode (mode) == + META_CRTC_REFRESH_RATE_MODE_VARIABLE; + + /* The refresh rate interval is required to be 0 for vrr. */ + if (is_vrr) + refresh_interval_ns = 0; + else + refresh_interval_ns = (uint32_t) (0.5 + s2ns (1) / frame_info->refresh_rate); maybe_update_presentation_sequence (surface, frame_info, output);