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

Support VK_NV_low_latency2 #200

Open
wants to merge 678 commits into
base: experimental_8.0
Choose a base branch
from

Conversation

esullivan-nvidia
Copy link

This PR updates the Vulkan xml file to 1.3.267, and adds some additional support for the VK_NV_low_latency2 extension to winevulkan. The only code changes needed are for passing in a valid frame id to fshack's vkQueueSubmit.

rbernon and others added 30 commits September 27, 2023 16:08
…p size changes."

This reverts commit 2a44dd0.
CW-Bug-Id: #21879
…after the desktop has been resized."

This reverts commit e56ad03.
CW-Bug-Id: #21879
(cherry picked from commit 26c6386)
CW-Bug-Id: #21879
…dow.

This doesn't create anything, but instead notifies the user driver of
the current desktop window, either when it is created, or when a thread
calling NtUserGetDesktopWindow receives the current desktop window.

(cherry picked from commit 15dfe2e)
CW-Bug-Id: #21879
…ated.

When the default desktop window is created, its parent is always NULL,
and SetDesktopWindow is never called here.

(cherry picked from commit 8b5bdb1)
CW-Bug-Id: #21879
(cherry picked from commit f9c1b6a)
CW-Bug-Id: #21879
(cherry picked from commit 4b5311c)
CW-Bug-Id: #21879
(cherry picked from commit c22c10d)
CW-Bug-Id: #21879
(cherry picked from commit 1cea2be)
CW-Bug-Id: #21879
(cherry picked from commit 3bce247)
CW-Bug-Id: #21879
(cherry picked from commit 900ba82)
CW-Bug-Id: #21879
(cherry picked from commit 46d2761)
CW-Bug-Id: #21879
(cherry picked from commit 29ac54e)
CW-Bug-Id: #21879
(cherry picked from commit 1bf316c)
CW-Bug-Id: #21879
Eric Pouech and others added 15 commits September 27, 2023 16:08
Signed-off-by: Eric Pouech <epouech@codeweavers.com>

(cherry picked from commit 6558611)

CW-Bug-ID: #20860

This patch doesn't let the game start; this patch lets the game crash
a little bit further down the road.
(cherry picked from commit 3431949)

CW-Bug-Id: #22498
(upstream commit 6217369)

CW-Bug-Id: #22660
Needed for ntlea.

(upstream commit 74027f3)

CW-Bug-Id: #22660
Needed for ntlea.

(upstream commit 2508bb8)

CW-Bug-Id: #22660
ntlea for some reason expects GetWindowLongA to start with a "push $-2", and
will try to skip over this instruction. If we don't anticipate this, it will
ended up either skipping over critical instructions, or on a desync address.

(upstream commit f9f9481)

CW-Bug-Id: #22660
This reverts commit 87fbf33.

We saw hangs in Phasmophobia with the commit, and then discovered this commit is
not strictly necessary for ntlea, so we revert it.
To support VK_NV_low_latency2 a frame ID should be provided for each
call to vkQueueSubmit. This commit adds a path for fshack to provide
a frame ID when it submits its upscaling work, when low latency mode
is enabled.
@ivyl
Copy link
Collaborator

ivyl commented Oct 15, 2023

What is this for? Are there any consumers of this API out there that will benefit from supporting it?

It would be nice to get the Vulkan version bump upstreamed. Save hassle when rebasing the tree.

Also the custom implementation of vkSetLatencySleepModeNV, it looks like it's there for setting the private low_latency_enabled for fshack. Is there any reason why we don't handle passing .sType and .pNext and set them to hardcoded values?

@Etaash-mathamsetty
Copy link
Contributor

What is this for? Are there any consumers of this API out there that will benefit from supporting it?

It would be nice to get the Vulkan version bump upstreamed. Save hassle when rebasing the tree.

Also the custom implementation of vkSetLatencySleepModeNV, it looks like it's there for setting the private low_latency_enabled for fshack. Is there any reason why we don't handle passing .sType and .pNext and set them to hardcoded values?

for the first question, there are PRs on the dxvk and dxvk-nvapi repos to add support for this extension to enable reflex in games, so yes there are consumers

@ivyl
Copy link
Collaborator

ivyl commented Oct 16, 2023

Linking to the related PRs that those are all cross-linked:

doitsujin/dxvk#3690
HansKristian-Work/vkd3d-proton#1739
jp7677/dxvk-nvapi#147

@ivyl
Copy link
Collaborator

ivyl commented Oct 16, 2023

Bump to Vulkan 1.3.267 has been cherry-picked from upstream. This unblocks work on other projects - testing that it works when the supporting driver finally drops. Only the fshack remains but it's not essential and we can iterate on it a bit.

loathingKernel added a commit to loathingKernel/Proton that referenced this pull request Nov 22, 2023
Requires at least Nvidia 545.xx drivers.

