Solveddxvk Pipeline cache

@doitsujin I decided to make another issue to move the pipeline discussion out of #646.

It occurs to me that the pipelines produced by Vulkan cannot be cached because they are driver specific (and therefore would need to be invalidated by driver updates, provided that they are possible to cache in the first place).

However, the shaders that games pass to DXVK that are processed to create the pipelines can be cached. If DXVK were to dump those into a SQLite database indexed by checksum (or perhaps binary name), it could look up all shaders passed to it in past sessions. If it indexed by binary name, it would be able to begin precompiling pipelines as soon as it is initialized.

We probably would want some sort of decay to delete stale data that is no longer relevant due to game updates and maybe even a second level of decay where we keep the checksum around in case it is just infrequently used (such that we could apply the ARC algorithm or something similar).

This would decouple shader cache invalidation from driver version such that driver updates would not slow things down. If the DXBC is cached, then updates and improvements to DXVK could reuse the cache.

This is just a rough idea, but I wanted to put it out there for consideration. What do you think?

42 Answers

✔️Accepted Answer

There's a working implementation in the dxvk-shader-cache-v2 branch. Enable it by setting dxvk.useStateCache = True in the configuration file. Right now, the cache file location is hardcoded to be dxvk.scache next to the game's executable.

Like the original implementation, it caches only the pipeline state vectors, which has the following implications:

  • The cache files are relatively small (the highest I've seen so far is 12 MB for the Unity Blacksmith demo with well over 6000 pipelines)
  • They will survive driver updates and can even be shared with other users if necessary (might become useful in the future, thinking of games like Overwatch here)
  • They will also survive most DXVK updates, unless incompatible changes to the pipeline state have to be made

One of the problems that I've run into with past attempts is that compiling the exact same pipeline multiple times at the same time apparently crashes drivers. The new code works around this issue, and now it appears to be stable.

Other Answers:

This is now implemented in master and enabled by default.

Impressive, with this branch I get the following results on my GTX 1080 with the Arkham Knight built-in Benchmark:

DXVK cache disabled:
Min 17 Max 77 Avg 48
With pre-filled DXVK cache (DXVK: Read 6198 valid state cache entries):
Min 33 Max 90 Avg 54

I invalidated the NVidia cache between runs (using__GL_SHADER_DISK_CACHE_PATH env variable).

Once the Nvidia cache is filled I get more or less identical results when using or not using the DXVK cache (Min 32 Max 91 Avg 54). Very cool that driver updates will no longer have such a huge effect.

Related Issues:

41
dxvk Pipeline cache
There's a working implementation in the dxvk-shader-cache-v2 branch Enable it by setting dxvk.useSta...
13
dxvk Resident Evil 2 remake stucks at the loading screen
Guys guys In RESIDENT EVIL 2 / BIOHAZARD RE:2 I can play the intro level (at the gas station) which ...
12
dxvk DXVK replaces dxgi.dll, what does it mean for vkd3d?
As of 1e393bf and using latest wine-git dxvk can be used with wine's DXGI DLL so that only d3d11.dll...
5
dxvk Hellblade: Senua's Sacrifice crashes without DXVK_SHADER_OPTIMIZE=1
@60fpshacks @xpander69 It would be good if you isolate bad shader(s) and attach it (them) to be anal...
4
bgfx could not load library "libc++_shared.so"
For me I made it work by coping C:\Users\%username%\AppData\Local\Android\sdk\ndk-bundle\sources\cxx...
32
lutris [Ubuntu 18.04] ERROR: ld.so: object 'libgtk3-nocsd.so.0' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
I see the error online elsewhere but I only ever saw it on my machine after running Lutris My guess ...
20
mumble macOS Mojave: passing the null port to CGEventTapEnable() segfaults
This is because the accessibility access for Mumble gets disabled on upgrade Trying to run Mumble-1....
15
winetricks not able to install dotnet >= 45
For anyone else having this problem a workaround is to run: The installer for .NET 4.0 will run firs...
11
lutris Lutris - Unable to get runners
Hello I just wanted to say that runnign the following commands fixed my issue: So i have this strang...
4
winetricks need wmp9 to install on 64 bits Wine prefix
Sorry for not submitting a PR or something but I don't know anything about git and it's quick & dirt...
358
atom Sometimes opening a file, Atom does not open in a new tab
This feature is called Pending Pane Items (formerly known as Preview Tabs) – this allows you to quic...
331
psutil psutil fails to install on python3.6 and Ubuntu16.04
I was just about to comment the same after I read the install file: https://github.com/giampaolo/psu...
191
steam for linux symbol lookup error: /usr/lib/i386-linux-gnu/libxcb-dri3.so.0: undefined symbol: xcb_send_request_with_fds
Hello @milankragujevic this issue is already being tracked at #4816 Your system information Steam cl...
176
atom MacOS Mojave: The text in the editor is dimmed / hard to read.
Hey folks could you try running this command and then restart Atom: Hat tip to @alexanderyakusik in ...
155
node Error: Cannot find module 'internal/fs' when npm install on mac
If you run rm -rf /usr/local/lib/node_modules/npm and then re-install Node.js does it work? ...
147
node Missing stack traces from async functions after the first await
Thanks! And to put a point on the real problem Version: v7.7.3 Platform: Windows 7x64 The purpose of...
142
atom Add config option for MRU tabs
So a temporary fix for this issue is to insert this into the keymap correct? Prerequisites Can you r...
139
ddev In WSL2 ddev start fails at docker-credential-desktop.exe, "error listing credentials"
I had to set credsStore: in my ~/.docker/config.json .. it was previously set to credentials.exe ...
129
node Fatal error in ../deps/v8/src/api.cc, line 1051
i got it fixed Ran following commands Thanks node version 7.3.0 (even tried with 7.4.0 ...
116
dash to dock Dash to dock shows on lockscreen
Ok resolved the issue by removing default ubuntu-dock@ubuntu.com: The dash to dock isnt disabled whe...
110
cncjs npm v5.0.3 installation integrity checksum failure
@pluggee @nomykk Have you tried npm install --update-binary --no-shrinkwrap? I had luck with that co...
109
node "ReferenceError: v8debug is not defined" when doing remote debug
bnoordhuis is right just add --expose_debug_as=v8debug to the Node parameters text field until JetBr...
108
atom "Multi Cursor on Click" seems to always be disabled in Atom 1.48.0
@HugoMcPhee posted and deleted a comment linking to #20804 which does indeed seem to offer a fix for...
104
nodegit Can't install via NPM
Latest Xcode just straight up broke things all across the world Try running sudo xcode-select --inst...
100
steam for linux Steam fails to start on new account because of outdated libxcb
LD_PRELOAD='/usr/$LIB/libstdc++.so.6 /usr/$LIB/libgcc_s.so.1 /usr/$LIB/libxcb.so.1 /usr/$LIB/libgpg-...
100
termux packages npm install: Unhandled rejection Error: EACCES: permission denied
Give ownership to npm like this: uname -a: Linux localhost 3.18.14-11422779 #1 SMP PREEMPT Thu Jun 1...
96
electron builder Can not build the windows installer on macOS Catalina version 10.15
electron-builder 22.2.0 now includes a targeted workaround extracting the NSIS uninstaller without t...
96
node HTTP/HTTPS client requests throwing EPROTO
It sounds like you are trying to use port 80 for https? Reproduced via: My code is littered with bot...
91
electron builder Built application displays nothing but a white screen
If any of you guys use React Router one of the thing that might break your Electron build is Browser...
86
alacritty Tmux austostart?
It should be like this: Which operating system does the issue occur on? MacOS Catalina I understood ...
84
node Debugging v8.5 - always pauses in async_hooks.js on promise rejection
This also reproes in Node 8.6 Is anyone looking into this? Seems to be affecting quite a few people ...
83
atom Uncaught Error: Setting active pane that is not present in pane container
Alright so as an update [Enter steps to reproduce:] @ungb's repro steps from below: Open Atom with a...
83
atom Font Rendering issue with freetype 2.8.1
Workaround: Prerequisites [X ] Put an X between the brackets on this line Description The fonts are ...
80
node Can’t import fs Promises API with ECMAScript Modules
I may be missing something but: isn't good enough? Version: v10.2.1 Platform: Windows 10 64-bit Subs...
79
toggldesktop Linux: Ubuntu 16.04 installs GStreamer 1.0 series, not 0.10 series, by default
And a quick workaround tested on my machine with Ubuntu 16.10: In Ubuntu 16.04 (xenial) the core des...
78
alacritty Support for Alt+key (option as meta)
With latest alacritty and tmux I finally got forward and backward movement with the following: ...
78
node Chrome DevTools not able to connect to Node inspect since 7.5.0
I suspect #9691 is responsible Version: 7.5.0 ...
76
termux app 403 forbidden while update or pkg Install
If someone facing the issue when you run pkg install ... Issue : when ever I try to update / upgrade...
75
gitsome Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-7SrToZ/gitsome/
I had the same problem on OSX and Solve my issue (I have both python versions installed). ...
71
polybar Dropping Unmatched Character
OK after quite a while fighting with this I've managed to get rid of the warnings On my (Arch) box s...
68
atom Unable to installing atom-amd64.deb on Ubuntu 17.04
I had the same issue when installing on 17.04 Prerequisites Put an X between the brackets on this li...
67
node setInterval callback function unexpected halt
@apapirovski @benjamingr @Fishrock123 I was just able to reproduce this with a smaller example 😁 I ...
65
node crypto, bad decrypt
Ok so the problem is in padding This is actually a common issue when users are encrypting in one lan...
65
wslu Cannot create directory "//.cache": Permission denied
Hello Here an improved version Background Information: Build: 17763 WSL: Ubuntu 18.04.03 Version: ws...
64
atom [1.19.0] [macOS] Atom CLI doesn't open native tabs
@dannyradden open file /Applications/Atom.app/Contents/Resources/app/src/main-process/atom-window.js...
64
bento Timeout error during vagrant up
I had these same issues with migrating to bento/ubuntu-16.04 version 2.30 (2.29 worked for me) I am ...
63
steam for linux Steam crashes at launch (since last update or the one before) on Kubuntu 19.04
Any progress? Cuda is essential to many So until a fix steam is unusable forever to us Tired of tryi...
63
peek convert fails due to resource limits
I think I've found the issue or at least a workaround Hi I'm on Debian with version below ...
59
electron builder Error: Application entry file "build/electron.js" in the "<path>/dist/mac/<app-name>/Contents/Resources/app.asar" does not exist.
Somehow setting files work Version: 19.49.0 Target: mac I'm using create-react-app and also followed...
57
electron builder dev-app-update.yml not found
Maybe this will help someone for solving this issue For me it worked creating the dev-app-update.yml...