From 72eb402cd480a59bfae4e7a78d25b9017ef42573 Mon Sep 17 00:00:00 2001 From: 3AvisD Date: Sun, 18 Oct 2026 11:53:00 -0600 Subject: [PATCH] fix(launcher): keep Mesa's shader cache on the host Mesa derives its shader disk cache from $HOME. Inside the guest that is /Users/, which does not exist on the host filesystem, so Mesa could not create the cache and disabled it, once per process: Failed to create /Users/ for shader cache (Permission denied)---disabling One launcher log contained 212 of those lines, and no shader compiled by one process was reused by another process or by the next start: the client and the game recompiled every shader on every launch, spending CPU at startup for no gain. Mesa is host code loaded into the guest and reads MESA_SHADER_CACHE_DIR verbatim, so point it at a host directory; Mesa creates mesa_shader_cache/ (client and game shaders) and radv_builtin_shaders/ below it. A non-empty value from the caller is preserved, and a directory that cannot be created leaves the previous behaviour instead of ending the launch. Observed on a Radeon RX 550 with radv: no shader-cache failure after the change, and 434 files / 5.6 MB written during one client start, still growing while the client ran. The cache is reused from the second start on, which lowers the client's CPU use while it starts; the startup-time gain itself has not been measured separately. --- docs/TROUBLESHOOTING.md | 28 ++++++++++++++++++++++++++++ tools/run-riot-client.sh | 10 ++++++++++ 2 files changed, 38 insertions(+) diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md index a6da2e1..5057461 100644 --- a/docs/TROUBLESHOOTING.md +++ b/docs/TROUBLESHOOTING.md @@ -57,6 +57,34 @@ The old kernel library returned success for Darwin allocator free/reuse hints wi Build/install the kernel library using [the incremental update steps](SETUP.md#updating-an-existing-runtime), then perform the manual restart when finished playing. Linux 5.14+ is required. Do not kill client helpers as an attempted memory optimization during play. +## Shaders are recompiled on every start + +Mesa resolves its shader disk cache below `$HOME`. Inside the guest, `$HOME` is +`/Users/`, which does not exist on the host filesystem, so Mesa cannot create the +cache and disables it, once per process: + +``` +Failed to create /Users/ for shader cache (Permission denied)---disabling +``` + +One launcher log without the fix contained 212 of these lines, and no shader compiled by +one process was reused by another process or by the next start: the client and the game +recompiled every shader, on every launch. Mesa is host code loaded into the guest and +reads `MESA_SHADER_CACHE_DIR` verbatim, so the launcher now passes a host directory: + +```sh +MESA_SHADER_CACHE_DIR=${XDG_CACHE_HOME:-${HOME:-$prefix_dir}/.cache}/darling-lol # launcher default +``` + +Mesa creates `mesa_shader_cache/` (client and game shaders) and `radv_builtin_shaders/` +below it. With the change, one client start logged no shader-cache failure and wrote 434 +files / 5.6 MB, still growing while the client ran (Radeon RX 550, radv). Set +`MESA_SHADER_CACHE_DIR` yourself to move the cache, for example to another disk: the +launcher preserves a non-empty value, and a directory that cannot be created leaves the +previous behaviour. Reusing the cache removes the repeated compilation; the startup-time +gain has not been measured separately. Cache entries are keyed by driver and GPU, so a +driver update recompiles once and caches again. + ## Installer exits, cannot write temporary files, or Install appears idle Use `sh scripts/installer.sh euw` (or your supported region). The first-time launcher must omit the installed client's `--app-root` and pass `--skip-to-install`; the normal wrapper now does this. It also selects `league_of_legends` so the product installation UI appears after login. diff --git a/tools/run-riot-client.sh b/tools/run-riot-client.sh index 5fa75a5..f3213dc 100755 --- a/tools/run-riot-client.sh +++ b/tools/run-riot-client.sh @@ -92,6 +92,16 @@ fi if [ -n "${RCLOL_REFRESH_HZ-}" ]; then export RCLOL_REFRESH_HZ; fi # Vulkan WSI & Mesa optimizations export MESA_NO_ERROR="${MESA_NO_ERROR:-1}" +# Mesa resolves its shader disk cache below $HOME, which inside the guest is +# /Users/: that path does not exist on the host filesystem, so every process logs +# "Failed to create /Users for shader cache (Permission denied)---disabling" and +# recompiles every shader on start (212 such lines in one launcher log). The host Mesa +# loaded into the guest reads MESA_SHADER_CACHE_DIR verbatim, so point it at a host +# directory; Mesa creates mesa_shader_cache/ and radv_builtin_shaders/ below it. +cache_root=${XDG_CACHE_HOME:-${HOME:-$prefix_dir}/.cache}/darling-lol +MESA_SHADER_CACHE_DIR="${MESA_SHADER_CACHE_DIR:=$cache_root}" +export MESA_SHADER_CACHE_DIR +mkdir -p "$MESA_SHADER_CACHE_DIR" 2>/dev/null || true # NVIDIA proprietary driver: limit pre-rendered frames. export __GL_MaxFramesAllowed="${__GL_MaxFramesAllowed:-1}" # Threaded optimizations stay off: with them, NVIDIA 580 (the last branch for