From dd163a8ec44ee12e45058c5d19b3aeaf16e104ac Mon Sep 17 00:00:00 2001 From: Bailey Stoner Date: Sun, 21 Dec 2025 09:28:04 -0800 Subject: [PATCH] fix: let wlroots determine frame_done timestamp for PRIME offload When using PRIME GPU offload (e.g., NVIDIA renders, AMD displays), capturing the timestamp via clock_gettime in rendermon() causes frame timing issues. The timestamp is captured from the display GPU's clock, but rendering occurs on the offload GPU with different timing. This clock divergence causes stuttering that appears as "frames going backward in time" when the mouse is moved. By passing NULL to wlr_scene_output_send_frame_done(), we let wlroots determine the appropriate timestamp, which handles the PRIME offload case correctly. --- dwl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dwl.c b/dwl.c index 12f441e..3f17462 100644 --- a/dwl.c +++ b/dwl.c @@ -2154,7 +2154,6 @@ rendermon(struct wl_listener *listener, void *data) Monitor *m = wl_container_of(listener, m, frame); Client *c; struct wlr_output_state pending = {0}; - struct timespec now; /* Render if no XDG clients have an outstanding resize and are visible on * this monitor. */ @@ -2166,9 +2165,10 @@ rendermon(struct wl_listener *listener, void *data) wlr_scene_output_commit(m->scene_output, NULL); skip: - /* Let clients know a frame has been rendered */ - clock_gettime(CLOCK_MONOTONIC, &now); - wlr_scene_output_send_frame_done(m->scene_output, &now); + /* Let clients know a frame has been rendered. Pass NULL to let wlroots + * determine the timestamp, which is required for correct timing when + * input and output clocks may diverge (e.g., PRIME GPU offload). */ + wlr_scene_output_send_frame_done(m->scene_output, NULL); wlr_output_state_finish(&pending); }