ValveSoftware / steam-for-linux

Issue tracking for the Steam for Linux beta client
4.21k stars 174 forks source link

Steam always reprocesses shader precache at game launch #9748

Closed felipec closed 10 months ago

felipec commented 1 year ago

This is the same as #7306, which was apparently wrongly closed and locked.

I have noticed it happening in the past few weeks. I don't know if it was happening before.

Your system information

Please describe your issue in as much detail as possible:

Every time I launch Dota 2 it says "Processing Vulkan Shaders" and spends several minutes there. Not every time there's an update, every time I launch it.

Why does it need to do that every single time?

Steps for reproducing this issue:

  1. Launch Dota 2
kisak-valve commented 1 year ago

Hello @felipec, the general topic of shader pre-cache updates is being tracked at #8076, not #7306. Noted at https://github.com/ValveSoftware/steam-for-linux/issues/8076#issuecomment-1430641159, shader pre-cache updates are designed to be small incremental updates as shaders are seen in the wild.

The majority of the time, most of the shaders have already been seen by the video driver and stored in the video driver specific on-disk shader cache.

I took a look at this a bit and did not reproduce the issue locally with Steam running on an Intel GPU. I would expect when the Steam -> Settings -> Downloads -> Allow background processing of Vulkan shaders option is enabled, that would allow the Steam client to work ahead and not need to handle that at game start, and when that option is disabled, for it to run as needed.

Another NVIDIA user repeated the same basic conditions, and did reproduce the issue of processing shader on every game launch, which hints that this is a shader precache subcomponent + NVIDIA specific issue. Can you note what video driver version you're using?

apocalyptech commented 1 year ago

FWIW, I was the other NVIDIA user confirming the conditions. My details:

OpenGL renderer string: NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2 OpenGL core profile version string: 4.6.0 NVIDIA 535.54.03 OpenGL core profile shading language version string: 4.60 NVIDIA

shader log entries for the day: shader_log_2023_06_28.txt -- had let a Borderlands 2 shader compilation continue to completion, and then launched it again right away after quitting the game. (Second compilation process cancelled near its start.)

3331 commented 1 year ago

This issue appears to have been fixed for me with July 10th update, however some games such as CS:GO still appear to be recompiling a bunch of shader during launch, since I have to wait 3-4 minutes before the game is ready to play. This used to only happen once when nvidia drivers was updated/changed, but now it happens every time CS:GO is launched.

JU12000 commented 1 year ago

Can confirm this issue is also happening to me even on the July 10 update.

Steam client version: 1.0.0.78-2 (1689034492) Distribution: Manjaro Linux Opted into Steam client beta?: No Have you checked for system updates?: Yes OpenGL renderer string: NVIDIA GeForce GTX 1080/PCIe/SSE2 OpenGL core profile version string: 4.6.0 NVIDIA 535.54.03 OpenGL core profile shading language version string: 4.60 NVIDIA

Tried with multiple different games in immediate succession and each launch kicks off the Vulkan Shader processor even with Allow background processing of Vulkan shaders turned on.

JU12000 commented 1 year ago

Don't want to spam but some more (possibly) relevant info came up.

After rebooting Manjaro, Steam would no longer launch for me. A quick search and compare in journalctl told me the difference was: Could not connect to X session manager: Authentication Rejected, reason: None of the authentication protocols specified are supported and h

Searching for that lead me to this Steam Support page which informed me to run Steam with DISPLAY=:0 steam.

Fortunately this worked, at which point I turned off Allow background processing of Vulkan shaders and attempted to exit and start steam normally, which also worked.

I checked echo $DISPLAY before running the DISPLAY=:0 steam command and after launching Steam the second time, it was and still is set globally to :0.0.

I'm not sure how closely related the two are but thought it might help to share.

adamnejm commented 1 year ago

I experience the same thing.

System: OS: ArchLinux Kernel: 6.4.3-arch1-1 Nvidia: RTX 3070 on 535.54.03-8 Steam: 1.0.0.78-1 from official multilib repositories Steam build: 1689034492 (July 10th 2023 @ 23:59:09)

Related GPU variables:

export NVD_BACKEND="direct"                                                      # VA-API backend
export LIBVA_DRIVER_NAME="nvidia"                                                # VA-API driver
export PROTON_HIDE_NVIDIA_GPU=0                                                  # Report as Nvidia
export PROTON_ENABLE_NVAPI=1                                                     # Enable NVAPI library
export PROTON_ENABLE_NGX_UPDATER=1                                               # Enable OTA updates for Nvidia NGX
export VKD3D_CONFIG="dxr,dxr11"                                                  # Enable DXR and DXR 1.1
3331 commented 1 year ago

This issue appears to have been fixed for me with July 10th update, however some games such as CS:GO still appear to be recompiling a bunch of shader during launch, since I have to wait 3-4 minutes before the game is ready to play. This used to only happen once when nvidia drivers was updated/changed, but now it happens every time CS:GO is launched.

What I said here was incorrect, the issue reappears once I resume from suspended system or reboot the machine. (CSGO launch thing happens regardless of what has been done)

jaxwilko commented 1 year ago