The patches are from the following pull requests:
[wine](ValveSoftware/wine#200)
[dxvk-nvapi](jp7677/dxvk-nvapi#147)
[vkd3d-proton](HansKristian-Work/vkd3d-proton#1739)
[dxvk](doitsujin/dxvk#3690)

Thanks also goes to @ptr1337 for initially building and testing the patchset.
loathingKernel added a commit to loathingKernel/Proton that referenced this pull request Nov 22, 2023
Requires at least Nvidia 545.xx drivers.

The patches are from the following pull requests:
[wine](ValveSoftware/wine#200)
[dxvk-nvapi](jp7677/dxvk-nvapi#147)
[vkd3d-proton](HansKristian-Work/vkd3d-proton#1739)
[dxvk](doitsujin/dxvk#3690)

Thanks also goes to @ptr1337 for initially building and testing the patchset.
struct wine_device* wine_device = wine_device_from_handle(device);
struct wine_swapchain* wine_swapchain = wine_swapchain_from_handle(swapchain);

wine_device->low_latency_enabled = pSleepModeInfo->lowLatencyMode;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Vulkan Docs:

Parameters

  • pSleepModeInfo is NULL or a pointer […]

Description
If pSleepModeInfo is NULL, vkSetLatencySleepModeNV will disable low latency mode, low latency boost, and set the minimum present interval previously specified by VkLatencySleepModeInfoNV to zero on swapchain.

Shouldn't this function handle cases where pSleepModeInfo is NULL? Right now it looks like it will try to unconditionally dereference passed pointer without checking for NULL and likely crash if one was passed by the caller.

Jan200101 pushed a commit to Jan200101/NorthstarProton that referenced this pull request Jan 28, 2024
Requires at least Nvidia 545.xx drivers.

The patches are from the following pull requests:
[wine](ValveSoftware/wine#200)
[dxvk-nvapi](jp7677/dxvk-nvapi#147)
[vkd3d-proton](HansKristian-Work/vkd3d-proton#1739)
[dxvk](doitsujin/dxvk#3690)

Thanks also goes to @ptr1337 for initially building and testing the patchset.
@ptr1337
Copy link

ptr1337 commented Mar 1, 2024

@esullivan-nvidia

Could you please update this for the experimental 9 or proton 9 branch?
Thanks in advance

Edit:
It fails currently with:

touch /tmp/makepkg/proton-cachyos/src/build/.wine-source
cd /tmp/makepkg/proton-cachyos/src/build/src-wine && tools/make_specfiles
dlls/ntdll/ntsyscalls.h updated
dlls/win32u/win32syscalls.h updated
cd /tmp/makepkg/proton-cachyos/src/build/src-wine && tools/make_requests
include/wine/server_protocol.h updated
include/wine/server_protocol.h updated
server/trace.c updated
server/request.h updated
cd /tmp/makepkg/proton-cachyos/src/build/src-wine && dlls/winevulkan/make_vulkan -x vk.xml
Traceback (most recent call last):
  File "/tmp/makepkg/proton-cachyos/src/build/src-wine/dlls/winevulkan/make_vulkan", line 215, in <module>
    "vkSetLatencySleepModeNV" : {"dispatch": True, "driver": False, "thunk" : ThunkType.NONE},
                                                                              ^^^^^^^^^
NameError: name 'ThunkType' is not defined
make[1]: *** [../proton/Makefile.in:451: /tmp/makepkg/proton-cachyos/src/build/.wine-post-source] Error 1
make[1]: Leaving directory '/tmp/makepkg/proton-cachyos/src/build'
make: *** [../proton/Makefile.in:1197: dist] Error 2

Fixing the thunks issue results into:

/tmp/makepkg/proton-cachyos/src/build/src-wine/dlls/winevulkan/vulkan.c: In function ‘wine_vkSetLatencySleepModeNV’:
/tmp/makepkg/proton-cachyos/src/build/src-wine/dlls/winevulkan/vulkan.c:919:68: error: ‘struct wine_device’ has no member named ‘device’
  919 |     return wine_device->funcs.p_vkSetLatencySleepModeNV(wine_device->device, wine_swapchain->swapchain, &sleep_mode_info_host);
      |                                                                    ^~
/tmp/makepkg/proton-cachyos/src/build/src-wine/dlls/winevulkan/vulkan.c:919:94: error: ‘struct wine_swapchain’ has no member named ‘swapchain’; did you mean ‘host_swapchain’?
  919 |     return wine_device->funcs.p_vkSetLatencySleepModeNV(wine_device->device, wine_swapchain->swapchain, &sleep_mode_info_host);
      |                                                                                              ^~~~~~~~~
      |                                                                                              host_swapchain

@ptr1337
Copy link

ptr1337 commented Mar 1, 2024

was able to fix the patch and test against proton 9.
Everything is working fine.
Here the patch:
https://github.com/CachyOS/CachyOS-PKGBUILDS/blob/master/proton-cachyos/proton-cachyos/wine-reflex.patch

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.