Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vblankmanager: Port to timerfd #1053

Merged
merged 8 commits into from
Dec 8, 2023
Merged

vblankmanager: Port to timerfd #1053

merged 8 commits into from
Dec 8, 2023

Conversation

misyltoad
Copy link
Collaborator

Ports vblankmanager to be timerfd based, and also fxies issues
with re-arming at higher refresh rates.

The old nudge thread method still exists (and is needed for VR), and
it has also been improved to fix the re-arming issue.

The old method can be enabled with GAMESCOPE_DISABLE_TIMERFD.

This additionally ports the main poll event loop to epoll with the new waitable system and fixes a presentWaitID bug in Vulkan.

cc: @sharkautarch Probably interests you?

@misyltoad
Copy link
Collaborator Author

Some things to think about before merging:

  • Is drawTime correct and good to use like this? Given there can be other work in steamcompmgr that is now polling this where the ulWakeupTime comes from.
  • Go through games and check frame pacing

@misyltoad
Copy link
Collaborator Author

misyltoad commented Dec 7, 2023

Thoughts:

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)

@misyltoad
Copy link
Collaborator Author

Seems like there is some unstable frametiming introduced by:

commit 46bbf7214ca99a2df13df3de569eb6016e5eeb05
Author: Joshua Ashton <[email protected]>
Date:   Wed Dec 6 22:51:33 2023 +0000

    steamcompmgr: Move main poll event loop to new waitable system

Not sure why yet...

Ports vblankmanager to be timerfd based, and also fxies issues
with re-arming at higher refresh rates.

The old nudge thread method still exists (and is needed for VR), and
it has also been improved to fix the re-arming issue.

The old method can be enabled with GAMESCOPE_DISABLE_TIMERFD.
…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)
@misyltoad
Copy link
Collaborator Author

Fixed that, it was because nudge_steamcompmgr was not nudging the new FD on the g_SteamCompMgrWaiter but the old global nudge one that is now unused.

@sharkautarch
Copy link

sharkautarch commented Dec 8, 2023

cc: @sharkautarch Probably interests you?

I merged this PR into my own branch nvidia-fix-vblank-timerfd
Initial testing w/ vkcube: works well when running w/ ENABLE_GAMESCOPE_WSI=1, but stutters with ENABLE_GAMESCOPE_WSI=0

note: not sure if it would behave better w/ --rt, because gamescope nvidia-fix/nvidia-fix-vblank-timerfd freezes when run with CAP_SYS_NICE privileges due to nvidia driver snafu

EDIT: seems like the behavior is better, less stuttery w/ intel igpu (I think because of the compute queue that could be used when not running on nvidia) , and maybe slightly more better with intel igpu + running w/ realtime (--rt)

@misyltoad
Copy link
Collaborator Author

If you are testing on NVIDIA I am not surprised at there being issues without WSI given the whole xserver interaction there.

@misyltoad misyltoad merged commit b7c828b into master Dec 8, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants