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

Fix Vulkan swapchain extent and buffer count issues, Implement Vulkan mailbox mode option #787

Merged
merged 3 commits into from
Jul 14, 2023

Conversation

SRSaunders
Copy link

@SRSaunders SRSaunders commented Jun 9, 2023

This PR fixes #765 and #783 and hopefully addresses #740.

It also implements eMailbox presentation mode for Vulkan as an optional alternative to eImmediate mode, based on the setting of a new r_preferFastSync cvar (default on = true). This setting will change the meaning of Vulkan VSync Off in the GUI to mean "run full out without tearing" (Fast Sync) vs. "run full out with tearing". Vulkan eMailbox mode achieves this by dropping frames to line up with vsync. If supported on their platform, users will have an option for fast frame rates and low latency with a choice of tearing or skipping. This is really only valuable if your graphics card is fast and can exceed vsync rates by a factor of 2-3X. Note if the Vulkan eMailbox present mode is not available on a platform, the VSync Off GUI selection falls back to mean eImmediate (i.e. status quo with tearing).

Finally, this PR aligns the window type, size handling, and error reporting logic between SDL and Windows. Hopefully this will make it easier to maintain going forward.

I have tested these changes on all platforms: Windows 10, linux Manjaro, and macOS Monterey. In addition, I have tried the updated window resizing / Vulkan swapchain extent logic with tiling window managers on linux (xfce tiling settings) and macOS (magnet tiling manager). Hopefully this may solve the above issues.

I would appreciate testing and validation of this PR against the reported issues. If your problems are not solved, please report against your original issue and hopefully I can address it. Thanks.

  1. @sjnewbury and @rg3 (thanks for your code!) for Vulkan/Wayland broken since NVHRI landed #765
  2. @Oreolek for error running on linux (leftwm) #783
  3. @vide0hanz and @RobertBeckebans for Just compiled on Linux, unable to launch RBDoom3BFG  #740

@Oreolek
Copy link

Oreolek commented Jun 9, 2023

Yup, it definitely fixes #783. 🎉

@SRSaunders
Copy link
Author

Thanks for testing #783 - good news. Let's wait for results from the others.

@rg3
Copy link

rg3 commented Jun 12, 2023

Works here without issues in both Wayland and XWayland. Many thanks!

@SRSaunders
Copy link
Author

SRSaunders commented Jun 12, 2023

Thanks @rg3 for testing #765. Now let's wait for @RobertBeckebans to test his issue re swap chain extents on Kubuntu.

As an aside, does eMailbox mode (when VSync GUI = Disabled) work and provide value for you? If available on your platform and r_preferFastSync = true (default setting) you should see no visual tearing. However, is the frame skipping noticeable? If this works it should minimize frame latency without visual tearing on Vulkan.

@rg3
Copy link

rg3 commented Jun 12, 2023

As an aside, does eMailbox mode (when VSync GUI = Disabled) work and provide value for you? If available on your platform and r_preferFastSync = true (default setting) you should see no visual tearing. However, is the frame skipping noticeable? If this works it should minimize frame latency without visual tearing on Vulkan.

eMailbox mode works, eyeballing the frame counter with com_showFPS 1, and I see no visual tearing, but I don't know if frame skipping is noticeable. Gameplay feels OK to me.

For context, normally I use relatively recent GPUs, so in these old games I'm always above 60 FPS unless the port is doing something very demanding that can't be disabled (I use a 1440p 60Hz monitor). Due to this, I prefer to enable vsync so I experience no tearing and my GPU runs quieter and cooler. Doom 3 BFG is not a fast-paced shooter in any case.

That said, RADV users on Wayland have either FIFO or Mailbox available, so it's good to make both options available in some form through the menu instead of forcing them to use FIFO.

@SRSaunders
Copy link
Author

Thanks for the feedback. The main value in using eMailbox mode is for reducing input to presentation latency. The max engine frequency on RBDoom3-BFG is 120 Hz so you might see some benefit if running with a 60Hz monitor, i.e. dropping every second frame to reduce end-to-end latency without tearing artifacts.

@Calinou
Copy link

Calinou commented Jun 12, 2023

The max engine frequency on RBDoom3-BFG is 120 Hz

The com_engineHz cvar makes it possible to set this to any value, so you're not limited to just 60 and 120. I use 117 personally to achieve low input lag with VRR on a 120 Hz display.

@RobertBeckebans
Copy link
Owner

I still have to reinstall Kubuntu or another distro. Kubuntu destroyed itself again after an apt dist-upgrade.
@SRSaunders I have less time for computer stuff at the moment. I'm going to review your other PRs in July when I have vacation.

@Calinou
Copy link

Calinou commented Jun 16, 2023

I still have to reinstall Kubuntu or another distro. Kubuntu destroyed itself again after an apt dist-upgrade.

As a side note, Kubuntu isn't exactly the greatest KDE distro in town. The KDE developers themselves tend to frown upon it. I'd recommend Fedora with the KDE spin 🙂

@rg3
Copy link

rg3 commented Jun 17, 2023

While I'm not the reporter in issue #740, I did hit the problem while trying to run the game on Wayland in fullscreen mode under Gnome/Wayland (not in borderless fullscreen, for some reason). I can't reproduce it anymore with this PR.

@SRSaunders
Copy link
Author

@SRSaunders I have less time for computer stuff at the moment. I'm going to review your other PRs in July when I have vacation.

Thanks @RobertBeckebans, no worries. I have a few PRs stacked up but plan to slow down now for the summer. I will be interested in your feedback, especially re the possible latency improvements.

@RobertBeckebans RobertBeckebans merged commit 330486e into RobertBeckebans:master Jul 14, 2023
@SRSaunders
Copy link
Author

Hi Robert, thanks for merging. Did it solve #740 for your setup? I know you were experiencing issues on linux and I am hoping this finally fixes it.

@SRSaunders SRSaunders deleted the swapchain-fixes branch January 26, 2024 03:26
@naggie naggie mentioned this pull request May 4, 2024
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.

Vulkan/Wayland broken since NVHRI landed
5 participants