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

Nvidia Reflex support #4632

Merged
merged 22 commits into from
Jan 25, 2025
Merged

Nvidia Reflex support #4632

merged 22 commits into from
Jan 25, 2025

Conversation

doitsujin
Copy link
Owner

@doitsujin doitsujin commented Jan 21, 2025

This implements Reflex support through dxvk-nvapi's ID3DLowLatencyDevice on drivers that support VK_NV_low_latency2. Fairly invasive change since we need to pass frame IDs all over the place and mess around with certain markers to account for internal threading.

Tested in a few games:

  • Ghostrunner: Broken, game never even calls the function to enable Reflex at all, let alone the sleep function.
  • Ghostrunner 2: Works as expected.
  • God of War: Works as expected.
  • Mordhau: Game sets present markers but thinks that Reflex is unsupported, so you can't enable it in game. (???)
  • Overwatch 2: Works, but only if Vsync is disabled. I don't know if this is expected behaviour.
  • Quake Champions: Doesn't use markers, but appears to work.

Not sure if there are any other Reflex-enabled D3D11 games that aren't simultaneously blocked by anti-cheat measures, it's a bit unfortunate that the only UE4 test case seems to be bugged at a game level.

This also adds a HUD item (latency) that will show up when a game uses latency markers, and will display the average time it takes from the game setting the SIMULATION_START (or INPUT_SAMPLING, if it uses that) marker to presentation of the given frame completing on the GPU, as well as the average latency sleep duration.

Bildschirmfoto-829

Things that are not really supported very well include non-monitonic frame IDs (dxvk-nvapi sorts these out for us so that should never happen anyway), and the whole thing probably isn't very well behaved when a game randomly skips markers for a frame since it breaks our way of correlating app-provided frame IDs with the ones we use for the Vulkan swapchain.

Finally, this adds an option to enable latency sleep for older games; the obvious downside here is that we can only really sleep after Present, so this isn't going to do all that much in games that have an asynchronous render thread, besides reducing some buffering inside DXVK. This can be enabled by setting dxvk.latencySleep = True in the configuration file.

Supersedes #4623, #3690.

We'll need this in more places.
Implements a basic latency sleep solution that is intended to work
without requiring games to support any related vendor features.

This alone is not enough to expose the Reflex API to applications via
dxvk-nvapi, but since that relies on NV_low_latency2 specifics anyway,
we are going to add an implementation based on that extension later
with an extended interface.
Introduces two queues and allows us to dispatch chunks to the ordered
queue without disrupting the sequence number.
@WinterSnowfall
Copy link
Contributor

WinterSnowfall commented Jan 23, 2025

I've tested out dxvk.latencySleep = True in quite a few d3d8 and d3d9 games and it does seem to work as intended, pretty much negating the latency introduced by VSync. How observable the effect is ultimately depends on other aspects of a game and of course the eye of the beholder.

I haven't run into any ill effects or instability, beside a minor quirk in Aquanox 2 - it, for some reason, seems to halve its framerate at times with the setting enabled, which doesn't happen with it disabled.

@qinlili23333
Copy link
Contributor

Suggest game for test: My Time at Sandrock (D3D11, Unity 2021, Single player game without anticheat)
Party Animals may also be useful for test.

The full list of Reflex enabled games: https://www.nvidia.com/en-au/geforce/technologies/reflex/supported-products/

@doitsujin
Copy link
Owner Author

I'm aware of the full list, but 99% of the games on that are D3D12 only so it's kinda hard to really pick something out.

Anyway, will give that Unity game a go.

@doitsujin
Copy link
Owner Author

Nevermind my previous comment, it does actually do something, just wasn't testing the correct dxvk branch 🐸

Too bad the game is CPU-bound like hell so there's no actual latency sleep happening.

@doitsujin doitsujin merged commit 736ee20 into master Jan 25, 2025
8 checks 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.

3 participants