ValveSoftware / Proton

Compatibility tool for Steam Play based on Wine and additional components
Other
24.59k stars 1.07k forks source link

dlssg-to-fsr3 mod with Proton #7361

Open Zenzi0 opened 11 months ago

Zenzi0 commented 11 months ago

Feature Request

I confirm:

Description

Is it possible to use this mod with Proton? It replaces Nvidia Frame Generation with FSR3 in games like Cyberpunk 2077, The Witcher 3 and others. https://github.com/Nukem9/dlssg-to-fsr3/releases

Justification [optional]

Risks [optional]

References [optional]

Zenzi0 commented 11 months ago

A RTX graphics card is required. From what I've read one needs to place both .dll files into the folder with the game's executable (make a backup of the original dbghelp.dll). In game one needs to disable V-Sync. Another comment here recommends to enable Hardware-Accelerated GPU Scheduling (in Windows). I don't know whether that is possible in Linux. This could be a massive improvement for Nvidia graphics cards older then 40XX gpus.

Edit: They have since changed the installation instructions and the file names. Here are the instructions at the time of writing: dlssg-to-fsr3 has been tested in Cyberpunk 2077 and The Witcher 3 only.

dlssg-to-fsr3 may be obtained from: https://github.com/Nukem9/dlssg-to-fsr3

================================ ===== Install instructions =====

  1. Right click on "DisableNvidiaSignatureChecks.reg" and select "Merge". Click "Yes" when the dialog opens.

  2. Locate your game's installation directory. For Cyberpunk 2077, this would be the folder containing Cyberpunk2077.exe.

  3. Copy "dlssg_to_fsr3_amd_is_better.dll" and the new "nvngx.dll" to your game's installation directory.

  4. Done. Launch the game. You'll see a message box on startup.

================================ ==== Uninstall instructions ====

  1. Right click on "RestoreNvidiaSignatureChecks.reg" and select "Merge". Click "Yes" when the dialog opens.

  2. Delete "dlssg_to_fsr3_amd_is_better.dll" and "nvngx.dll" in your game's installation directory.

Saancreed commented 11 months ago

Wine currently does not support the APIs Streamline uses to check if Hardware Accelerated GPU Scheduling is enabled. I have a hack for this here which should apply to Wine 9.0-rc2 and some flavors of it.

