Skip to content

Commit

Permalink
vblankmanager: Treat wakeup time as scheduled wakeup point for timerf…
Browse files Browse the repository at this point in the history
…d path

Because we are using timerfd, ulWakeupTime should actually be the target
point of the timerfd when using that, not the the current time from
OnPollIn, so we can account for the scheduling quantums from the target
wakeup time and other work (like we were wrt the pipe write before)
  • Loading branch information
misyltoad committed Dec 7, 2023
1 parent ecccd77 commit db59f4c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/vblankmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,21 @@ namespace gamescope
if ( !m_bArmed.exchange( false ) )
return;

uint64_t ulNow = get_time_in_nanos();

m_PendingVBlank = VBlankTime
{
.schedule = m_TimerFDSchedule,
.ulWakeupTime = ulNow,
// One might think this should just be 'now', however consider the fact
// that the effective draw-time should also include the scheduling quantums
// and any work before we reached this poll.
// The old path used to be be on its own thread, simply awaking from sleep
// then writing to a pipe and going back to sleep, the wakeup time was before we
// did the write, so we included the quantum of pipe nudge -> wakeup.
// Doing this aims to include that, like we were before, but with timerfd.
.ulWakeupTime = m_TimerFDSchedule.ulScheduledWakeupPoint,
};
#ifdef VBLANK_DEBUG
uint64_t ulNow = get_time_in_nanos();
fprintf( stderr, "wakeup: %lu\n", ulNow );
#endif

Expand Down

0 comments on commit db59f4c

Please sign in to comment.