RobertBeckebans / RBDOOM-3-BFG

Doom 3 BFG Edition source port with updated DX12 / Vulkan renderer and modern game engine features
https://www.moddb.com/mods/rbdoom-3-bfg
GNU General Public License v3.0
1.38k stars 247 forks source link

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

Closed SRSaunders closed 10 months ago

SRSaunders commented 11 months ago

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. :white_check_mark: @sjnewbury and @rg3 (thanks for your code!) for #765
  2. :white_check_mark: @Oreolek for #783
  3. :grey_question: @vide0hanz and @RobertBeckebans for #740
Oreolek commented 11 months ago

Yup, it definitely fixes #783. :tada:

SRSaunders commented 11 months ago

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

rg3 commented 11 months ago

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

SRSaunders commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 :slightly_smiling_face:

rg3 commented 11 months ago

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 commented 10 months ago

@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.

SRSaunders commented 10 months ago

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.