fix(launcher): keep Mesa's shader cache on the host

Mesa derives its shader disk cache from $HOME. Inside the guest that is
/Users/<user>, 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/<user> 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.
This commit is contained in:
3AvisD committed 2026-10-18 12:18:33 -06:00
1 parent f400b86de1
commit 72eb402cd4
2 files changed
+38

No files matched your search

+28
View File
@@ -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/<user>`, which does not exist on the host filesystem, so Mesa cannot create the
cache and disables it, once per process:
```
Failed to create /Users/<user> 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.
+10
View File
@@ -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/<user>: 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