Warning though, some assembly is required; you will need to compile your own Wine to use this (don't forget to run tools/make_specfiles before building, otherwise linking will fail). It seems to be working for me in Cyberpunk 2077 (you will need to export WINEHAGS=1 environment variable to enable it).

Zenzi0 commented 11 months ago

Maybe it is time to learn how to build packages and include patches then. But isn't something like this what a project like GloriousEggroll's proton-ge-custom would be willing to include? At least until a non-hacky alternative presents itself. I don't possess the knowledge to judge this accurately.

Gravechapa commented 11 months ago

Replying to https://github.com/ValveSoftware/Proton/issues/7361#issuecomment-1863639235

Thanks, it works. But I actually had to patch gpu detection to get dlss to work.

WildNightFoxy commented 11 months ago

Replying to #7361 (comment)

Thanks, it works. But I actually had to patch gpu detection to get dlss to work.

Could u say how to do it step by step :3 ?

MrDuartePT commented 11 months ago

Replying to #7361 (comment)

Thanks, it works. But I actually had to patch gpu detection to get dlss to work.

Well I gonna try both patches on my machine and report back. Just need to wait for the compile to end, the patches applied to wine-proton-9999 without problems: image

Saancreed commented 11 months ago

Don't forget to also apply the second patch from my gist, the hags-0002.patch one.

MrDuartePT commented 11 months ago

Well after adding the missing path and editing the ebuild to add tools/make_specfiles now should work.

MrDuartePT commented 11 months ago

@Saancreed it work but create graphical corruption: image

Edit: Turnning off dlss frame generation the bug disappear.

Pausing the game or staying still the color return to normal: image

I gonna try removing some env to see if solves it: image

Ok didnt solve. Can be a bug with wine since is a rc version

FakeMichau commented 11 months ago

This is the same result people got on Windows on GTX cards when using my nvapi-dummy (based on dxvk-nvapi) to spoof the GPU arch.

FakeMichau commented 11 months ago

@MrDuartePT Would you mind sharing your dxvk-nvapi log?

MrDuartePT commented 11 months ago

@MrDuartePT Would you mind sharing your dxvk-nvapi log?

Well I only could generate the VKD3D logs lets see if this helps: cyberpunk-vkd3d.txt

And I using a RTX 3070 Mobile (laptop) is very strange this is happening

RyanKelly-DC commented 11 months ago

A RTX graphics card is required. From what I've read one needs to place both .dll files into the folder with the game's executable (make a backup of the original dbghelp.dll). In game one needs to disable V-Sync. Another comment here recommends to enable Hardware-Accelerated GPU Scheduling (in Windows). I don't know whether that is possible in Linux. This could be a massive improvement for Nvidia graphics cards older then 40XX gpus.

Why is an Nvidia GPU required, when FSR is explicitly designed by AMD to be largely hardware agnostic?

dlove67 commented 11 months ago

Replying to https://github.com/ValveSoftware/Proton/issues/7361#issuecomment-1866879511

Because it uses DLSS, which is Nvidia only. It only uses the Frame gen component from FSR3.

MrDuartePT commented 11 months ago

Replying to https://github.com/ValveSoftware/Proton/issues/7361#issuecomment-1866879511

Even if you can spoof wine to think you have a Nvidia card it probably will not work very well since DLSS use Tensor Cores. AMD card could use the computer core but I think it will be very slow. Also FSR3 SDK is open source and work on every Directx12 it possible one day to update FSR hack to use FSR3. Or the games just implement FSR3.

Saancreed commented 11 months ago

Replying to https://github.com/ValveSoftware/Proton/issues/7361#issuecomment-1866706830

I'm unable to reproduce this issue. I can notice ghosting in Cyberpunk 2077 with the mod installed (or maybe it's more like frames being presented out of order sometimes?) but colors seem to be fine. Here's a quick comparison, FG disabled vs FG enabled:

Expand for some screenshots… ![Screenshot_20231222_025742](https://github.com/ValveSoftware/Proton/assets/26201033/c1b6cdf7-9e6a-42d9-bff0-bbd8533a38ce) ![Screenshot_20231222_025759](https://github.com/ValveSoftware/Proton/assets/26201033/675ee42a-52ed-4c21-af46-e8b336541d5f)

No such issue in Path Tracing SDK sample either. I don't really have too many FG games outside Steam I could test this with and I'd rather avoid angering online games like Diablo IV by loading unsigned binaries that install detours in other code segments, sorry :sweat_smile:

There might be a bug somewhere else in the stack that I somehow avoid on my own builds/hardware. But it's highly unlikely that my HAGS patch caused it.

MrDuartePT commented 11 months ago

Replying to https://github.com/ValveSoftware/Proton/issues/7361#issuecomment-1867154257

Probably my problem was that I use the latest commit of wine instead of the tagged 9.0-rc2 version. I gonna recompile wine and report back.

MrDuartePT commented 11 months ago

Lol nice catch github :)

MrDuartePT commented 11 months ago

It happening again even with the tagged 9.0-rc2 wine version: image

I gonna try reinstall the mod again Edit: With gamescope and even reinstalling the mod still happening Very strange you can reproduce it @Saancreed Probably because you have a 4000 series card?

Saancreed commented 11 months ago

