adaptive sync

This commit is contained in:
nnduc
2026-10-19 23:21:54 +07:00
parent 9b8320cead
commit 96467a1c56
15 changed files with 169 additions and 848 deletions
+46 -3
View File
@@ -75,8 +75,51 @@ echo 3 | sudo tee /sys/class/drm/card*/device/pp_dpm_mclk
with `adaptive_sync off` games run without it.
- To turn off FreeSync for a single game (Xorg): `adaptive_sync=false %command%`
(Steam launch options).
- Login greeters (SDDM, LightDM, ...) are fullscreen and mostly static, so VRR
drops to the bottom of the range and flickers. `mesa/drirc` disables it for
any `*greeter*` executable; install system-wide (greeters don't read `~/.drirc`):
```bash
sudo cp xorg/20-amdgpu.conf /etc/X11/xorg.conf.d/
sudo cp mesa/drirc /etc/drirc
```
![stones](./screenshots/Screenshot_20240503_095414.png)
## Shader cache (Steam)
With Steam's *Shader Pre-caching* off (it re-downloads caches for every game
almost daily), Steam points Mesa at a temporary
`~/.local/share/Steam/shader_cache_temp_dir_*` and deletes it when the game
exits, so every session recompiles shaders (hitches everywhere, every time).
Steam only sets the legacy `MESA_GLSL_CACHE_DIR`, so the newer variable wins.
Set it session-wide (i3 is started by SDDM, `environment.d` doesn't reach
Steam). The cache lives in `/var/cache` so `~/.cache` cleaners don't wipe it,
with one private subdir per user: Mesa creates its dirs `0700`, so a single
shared dir can't work (and would let users poison each other's shaders).
`/etc/environment` can't expand `$USER`, so use `/etc/profile.d` (SDDM's
X11/Wayland sessions and TTY logins source it). Run as your normal user, not
from a root shell (`~` and `$USER` must be yours), with Steam closed:
```bash
sudo mkdir -p /var/cache/mesa_shader_cache
sudo chmod 1777 /var/cache/mesa_shader_cache # like /tmp: anyone creates own subdir
mv ~/.cache/mesa_shader_cache /var/cache/mesa_shader_cache/$USER # no sudo: keeps ownership
sudo sed -i '/^MESA_SHADER_CACHE_/d' /etc/environment
sudo tee /etc/profile.d/mesa-shader-cache.sh >/dev/null <<'EOF'
export MESA_SHADER_CACHE_DIR="/var/cache/mesa_shader_cache/$USER"
export MESA_SHADER_CACHE_MAX_SIZE=10G
export PRESSURE_VESSEL_FILESYSTEMS_RW=/var/cache/mesa_shader_cache
EOF
```
The last line matters: Steam runs games (native and Proton) in the Steam
Linux Runtime container, which shares `$HOME` but gives the game its own empty
`/var`. Without it the cache is written to a tmpfs inside the container and
thrown away when the game exits.
Re-login, then check it's yours and persists after playing (should print > 0):
```bash
echo $MESA_SHADER_CACHE_DIR; ls -ld $MESA_SHADER_CACHE_DIR # owner must be you
find $MESA_SHADER_CACHE_DIR -mmin -60 -type f | wc -l
```
Deleting the cache is harmless: shaders just recompile (stutter) on first use.
## Installing dependencies
Package availability differs between distros — Arch has everything below in the
@@ -191,9 +234,9 @@ sudo emerge --ask games-util/gamemode
Adaptive sync (sway): the desktop runs at a fixed 240 Hz with VRR off, because
sway only renders on change and idle frame rates fall below the panel's 48 Hz
floor (out of LFC range → flicker). `sway/scripts/vrr-follow` turns VRR on for
DP-1 only while the visible workspace has a fullscreen window; `lock-now` turns
it off while locked. Needs `jq`.
floor (out of LFC range → flicker). gamemode turns VRR on for DP-1 while a
game runs and off when it exits (install `gamemode/gamemode.ini` to
`~/.config/gamemode.ini`); `lock-now` turns it off while locked.
### GPU monitoring & tuning