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

Vulkan: Change double buffered VSync to match display without blocking #1012

Closed
wants to merge 35 commits into from

Conversation

goeiecool9999
Copy link
Collaborator

@goeiecool9999 goeiecool9999 commented Oct 29, 2023

This PR eliminates unnecessary blocking on the GPU thread while using the FIFO present mode.

Tripple buffered VSync and VSync off behaviour remains unchanged and use the old method of driving present with SwapBuffers, which allows VRR to reduce stuttering and external tools to see exact frametimes

Implementation:

  • Use two vulkan textures as a representation of a front and back buffer and let games only draw to the back buffer.
  • When FIFO present mode is active, SwapBuffer only swaps the two textures
  • Set AcquireImage timeout to 0. GPU thread never blocks on presentation code anymore.
  • Track rate at which AcquireImage succeeds.
  • When FIFO present mode is active call vkPresentImage from handleTimedVsync instead of SwapBuffer
  • When FIFO present mode is active AND 60 frames had desired pacing, take over vsync signalling from fixed timer

Why:

  • No blocking on GPU thread, more opportunity to do work.
  • Matches hardware more closely.

Why not:

  • A lot of work for a theoretical improvement
  • Games may receive sporadic VSync timing because of the pacing detection system switching between timing sources
  • Pacing detection is fragile in general, it relies on handleTimedVsync being called more often than the framerate, which may not always be the case. To implement this properly presentation would need to be moved to a new thread, which is difficult and unusual and may expose driver bugs

@goeiecool9999 goeiecool9999 changed the title Vulkan: Change VSync mechanism to hopefully improve framepacing on non VRR displays (Needs testing) Vulkan: Change double buffered VSync to match display without blocking Nov 5, 2023
@lbibass
Copy link

lbibass commented Mar 10, 2024

Any update on this? Seems like it would be useful for steam deck.

@goeiecool9999
Copy link
Collaborator Author

when I wrote the PR description I oversold it's capabilities considerably, because I didn't fully understand the nuances of this change. I have edited the PR description to be more accurate.
That said. I don't think this will give considerable improvements on any platform, in hindsight it doesn't actually give Cemu new capabilities. And with that I am closing this PR.

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