Is there any update on this? I've been having the same issue for a while, every time I restart my machine and try and launch any game it starts Processing Vulkan shaders. Even if I let it run to completion, after the machine is restarted it will try and rebuild the shaders again.

System:

OS: Debian GNU/Linux trixie/sid x86_64 
Kernel: 6.4.0-2-amd64
DE: GNOME 43.6 
WM: Mutter 
CPU: Intel i9-9900K (16) @ 5.000GHz 
GPU: NVIDIA GeForce RTX 2080 Ti Rev. A 
kisak-valve commented 1 year ago

Hello @jaxwilko, what NVIDIA driver version are you using?

It looks like this specific issue was a video driver bug regarding how the driver handled its own on-disk shader cache. It's possible that the issue tracked here was introduced with 535.43.02 and quietly resolved in 535.86.05. I don't know off hand if other release series were affected.

adamnejm commented 1 year ago

Not the previous guy, but I face the same issue with nvidia package, ver. 535.98 from official Arch Linux repositories along with 6.4.10-arch1-1 kernel. Before the update, nvidia, ver. 535.86.05 was also affected by this bug.

jaxwilko commented 1 year ago

@kisak-valve thanks for replying, even on a sunday, absolute legend <3.

Sorry for not incluiding this in my initial comment, my current nvidia driver version is: 525.125.06.

I'm 99% sure I've had the same issue with the following versions, but cannot be 100% sure:

For Debian testing 525.125.06 is the latest available driver, see: https://packages.debian.org/testing/nvidia-driver

Is there anything else I can try or provide that would help?

adamnejm commented 1 year ago

@kisak-valve So sorry for the confusion and wasting your time, but turns out I was wrong earlier.

I just tested 4 games: Counter-Strike: Global Offensive, Left 4 Dead 2, Deep Rock Galactic and FTL: Faster Than Light using nvidia-535.98-2 and normal, non-beta Steam release, ver. 1690583737.
The shader cache seems to be working perfectly, even after restarting Steam or the whole PC.

I think the Need Retest label should be re-added so other people can confirm this.

felipec commented 1 year ago

Can you note what video driver version you're using?

I suppose in June 28 I was using nvidia 535.54.03.

Back then I was certainly experiencing some issue. At some point I don't know when the amount of times I saw the processing message was significantly reduced, to the point that I don't consider it an issue any more.

Now I'm using nvidia 535.98 and and steam 1690583737.

I just updated Dota 2, launched it, and didn't even show the processing message.

If memory serves I still see the message, but it's certainly not every time, it's only sometimes, and it doesn't take forever.

I'm pretty sure there was an issue, but whatever it was I don't think it's present anymore, at least on my system.

adamnejm commented 1 year ago

Since my last update, 3/4 games - CS:GO (twice), L4D2 (once), DRG (once), FTL (none) had popped up with the shader precaching, although in each case it didn't take very long (~30s avg on 5600X), so I assume it wasn't compiling them from scratch, that's good.

When it comes to DRG and L4D2 they had updates pushed during that time, however CS:GO didn't.
Assuming that shader precaching may be triggered by a game update, it could be theoretically possible that there was an internal build of CS2 Limited Test which caused shader precaching (my account participates in the CS2 beta), just a speculation though.

As @felipec stated, overall, the current state is acceptable.

AllDragonsAreDead commented 1 year ago

Adding __GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1 to ~/.profile solved the issue for me. Before, I had to spend an hour compiling shaders after every Dota restart. Now Dota starts quickly, as expected. Source: https://www.reddit.com/r/linux_gaming/comments/9gly07/nvidia_shadercache_use_this_env_variable_to_not/

Apparently, NVIDIA driver cleans/removes shaders specific to an app, when their size exceeds 128 MB. The solution mentioned above is one of the workarounds, but probably not the best one. Some people mention that game developers actually can fix that on their end, so users don't need to change driver's settings. Sadly, I can't find the link explaining that now.

TLATER commented 1 year ago

Apparently, NVIDIA driver cleans/removes shaders specific to an app, when their size exceeds 128 MB.

This is a lifesaver. Of course it's NVIDIA's fault, it always is. I don't think I'll ever buy another one of their devices. None of the driver versions reported here helped on my end.

I've set up that env variable for the games that were constantly rebuilding their shaders, and banished them to specific directories with __GL_SHADER_DISK_CACHE_PATH. No more rebuilds setting my CPU to 100% for 6+ hours, no more framerate stuttering whenever I enter uncached regions. Thank you so much.

I'm keeping precache disabled for now, but it will be interesting to see how this interacts with that when I get annoyed by updates causing stuttering. Presumably the precache process needs to know where to put the cached shaders, which I doubt works if the env variables aren't set globally.

Balssh commented 1 year ago

Thanks! __GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1 solved it for me.

g572staem commented 11 months ago

Steam -> Settings -> Downloads -> Allow background processing of Vulkan shaders

Jeepers, talk about illogical placement of an option.

kisak-valve commented 10 months ago

Closing as the issue tracked here was an NVIDIA sided disk cache regression around 535.54.03 which has been resolved somewhere around the NVIDIA 535.98 driver update.