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

[Feature Request] Implement equivalent of VKD3D_DISABLE_EXTENSIONS for DXVK #4510

Open
matte-schwartz opened this issue Dec 7, 2024 · 2 comments

Comments

@matte-schwartz
Copy link

Some background context here:
On NVIDIA GPUs under gamescope, when using Gamescope WSI + HDR with either the Wayland backend or the DRM backend, there is a ~25% chance of the game you are trying to run appearing to freeze on a random frame within the first couple of seconds or minutes of running, and remaining stuck on that frame while audio continues to play. This happens under both vkd3d-proton and DXVK, and has a gamescope issue tracking it: ValveSoftware/gamescope#1592 (NV bug 4924590).

As someone in the gamescope thread noted, the freeze can be worked around by disabling VK_KHR_present_wait. In vkd3d-proton, this is possible to do at runtime with VKD3D_DISABLE_EXTENSIONS=VK_KHR_present_wait and it works for the D3D12 games I tested that previously froze with HDR. Eventually, I found a DirectX 11 game that supported HDR and froze for me (Ori and the Will of the Wisps) to poke around a bit, but I wasn't able to find any readily available debugging option for testing DXVK with VK_KHR_present_wait disabled in a similar manner.

To get around this, I cooked up a somewhat goofy patch sprucing up the old workaround logic here

// Unless we're on an Nvidia driver where these extensions are known to be broken
if (matchesDriver(VK_DRIVER_ID_NVIDIA_PROPRIETARY, Version(), Version(535, 0, 0))) {
enabledFeatures.khrPresentId.presentId = VK_FALSE;
enabledFeatures.khrPresentWait.presentWait = VK_FALSE;
}
to instead apply this to all NVIDIA driver versions. Re-building DXVK with this patch and using it in a Proton build reliably avoids hanging Ori and the Will of the Wisps w/ gamescope + HDR enabled on my RTX 4090 rig, so it seems like it might be worthwhile to ask others to test this workaround if they experience similar issues in other titles.

Instead of asking people to go through the steps of patching and re-building DXVK to try disabling VK_KHR_present_wait (or any VK extension I suppose), I think it would make more sense to consider introducing a DXVK_DISABLE_EXTENSIONS debugging function that could be used to disable certain extensions similar to what vkd3d-proton does with VKD3D_DISABLE_EXTENSIONS.

@doitsujin
Copy link
Owner

doitsujin commented Dec 7, 2024

Wouldn't it make more sense for DXVK to just not use the extension on Nvidia then if it's still broken? Am I misunderstanding anything here?

I guess we could technically add a config to not use present_wait, but just implementing a VKD3D_DISABLE_EXTENSIONS equivalent isn't a great idea in general since it'll just stop working if the feature ever gets promoted to core Vulkan and we start using it (it's already not really great on the vkd3d side for that reason), and making users work around driver issues seems a bit awkward.

@matte-schwartz
Copy link
Author

Wouldn't it make more sense for DXVK to just not use the extension on Nvidia then if it's still broken? Am I misunderstanding anything here?

No, I think that would also be a more ideal workaround. I wasn't sure about the potential impact of such a change which is why I was apprehensive to suggest it.

I guess we could technically add a config to not use present_wait, but just implementing a VKD3D_DISABLE_EXTENSIONS equivalent isn't a great idea in general since it'll just stop working if the feature ever gets promoted to core Vulkan and we start using it (it's already not really great on the vkd3d side for that reason), and making users work around driver issues seems a bit awkward.

This makes sense to me as well. Definitely not an ideal situation to make users do the extra work of dealing with a driver issue, so taking care of it upstream until the underlying issue is fixed would be preferable.

I could submit this as a PR if you'd like, unless you see a better way to handle the approach of disabling it:

From 3d0c15678f85eb7b24d9d1f949bef3c45d5f1352 Mon Sep 17 00:00:00 2001
From: Matthew Schwartz <[email protected]>
Date: Sat, 30 Nov 2024 17:27:42 -0800
Subject: [PATCH] [util]/[hack]: disable VK_KHR_present_wait under all Nvidia
 drivers

Fixes presentation in some games that use DX11 freezing under gamescope,
only when VK_KHR_present_wait is in use on NV. This is a temporary
workaround until a proper fix is found.

Link: https://github.com/ValveSoftware/gamescope/issues/1592
---
 src/dxvk/dxvk_adapter.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/dxvk/dxvk_adapter.cpp b/src/dxvk/dxvk_adapter.cpp
index 1285c4ee..d884217e 100644
--- a/src/dxvk/dxvk_adapter.cpp
+++ b/src/dxvk/dxvk_adapter.cpp
@@ -427,7 +427,8 @@ namespace dxvk {
       m_deviceFeatures.khrPresentWait.presentWait;
 
     // Unless we're on an Nvidia driver where these extensions are known to be broken
-    if (matchesDriver(VK_DRIVER_ID_NVIDIA_PROPRIETARY, Version(), Version(535, 0, 0))) {
+    // under gamescope
+    if (matchesDriver(VK_DRIVER_ID_NVIDIA_PROPRIETARY)) {
       enabledFeatures.khrPresentId.presentId = VK_FALSE;
       enabledFeatures.khrPresentWait.presentWait = VK_FALSE;
     }
-- 
2.47.1

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

No branches or pull requests

2 participants