How long does it take to build the entire shader cache?

wine/proton

Just switched all my games over to Linux for the first time, I've always since dual booted or used GPU passthrough.

On my RX 480 my performance tends to be slightly worse, the averages stay around the same but it's much more stuttery. I haven't played a lot of the games I've tested, though, since I already completed them before on Windows and I've just been tinkering.

My understanding is that in Proton with Vulkan, shaders get compiled on demand instead of all at once. Is it normal to have to play for a few hours to get all the shaders cached? Do games under Proton with Vulkan get less-stuttery the more you play them? What can I do to help it? I haven't had a shader cache download come from Steam since I joined the beta.

Posted Oct 2, 2021, 4:51 PM UTC

1520
Dave_Andreas•

specs , OS, cpu, gpu,gpu driver , ram ,ssd ,swap file size , game settings / options ?

5
needlessoptionsOP•

Pop OS 21.04

Ryzen 5 3600

2x8 3600Mhz DDR4

RX 480 8GB

Mesa 21.2.1 iirc, whichever Pop OS has on latest update

SSD is a Crucial MX500 or TX500 or something, it has DRAM cache, 1TB

Swap no but I've never seen memory usage go higher than like 12 gigs

Settings I tweak for each game, I aim for 1080p60

3
looncraz•

You always want a swapfile. You can just use a flat file (dd to create a zeroed file, mkswap to format the file, swapon to do something) instead of a partition.

Swap allows the system to behave much better when something is going wrong and leaking memory.

8
needlessoptionsOP•

Ok I'll do this. Thanks for the tip 😃

2
gripped•

And control its usage.
https://www.howtoforge.com/tutorial/linux-swappiness/
Low swappiness = only used when absolutely necessary. Which is hopefully never.

5
GabMus•

Here is a quick guide I made for creating a swapfile, hope it's useful.

2
gardotd426•

My understanding is that in Proton with Vulkan, shaders get compiled on demand instead of all at once.

Steam precaches shaders for all games now, and has for a while. You shouldn't be seeing this issue.

4
kono_throwaway_da•

Yes, the games tend to be less stuttery the longer you play. This is the case on most platforms except the consoles.

The time needed to build the entire shader cache depends on the game, some games are really pathetic in this regard - taking an hour or even more due to the sheer amount of shader variants they have. However, my experiences have shown that once you have gone through the first scene/level in the game (basically 10~30mins for the games I play), the stutters go away entirely, or at least they are too minuscule for someone to notice.

One way to not endure the laggy cache building period is to start the game, leave it in the main menu (or alt-tab out in the first level if the main menu is simple and static) for a few minutes before you start playing.

3
[deleted]•

My understanding is that in Proton with Vulkan, shaders get compiled on demand instead of all at once.

Steam ships game shaders so you don't ever get any stuttering. You have to wait for them to compile prior to launching the game. It shows you a popping telling you it's compiling them, and then when you launch the game there should not be any shader stutters at all because they're all done compiling ahead of time.

Shader stuttering is an issue when you're playing a game you don't own on Steam because anything not on Steam doesn't ship with recompiled shaders. So any Bnet or Origin games will have this issue.

The single caveat to my post is that I don't know if every single game on steam ships with precompiled shaders for Proton. It's possible it's not all of them. Someone else would have to comment on that.

3
emkoemko•

can't we share the caches?

2
needlessoptionsOP•

I think that, unless they're sharing open source shaders or something, they're unique. But I'm not a 3D graphics programmer so might be wrong

1
emkoemko•

yea unique to a game can't we just share the shader cache someone built, emulators do this all the time.

1
DarkeoX•

Steam already does that in part for Vulkan applications using a Vulkan layer to capture game shaders and "replay" them locally to build a locally compiled version of them.

The reason why it's tricky to share the pre-compiled shaders themselves is because they depends on driver version + hardware + game version.

The first two parts are figured out at least for Mesa FLOSS driver since compiled shaders are stored under a "driver_id/gpu_id" structure.

The problem is that matching a gamed version with that could be tricky (although that problem is half solved by having a dedicated cache dir for each game/version). I guess this hasn't been applied because small intricacies actually make the implementation more buggy & unreliable than it is...

1
emkoemko•

what you do is capture the things making the shaders i don't know the technical but emulatros do this so the shaders don't depend on hardware or drivers.

is this possible to do with games ?

Vulkan: Added a permanent cache for Vulkan pipelines
Unlike the Vulkan-native cache that Cemu used before, this cache does never reset Additionally the new cache is independent of hardware and drivers and can therefore be transferred between different PCs
Technical info:
Pipeline caching works by capturing the state of the Wii U's GPU at the time of pipeline creation
During the pipeline loading screen Cemu can then play back those captured states to recreate the pipelines

1
Primont91•

Use proton-ge with DXVK_ASYNC=1 %command%

Beware of multiplayer tho

1
needlessoptionsOP•

Will try this. Are some games unsupported?I'm gonna try installing TKG or Zen kernel again as well to use fsync, first time it broke my boot lmao.

1
spiffeeroo•

Objects will be invisible until the shader is compiled. This may trigger anticheat detection in multiplayer games. The developer of dxvk got banned from Overwatch when testing async shader compilation.

2
needlessoptionsOP•

I see, will keep this in mind. Thanks.

1
N0t_Just1n•

Overwatch bans for async were reversed and many have been running fine with it.

2
N0t_Just1n•

You can check to see if shaders are being cached in the background by going to steam settings and then shader caches.

My caches used to mess up all the time until the latest steam beta and now they’re flawless so maybe try that.

1