From 5eacc6ea9b8cc542ad3639eea5ee06ec692909bf Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 23:33:17 +0100 Subject: [PATCH] Window: one frame queued and no pipelined rendering, for less mouse latency With vsync, Bevy's two queued frames and pipelined rendering put the picture three to four frames behind the mouse, which a player felt as smoothing on the first-person look. Co-Authored-By: Claude Opus 5.5 --- crates/shards/src/plugins.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/shards/src/plugins.rs b/crates/shards/src/plugins.rs index 5e1b26c8..4315a601 100644 --- a/crates/shards/src/plugins.rs +++ b/crates/shards/src/plugins.rs @@ -270,8 +270,22 @@ impl Plugin for EmbeddedLogCapture { fn with_window(group: PluginGroupBuilder, config: &EngineConfig) -> PluginGroupBuilder { let (width, height) = config.window; - let window = Window { title: config.title.clone(), resolution: (width, height).into(), ..default() }; - let group = group.set(WindowPlugin { primary_window: Some(window), ..default() }); + // The least latency a hand on the mouse can feel, at some of the frame rate: one frame queued on the GPU, not + // Bevy's two, and no pipelined rendering (with it the main world works on the next frame while this one is drawn, + // which is one frame more between a mouse move and the picture). With vsync and both, a look turned 3 to 4 frames + // after the hand moved, which a player felt as smoothing on the mouse. + let window = Window { + title: config.title.clone(), + resolution: (width, height).into(), + desired_maximum_frame_latency: std::num::NonZeroU32::new(1), + ..default() + }; + #[cfg_attr(not(feature = "render"), allow(unused_mut))] + let mut group = group.set(WindowPlugin { primary_window: Some(window), ..default() }); + #[cfg(feature = "render")] + if group.contains::() { + group = group.disable::(); + } // `/icon.png`, if the game has one, in the title bar and the taskbar; how long frames take. #[cfg(feature = "render")] let group = group