Skip to content

Commit

Permalink
wayland: fix presentation time refresh
Browse files Browse the repository at this point in the history
The refresh represents the time till the next vblank
relative to the timestamp and not the mode refresh
  • Loading branch information
cmeissl authored and Drakulix committed Sep 4, 2023
1 parent e0c3a9b commit 4cb1167
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion anvil/src/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ impl AnvilState<UdevData> {
clock,
output
.current_mode()
.map(|mode| mode.refresh as u32)
.map(|mode| Duration::from_secs_f64(1_000f64 / mode.refresh as f64))
.unwrap_or_default(),
seq as u64,
flags,
Expand Down
2 changes: 1 addition & 1 deletion anvil/src/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ pub fn run_winit() {
time,
output
.current_mode()
.map(|mode| mode.refresh as u32)
.map(|mode| Duration::from_secs_f64(1_000f64 / mode.refresh as f64))
.unwrap_or_default(),
0,
wp_presentation_feedback::Kind::Vsync,
Expand Down
2 changes: 1 addition & 1 deletion anvil/src/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ pub fn run_x11() {
time,
output
.current_mode()
.map(|mode| mode.refresh as u32)
.map(|mode| Duration::from_secs_f64(1_000f64 / mode.refresh as f64))
.unwrap_or_default(),
0,
wp_presentation_feedback::Kind::Vsync,
Expand Down
6 changes: 4 additions & 2 deletions src/desktop/wayland/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,12 @@ impl SurfacePresentationFeedback {
output: &Output,
clk_id: u32,
time: impl Into<Duration>,
refresh: u32,
refresh: impl Into<Duration>,
seq: u64,
flags: wp_presentation_feedback::Kind,
) {
let time = time.into();
let refresh = refresh.into();

for callback in self.callbacks.drain(..) {
if callback.clk_id() == clk_id {
Expand Down Expand Up @@ -392,14 +393,15 @@ impl OutputPresentationFeedback {
pub fn presented<T, Kind>(
&mut self,
time: T,
refresh: u32,
refresh: impl Into<Duration>,
seq: u64,
flags: wp_presentation_feedback::Kind,
) where
T: Into<Time<Kind>>,
Kind: crate::utils::NonNegativeClockSource,
{
let time = time.into();
let refresh = refresh.into();
let clk_id = Kind::id() as u32;
if let Some(output) = self.output.upgrade() {
for mut callback in self.callbacks.drain(..) {
Expand Down
3 changes: 2 additions & 1 deletion src/wayland/presentation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl PresentationFeedbackCallback {
self,
output: &Output,
time: impl Into<Duration>,
refresh: u32,
refresh: impl Into<Duration>,
seq: u64,
flags: wp_presentation_feedback::Kind,
) {
Expand Down Expand Up @@ -236,6 +236,7 @@ impl PresentationFeedbackCallback {
let tv_sec_hi = (time.as_secs() >> 32) as u32;
let tv_sec_lo = (time.as_secs() & 0xFFFFFFFF) as u32;
let tv_nsec = time.subsec_nanos();
let refresh = refresh.into().as_nanos() as u32;
let seq_hi = (seq >> 32) as u32;
let seq_lo = (seq & 0xFFFFFFFF) as u32;

Expand Down

0 comments on commit 4cb1167

Please sign in to comment.