sonic2kk / steamtinkerlaunch

Linux wrapper tool for use with the Steam client for custom launch options and 3rd party programs
GNU General Public License v3.0
2.12k stars 71 forks source link

{Question/Possible Enhancement} Steam Shader Cache #785

Closed Nano-Ocelot closed 1 year ago

Nano-Ocelot commented 1 year ago

How does Steam handle the shader cache that is served to the user when the user chooses STL as the compat tool? Does Steam just not give the user shader cache files? Or is Steam 'intelligent' enough to discern what proton version you've set in STL and it will serve you the appropriate cache?

If it just never sends the user precompiled shaders for their system this could be a pretty big negative aspect of using STL since it's a pretty big benefit to go into a game with a lot of or most of your shaders already compiled and sent to you by Steam servers, meaning performance and stutters will be worse without them. If this is the case, could there be some kind of workaround implemented with STL to 'tell' Steam which proton version we're using?

sonic2kk commented 1 year ago

I'm not overly sure what you mean, sorry.

I don't think SteamTinkerLaunch interferes with shaders in any way. If you're using the Windows build of a game, Steam should download the shaders if they are available. If not, it will compile them on your system and re-compile them if needed based on driver updates. I don't think the Proton version has anything to do with it to my knowledge?

When you're downloading a game, if a shader cache is available, Steam will download it. It will also update it based on whether or not a shader cache update is available. When downloading Steam will also tell you if it's downloading the game content or shader pre-caching content. The compatibility tool in use shouldn't interfere with this in any way, aside from downloading any available shader content if you're forcing a native Linux game to run with a compatibility tool.

When I was downloading Mass Effect Legendary Edition yesterday, SteamTinkerLaunch was still selected as the compatibility tool, and it still downloaded the shader cache for that game when downloading. I have used A Hat in Time on my Steam Deck before, and it had to compile shaders before launching, and it did this with and without SteamTinkerLaunch.

So I guess to answer:

Or is Steam 'intelligent' enough to discern what proton version you've set in STL and it will serve you the appropriate cache?

Proton version should not impact which shader cache you are served, as it should download the shader cache (if available) based on whether or not you're using a Windows build. Steam doesn't know which Proton version is selected with SteamTinkerLaunch, as SteamTinkerLaunch wraps the entire start command. STL builds the start command that Steam would use manually, and then runs that.

Nano-Ocelot commented 1 year ago

Ok so Steam did send you shaders to be downloaded? That was essentially my question.

My understanding is that these shader caches are built and distributed from similar setups as your computer from other users. So hardware, drivers, and I believe proton version (because dxvk and vkd3d versions can change between proton versions) are taken into account for what is sent to the user.

Essentially my worry was that the proton version is important to what Steam sends the user and Steam ultimately wouldn't know which shader files were relevant to the users setup. I could be wrong on this though, but isn't your version of Proton (because dxvk and vkd3d changes) important for what shaders the game will need? Doesn't a change in Proton version sometimes cause a game to need to recompile/download new shaders?

sonic2kk commented 1 year ago

Ok so Steam did send you shaders to be downloaded? That was essentially my question.

Yes, as far as I am aware it has always done this since the introduction of shader pre-caching. I tested removing STL and changing Proton versions for some games, and the games didn't need to re-download any shader caching stuff.

My understanding is that these shader caches are built and distributed from similar setups as your computer from other users. So hardware, drivers, and I believe proton version (because dxvk and vkd3d versions can change between proton versions) are taken into account for what is sent to the user.

This is mostly my understanding as well, though I don't believe DXVK/vkd3d-proton would come into play here. Users can change the version of DXVK/vkd3d-proton that they use for a game. Switching from Proton 7.0-6 to Proton Experimental or GE-Proton (which should use newer versions of DXVK/vkd3d-proton) hasn't, to my knowledge, ever prompted a change in shader caching. I don't think vkd3d-proton uses shader caches though, at least not in the same way that DXVK does, and afaik DXVK relies on getting the shader cache from Steam.

You can also drop-in your own shader caches for Non-Steam games, people did this before for Overwatch. To my understanding, the version of DXVK used didn't come into play when users where doing this. Before this, there was also a script that came with the Lutris installer for Overwatch to generate shaders. I am not totally sure how it worked, but I don't recall the DXVK version coming into question, aside from a minimum version required to run the game in general.

I believe Steam generates shaders on your system when required using Fossilize. These shaders are then stored in the relevant Steam library folder for a game (i.e. ~/.local/share/Steam/steamapps/shadercache/<appid>).

I think the only factor here for what shader cache is downloaded/generated is the driver version and hardware (i.e. for available Vulkan extensions and so on). Shader cache generation is exclusively handled by the graphics drivers (i.e. RADV on AMD). For example, here is one of many Mesa RADV MRs related to Vulkan shader generation.

I could be wrong on this though, but isn't your version of Proton (because dxvk and vkd3d changes) important for what shaders the game will need? Doesn't a change in Proton version sometimes cause a game to need to recompile/download new shaders?

I have never seen a case where a change in Proton version caused shader caches to be recompiled/downloaded, only changes in driver versions (in my case Mesa, as I only use AMD/Intel hardware).


I should also mention that, at worst, if this was the case, a user would need to run their game once with a given Proton version to get it to download the relevant shader cache, and then run their game with STL (which they already have to do if they need a specific Steam Linux Runtime and don't know which one a given Proton version requires). However I do not believe compatibility tools interfere which which shader cache is downloaded, outside of a case where a compatibility tool is forced on a native Linux game to run the Windows build. In this case, the compatibility tool would force Steam to download the Windows build and any associated available shader cache, and the specific compatibility tool version wouldn't come into question - as far as I know anyway.

I have not come across an instance where SteamTinkerLaunch has caused degraded performance/stuttering from shader caches not being downloaded/generated properly. Games also download with their relevant shader caches when STL is selected in my experience, and get shader pre-caching updates regardless of which compatibility tool is used.


EDIT: Posting this after the issue was closed, but just wanted to grab a screenshot. Here is a game "Cut the Rope" which had 16mb of shader cache content to download. Before downloading, I selected SteamTinkerLaunch as the compatibility tool, and then downloaded the game. The shader content was downloaded with the game.

image

Nano-Ocelot commented 1 year ago

I see. I misunderstood that the proton version changed what shaders are needed by a game. I guess it's all good then 👍