If anything, it's the version of vkd3d-proton used here that has the greatest chance of affecting this and not Wine. And for that I'm using 2.11.1 patched with Nvidia Reflex support (PR 1739 but rebased to latest vkd3d-proton and Vulkan-Headers), my own patches adding support for Opacity Micromaps and pull request 1806 (because I've heard it needs some testing).

But this is strange enough that I feel like someone would need to point NSight/Renderdoc at this thing to figure it out.

MrDuartePT commented 11 months ago

If anything, it's the version of vkd3d-proton used here that has the greatest chance of affecting this and not Wine. And for that I'm using 2.11.1 patched with Nvidia Reflex support (PR 1739 but rebased to latest vkd3d-proton and Vulkan-Headers), my own patches adding support for Opacity Micromaps and pull request 1806 (because I've heard it needs some testing).

But this is strange enough that I feel like someone would need to point NSight/Renderdoc at this thing to figure it out.

I can try that version of vkd3d-proton and see if solve it. You would mind sharing your patches and the NVIDIA reflex rebase one. Since vkd3d-proton 2.11.1 is avaiable as gentoo ebuild I can just add the patch and rebuilding it.

edit: After testing vkd3d-proton withouth patches the problem remains.

MrDuartePT commented 11 months ago

By the way one off my friend on gentoo also confirm it happen on The Witcher 3. Using the patched wine-staging 9.0-rc2. But the fps is good.

MrDuartePT commented 11 months ago

@Saancreed try the SDK and unfortunately need Nvidia Reflex to enable DLSS-G i will try to rebase the patches later

Saancreed commented 11 months ago

You would mind sharing your patches and the NVIDIA reflex rebase one.

I can do that in a few hours from now, plus I'll attach the exact config I'm using to build my Wine (using wine-tkg-git).

Saancreed commented 11 months ago

Okay, so starting with Wine, I'm building wine-tkg-git using a config like this:

wine-tkg.conf _NOCCACHE="true" _NOINITIALPROMPT="true" _LOCAL_PRESET="none" _PKGNAME_OVERRIDE="none" #_GCC_FLAGS+=" -march=x86-64-v3" #_CROSS_FLAGS+=" -march=x86-64-v3" # problematic, needs a workaround for gcc bug this runs into, otherwise will break 32-bit applications _user_deps+=" libgcrypt lib32-libgcrypt" _user_deps+=" pcsclite lib32-pcsclite" _user_deps+=" libdrm lib32-libdrm" _user_deps+=" libxkbcommon lib32-libxkbcommon" _user_deps+=" wayland lib32-wayland" _user_makedeps+=" wayland-protocols" _user_makedeps+=" winesync-header" _staging_commit='#tag=v9.0-rc2' _use_fastsync="true" _use_vkd3dlib="true" _proton_fs_hack="false" _win10_default="true" _protonify="true" _proton_battleye_support="true" _proton_eac_support="true" _user_patches_no_confirm="true" _hotfixes_no_confirm="false" _allow_server_rt_prio="true" _allow_wine_net_raw="true"

Of all these, probably the only only relevant settings are using the Staging (default) and Protonify patches.

Then, using the userpatches system I'm reverting Wine commit 354a8bb1f4a65bdec052606f2799db9e2907b5b1 (for other reasons, most likely unrelated to this), adding f6d04e332309159de4dc3aab219aafa838a0a3c0 ("win32u: Don't deactivate the target thread when setting the foreground window." because I'm experimenting with winewayland), adding my HAGS patches, updating Ubisoft Connect hack to append --use-angle=vulkan instead as Proton does, extending AC Odyssey hack for Immortals Fenyx Rising as well, and hacking WS_EX_TOPMOST in winex11 to not be so annoying when combined with fullscreen windows on KWin. Only the HAGS patch is important here, I think. Notably, the "GPU detection" patch shouldn't be needed because something like that is already included in Protonify patchset.

Since this project targets Arch users, you might have a hard time using it on Gentoo. Either try included non-makepkg-build.sh script or manually borrow all the patches it applies to your own ebuild (good luck!).

For the remaining projects, my versions of patches are here.

Moving on to dxvk-nvapi, I'm applying PR 147 as is then my OMM patches hacked rebased on top of Reflex. They are probably of little use to you on Ampere but if you wish to try anyway, they are in the dxvk-nvapi-reflex-omm.diff file in the Gist linked above.

Then, when building vkd3d-proton, checkout tag 2.11.1, forcufully update Vulkan-Headers submodule at khronos/Vulkan-Headers to latest (v1.3.274 but any version equal to v1.3.271 or newer should work), apply my modified Reflex patch (vkd3d-proton-reflex.patch file from the Gist) and optionally apply OMM patches (vkd3d-proton-reflex-omm.diff file from the Gist) and/or PR 1806.

Finally, there is dxvk-reflex.patch file that can be used with DXVK if you wish to use Reflex in D3D11 titles, which again requires updating included Vulkan-Headers submodule at include/vulkan just like vkd3d-proton did.

Oh, and make sure you don't have LatencyFleX available because it has higher priority but it doesn't fully implement all APIs Reflex requires. At worst, use WINEDLLOVERRIDES=latencyflex_layer,latencyflex_wine= to disable loading it.

With all this (and Nvidia's nvngx.dll and _nvngx.dll installed into the prefix, and DXVK_ENABLE_NVAPI=1 in the environment) you should have DLSS Super Resolution and Reflex exposed and working correctly, and with WINEHAGS=1 plus the mod, Frame Generation should also become usable. Try this with Path Tracing SDK and let me know how it went.

MrDuartePT commented 11 months ago

Everthing is done just not compile wine-tkg, frist I gonna see if it really needed. Edit: Is working no need for wine-tkg image withouth DLSS-FG I only get 23fps.

Now I juts gonna try cyberpunk and see if the weird graphical glith is gone with nvidia reflex enable.

Can also confirm in game if I enable reflex and after FG the weird color disappear. Tomorrow I post here a screenshot.

Note: I use all patches in vkd3d-proton includes the https://github.com/HansKristian-Work/vkd3d-proton/pull/1806 besides needing testing it seems to be working

MrDuartePT commented 11 months ago

@Saancreed sorry for the ping but I’m a bit currious. It any intention of adding WINEHAGS patches to wine-staging since it work very well. If get shipped on wine-9.0 it possible to also be included in proton-9.

Saancreed commented 11 months ago

Probably not anytime soon, Wine is currently in code freeze and only fixes will be accepted until 9.0 is released. The earliest something like this could get in would be Wine 9.1, I believe.

MrDuartePT commented 11 months ago

As you can see in this small demo. Now nvidia reflex get activated when DLSS FG is activated (is normal behavior of the game). Now we can conclude it only possible to use this mod, when WINEHAGS is added to wine and Nvidia Reflex were supported in DXVK, DXVK-NVAPI, VKD3D and VKD3D-Proton.

https://github.com/ValveSoftware/Proton/assets/68701049/bdcb9201-47c2-431b-a08b-c955e5696b5e

Edit: The fps is kinda low with the recording, for some reason NVENC is having a bad time :(

MichaelGoodale commented 11 months ago

I managed to get it working on Cyberpunk with these extra reflex patches, thanks so much!

MrDuartePT commented 11 months ago

Probably not anytime soon, Wine is currently in code freeze and only fixes will be accepted until 9.0 is released. The earliest something like this could get in would be Wine 9.1, I believe.

Well you can always submit a PR and see what they say. The same for @Gravechapa gpu patch

Gravechapa commented 11 months ago

@MrDuartePT My patch is from Valve's wine code.

MrDuartePT commented 11 months ago

@MrDuartePT My patch is from Valve's wine code.

Oh ok. Well if winehags get added in the future proton should added as well

XDM-Inc commented 11 months ago

where can i learn how to patch wine/proton to try this? i dont know where to start and im very interested in getting this stared

MichaelGoodale commented 11 months ago

@XDM-Inc I'd recommend checking out https://github.com/Frogging-Family/wine-tkg-git You can put the wine-hags patches in the wine-tkg-git/wine-tkg-userpatches and the other ones in the proton user patches.

Note that you will need to do something slightly more complicated here, and modify the https://github.com/Frogging-Family/wine-tkg-git/blob/master/proton-tkg/proton-tkg.sh so that the Vulkan-Headers submodule are checked out to the right branch, so watch out for that part, it's the most complicated!

Zenzi0 commented 11 months ago

Would you be willing to share your modified proton-tkg.sh? It is my first time doing something like this and I can't wrap my head around it. My best guess is to add something like git checkout vkd3d-proton-2.11.1.tar.gz in the vkd3d section around line 320. And I have no idea how to forcefully update the Vulkan-Headers submodule since I can't identify a section for it in the file.

On another note: Am I right to assume I should rename the patches and diffs to .mypatch, .mydxvkpatch and .myvkd3dpatch?

MichaelGoodale commented 11 months ago

Hi @Zenzi0 I forked wine-tkg-git with the appropriate changes and with the right patches. https://github.com/MichaelGoodale/wine-tkg-git

And I have no idea how to forcefully update the Vulkan-Headers submodule since I can't identify a section for it in the file.

Yeah, it's a little tricky you need to do it after cloning the dxvk after the submodules have been updated.

Zenzi0 commented 11 months ago

Thank you so much. I've had a look at the changes inside proton-tkg.sh. Doesn't look like much, but I would have never gotten that on my own. Trying to build it right now.

MichaelGoodale commented 11 months ago

No worries! Enjoy the extra FPS :)

WildNightFoxy commented 11 months ago

No worries! Enjoy the extra FPS :)

How to properly build proton for the steam deck? I have error when it try to patch hags(

Zenzi0 commented 11 months ago

This mod in particular is for Nvidia cards only and won't work on the Steam Deck. Though I think there are a bunch of these mods now. And some intended for AMD and therefore might be suitable for the Steam Deck.

WildNightFoxy commented 11 months ago

This mod in particular is for Nvidia cards only and won't work on the Steam Deck. Though I think there are a bunch of these mods now. And some intended for AMD and therefore suitable for the Steam Deck.

Thanks)

Calculus8303 commented 11 months ago

I forked wine-tkg-git with the appropriate changes and with the right patches. https://github.com/MichaelGoodale/wine-tkg-git

Appreciate the fork, what distro and version did you use? Does one first build in wine folder, and then use proton script? I almost got it to finish once, but ran into a font error near the end when using danger89/wine-pkgbuilds:latest . On Pop!_OS, it's not going so well. A fresh arch container is another set of headaches. Stuck between an itch to get this working and desire to just get on with life.

giantplaceholder commented 11 months ago

Was able to succesfully build proton-tkg build per https://github.com/ValveSoftware/Proton/issues/7361#issuecomment-1869712251.

Hitting the same issue as in https://github.com/ValveSoftware/Proton/issues/7361#issuecomment-1867541612 -- can't enable Reflex properly, so purple tint is present.

Any idea what I'm missing? I've build vkd3d-proton separately with the Reflex patches, but hitting the same wall.

Saancreed commented 11 months ago

@giantplaceholder A shot in the dark, but are you on 545.29.06 driver version and did you also build dxvk-nvapi with Reflex patches? If yes and it still refuses to cooperate, send a log made with PROTON_LOG=1 DXVK_NVAPI_LOG_LEVEL=info %command%.

giantplaceholder commented 11 months ago

@Saancreed I'm on latest available vulkan-dev, as of now (535.43.22).

I've built dxvk-nvapi with required patches manually and stuffed it into the proton libs, so it's definitely should be present in the prefix.

Saancreed commented 11 months ago

535.43.22

Yeah that's previous driver branch that does not expose the VK_NV_low_latency2 extension, not even the Vulkan Developer Beta flavor, you need 545.29.06 for this to work. Or some previous release from 545 branch if you use Reflex patches as submitted in PR to vkd3d-proton repo instead of my updated version.

giantplaceholder commented 11 months ago

535.43.22

Yeah that's previous driver branch that does not expose the VK_NV_low_latency2 extension, not even the Vulkan Developer Beta flavor, you need 545.29.06 for this to work. Or some previous release from 545 branch if you use Reflex patches as submitted in PR to vkd3d-proton repo instead of my updated version.

So you are saying that even though 535.43.22 is actually newer than 545.29.06, it doesn't have that API exposed, correct?

Saancreed commented 11 months ago

Yup. You can verify this yourself using tools like vulkaninfo.

giantplaceholder commented 11 months ago

@Saancreed I see. Thanks for your help.

I managed to get it working with Cyberpunk. Works pretty much the same as on Windows, albeit with much more noticeable ghosting on contrast shadows -- no matter if RT is used or not. Input latency is noticeably worse than in Windows.

Enabling FG option in game's menu whilst Reflex option is disabled, and then enabling Reflex manually = instant game crash.

For whomever wants to repeat this config, it would be enough to install 535.29.06 drivers and build https://github.com/MichaelGoodale/wine-tkg-git using default its proton-tkg.sh, selecting fourth option (Wine upstream proton), whilst applying all patches it will ask to apply. Takes about 30 minutes to build on an i5-13600K.