upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAslan2142 <jan.trencansky@protonmail.com>2026-12-01 12:30:40 +0100
committerGitHub <noreply@github.com>2026-12-01 12:30:40 +0100
commit4913ef152e5db8d4fce1404a70270d8ad09e5fe5 (patch)
tree9592b49a224809908ca39f739bf16ba3c95edbf9 /scripts
parentd9df071e91b6d122e0aa76ee3398a2987f6e2ba1 (diff)
parent22d58b8629ef0b3ca674b08db21a23866dbfa893 (diff)
Merge pull request #2436 from kawaii-shakal/wine-run-shader-cache
run_game_wine.sh: keep the drivers' shader cache from run to run (WINE-RUN-SHADER-CACHE)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/run_game_wine.sh24
1 files changed, 22 insertions, 2 deletions
diff --git a/scripts/run_game_wine.sh b/scripts/run_game_wine.sh
index cc60d6767..96daae6d0 100755
--- a/scripts/run_game_wine.sh
+++ b/scripts/run_game_wine.sh
@@ -34,6 +34,10 @@ Options:
34 --device VID:DID the Vulkan device, as MESA_VK_DEVICE_SELECT=VID:DID! (e.g. 1002:744c); without it Mesa picks 34 --device VID:DID the Vulkan device, as MESA_VK_DEVICE_SELECT=VID:DID! (e.g. 1002:744c); without it Mesa picks
35 --screenshot-every S capture the game window into <out>/shots every S seconds (needs ImageMagick's import and 35 --screenshot-every S capture the game window into <out>/shots every S seconds (needs ImageMagick's import and
36 xprop); the shots are game content and stay local 36 xprop); the shots are game content and stay local
37 --cache DIR|fresh XDG_CACHE_HOME of the run, where the drivers keep their shader caches (NVIDIA's GLCache,
38 Mesa's shader cache): DIR is kept from run to run, fresh is a new one in the run folder
39 (default: the caller's XDG_CACHE_HOME when it is set, otherwise fresh); fresh also
40 unsets MESA_SHADER_CACHE_DIR, MESA_GLSL_CACHE_DIR and __GL_SHADER_DISK_CACHE_PATH
37 --lock FILE the lock that allows one run at a time (default $XDG_RUNTIME_DIR/leonida-run-game-wine.lock, 41 --lock FILE the lock that allows one run at a time (default $XDG_RUNTIME_DIR/leonida-run-game-wine.lock,
38 or <out>/run.lock without XDG_RUNTIME_DIR) 42 or <out>/run.lock without XDG_RUNTIME_DIR)
39 -h, --help this text 43 -h, --help this text
@@ -108,7 +112,7 @@ if [ "${1:-}" = --inner ]; then
108fi 112fi
109 113
110# ---- arguments ---- 114# ---- arguments ----
111SRC= BUILD_DIR= OUT= PREFIX=${WINEPREFIX:-} LIMIT=600 VISIBLE=0 DEVICE= SHOT_EVERY=0 LOCK= 115SRC= BUILD_DIR= OUT= PREFIX=${WINEPREFIX:-} LIMIT=600 VISIBLE=0 DEVICE= SHOT_EVERY=0 LOCK= CACHE=${XDG_CACHE_HOME:-fresh}
112EXE=${LEONIDA_GAME_EXE:-} GAME=${LEONIDA_GAME_DIR:-} SHADERS=${LEONIDA_SHADERS:-} 116EXE=${LEONIDA_GAME_EXE:-} GAME=${LEONIDA_GAME_DIR:-} SHADERS=${LEONIDA_SHADERS:-}
113need() { [ $# -ge 2 ] && [ -n "$2" ] || die "$1 needs a value (see --help)"; } 117need() { [ $# -ge 2 ] && [ -n "$2" ] || die "$1 needs a value (see --help)"; }
114while [ $# -gt 0 ]; do 118while [ $# -gt 0 ]; do
@@ -126,6 +130,7 @@ while [ $# -gt 0 ]; do
126 --device) need "$@"; DEVICE=$2; shift 2 ;; 130 --device) need "$@"; DEVICE=$2; shift 2 ;;
127 --screenshot-every) need "$@"; SHOT_EVERY=$2; shift 2 ;; 131 --screenshot-every) need "$@"; SHOT_EVERY=$2; shift 2 ;;
128 --lock) need "$@"; LOCK=$2; shift 2 ;; 132 --lock) need "$@"; LOCK=$2; shift 2 ;;
133 --cache) need "$@"; CACHE=$2; shift 2 ;;
129 --) shift; break ;; 134 --) shift; break ;;
130 *) die "unknown argument: $1 (see --help)" ;; 135 *) die "unknown argument: $1 (see --help)" ;;
131 esac 136 esac
@@ -144,6 +149,10 @@ fi
144[ -e "$SRC" ] || die "no build path at $SRC" 149[ -e "$SRC" ] || die "no build path at $SRC"
145[ -f "$EXE" ] || die "no game executable at $EXE" 150[ -f "$EXE" ] || die "no game executable at $EXE"
146[ -d "$GAME" ] || die "no package folder at $GAME" 151[ -d "$GAME" ] || die "no package folder at $GAME"
152if [ "$CACHE" != fresh ]; then
153 mkdir -p "$CACHE" || die "cannot create the cache folder $CACHE"
154 CACHE=$(readlink -f "$CACHE")
155fi
147if [ "$SHADERS" != none ]; then 156if [ "$SHADERS" != none ]; then
148 SHADERS=${SHADERS#Z:} 157 SHADERS=${SHADERS#Z:}
149 [ -d "$SHADERS" ] || die "no shader library at $SHADERS" 158 [ -d "$SHADERS" ] || die "no shader library at $SHADERS"
@@ -212,9 +221,20 @@ unset LEONIDA_GAME_EXE LEONIDA_GAME_DIR # launcher inputs; LEONIDA_GAME_DIR als
212export WINE 221export WINE
213export XDG_RUNTIME_DIR=$RUN/xdg 222export XDG_RUNTIME_DIR=$RUN/xdg
214rm -rf "$XDG_RUNTIME_DIR"; mkdir -p -m 700 "$XDG_RUNTIME_DIR" 223rm -rf "$XDG_RUNTIME_DIR"; mkdir -p -m 700 "$XDG_RUNTIME_DIR"
215export XDG_CONFIG_HOME=$RUN/session/config XDG_DATA_HOME=$RUN/session/data XDG_CACHE_HOME=$RUN/session/cache \ 224# The cache folder alone may outlive the run: a fresh one makes every launch compile its pipelines again in the driver.
225# A driver's own cache variable wins over XDG_CACHE_HOME, so a fresh run drops them, and an accepted run folder's old
226# session/cache goes too: fresh means empty. With a kept cache the caller's variables stay, and win.
227if [ "$CACHE" = fresh ]; then
228 XDG_CACHE_HOME=$RUN/session/cache
229 rm -rf "$XDG_CACHE_HOME"
230 unset MESA_SHADER_CACHE_DIR MESA_GLSL_CACHE_DIR __GL_SHADER_DISK_CACHE_PATH
231else
232 XDG_CACHE_HOME=$CACHE
233fi
234export XDG_CONFIG_HOME=$RUN/session/config XDG_DATA_HOME=$RUN/session/data XDG_CACHE_HOME \
216 XDG_STATE_HOME=$RUN/session/state 235 XDG_STATE_HOME=$RUN/session/state
217mkdir -p "$XDG_CONFIG_HOME" "$XDG_DATA_HOME" "$XDG_CACHE_HOME" "$XDG_STATE_HOME" 236mkdir -p "$XDG_CONFIG_HOME" "$XDG_DATA_HOME" "$XDG_CACHE_HOME" "$XDG_STATE_HOME"
237if [ "$CACHE" = fresh ]; then echo "shader cache: fresh"; else echo "shader cache: kept in $CACHE"; fi > "$RUN/session.txt"
218unset WAYLAND_DISPLAY WAYLAND_SOCKET DBUS_SESSION_BUS_ADDRESS 238unset WAYLAND_DISPLAY WAYLAND_SOCKET DBUS_SESSION_BUS_ADDRESS
219if [ "$VISIBLE" = 1 ]; then 239if [ "$VISIBLE" = 1 ]; then
220 if command -v xdpyinfo >/dev/null 2>&1 && ! xdpyinfo >/dev/null 2>&1; then 240 if command -v xdpyinfo >/dev/null 2>&1 && ! xdpyinfo >/dev/null 2>&1; then