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:
authorBubsMcgee <alexbraden99@gmail.com>2026-11-25 14:12:01 -0500
committerBubsMcgee <alexbraden99@gmail.com>2026-11-25 14:12:01 -0500
commit4cfbdfc0b2e39e9137b7f40c48863f1e0e444adc (patch)
tree6c656db1c34d59b2b188fc4822badc0f351bffad /scripts
parenta5dd540bccc6ce20971a6680f076beedc13f2a95 (diff)
parent9f9a7c5f30f8559c52675780cf84004571b8d6e5 (diff)
Merge remote-tracking branch 'origin/main' into rt-xapu-opus-on-1144
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/run_game_wine.sh293
-rw-r--r--scripts/run_gpu_tests.py3
2 files changed, 295 insertions, 1 deletions
diff --git a/scripts/run_game_wine.sh b/scripts/run_game_wine.sh
new file mode 100755
index 000000000..ce01b0a07
--- /dev/null
+++ b/scripts/run_game_wine.sh
@@ -0,0 +1,293 @@
1#!/usr/bin/env bash
2# Run the retail game once under Wine on Linux: `gta6rt.exe --run <exe>` with the startup and D3D12 traces on, sound
3# off, a pinned Vulkan device, a hard time limit and full teardown, then print counts only
4# (tools/game_run_summary.py). Headless on a private kwin_wayland session by default, or on the current display with
5# --visible. `scripts/run_game_wine.sh --help` lists the inputs; docs/linux_proton.md has the requirements.
6#
7# The run folder's logs can quote what the title prints: they stay on this machine. Share the printed summary.
8set -u
9
10ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
11SELF=$ROOT/scripts/run_game_wine.sh
12
13usage() {
14 cat <<'EOF'
15Usage: scripts/run_game_wine.sh --build DIR --exe FILE --game-dir DIR --out DIR [options] [-- gta6rt arguments]
16
17Runs `gta6rt.exe --run <exe>` once under Wine, headless or on this display, with sound off, a pinned Vulkan device,
18a time limit and the startup and D3D12 traces on, then prints counts only. Every path comes from here or from the
19environment; nothing is assumed.
20
21Inputs:
22 --build DIR a build folder holding gta6rt.exe and gta6rt_tls_host.dll, or a checkout: its runtime/ is
23 cross-built with clang-cl and xwin (XWIN_DIR must be set) into --build-dir first
24 --build-dir DIR where a checkout is built (default <checkout>/runtime/build/wine-game-run)
25 --exe FILE the game executable (or LEONIDA_GAME_EXE)
26 --game-dir DIR the package folder; the working folder (or LEONIDA_GAME_DIR)
27 --shaders DIR the translated shader library (or LEONIDA_SHADERS; "none" leaves it unset)
28 --out DIR the run folder; it must not hold a run yet (logs, traces, saves, overlay, summary)
29 --prefix DIR the Wine prefix (or WINEPREFIX; default <out>/prefix)
30
31Options:
32 --seconds N hard time limit of the run (default 600; SIGTERM, then SIGKILL 10 s later)
33 --visible open the window on the current DISPLAY instead of a private headless session
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
36 xprop); the shots are game content and stay local
37 --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)
39 -h, --help this text
40 -- ARGS further gta6rt arguments, after the fixed ones
41
42Environment:
43 WINE the wine to use (default wine on PATH; for Proton, its files/bin/wine)
44 LEONIDA_* passed to the runtime unchanged (LEONIDA_INPUT_SCRIPT, LEONIDA_ARENA_MB, ...); the launcher
45 sets LEONIDA_AUDIO=silent, and LEONIDA_D3D12=vulkan, LEONIDA_RUMBLE=0 and LEONIDA_SAVE_DIR
46 unless they are set
47
48Headless needs kwin_wayland (with Xwayland) and dbus-run-session: Xvfb has no DRI3, so RADV cannot present there.
49Sound: Wine's audio drivers are disabled, PulseAudio, PipeWire and ALSA point at nothing, and the runtime serves its
50silent output endpoint (LEONIDA_AUDIO=silent).
51EOF
52}
53
54die() { echo "run_game_wine.sh: $*" >&2; exit 2; }
55
56if [ "${1:-}" = --inner ]; then
57 # ---- inside the session: DISPLAY is kwin's Xwayland (headless) or the caller's display (--visible) ----
58 RUN=$2; BUILD=$3; LIMIT=$4; SHOT_EVERY=$5
59 shift 5
60 WINE=${WINE:-wine}
61 WINESERVER=$(dirname "$(command -v "$WINE")")/wineserver
62 [ -x "$WINESERVER" ] || WINESERVER=wineserver
63 unset WAYLAND_DISPLAY # Wine's X11 driver on Xwayland, never its Wayland driver
64 {
65 echo "display: ${DISPLAY:-none}"
66 if command -v xdpyinfo >/dev/null 2>&1; then
67 echo "DRI3 extension: $(xdpyinfo 2>/dev/null | grep -c -w DRI3)"
68 fi
69 } >> "$RUN/session.txt"
70 mkdir -p "$WINEPREFIX"
71 "$WINESERVER" -p
72 # Warm-up: starts the prefix's services; no Mono/Gecko prompts in a new prefix.
73 WINEDLLOVERRIDES="$WINEDLLOVERRIDES;mscoree,mshtml=" "$WINE" wineboot -u </dev/null >/dev/null 2>&1
74 SHOTS=
75 if [ "$SHOT_EVERY" != 0 ]; then
76 mkdir -p "$RUN/shots"
77 (
78 n=0
79 while sleep "$SHOT_EVERY"; do
80 n=$((n + 1))
81 # Wine names the window's class after the executable: gta6rt.exe.
82 for id in $(xprop -root _NET_CLIENT_LIST 2>/dev/null | grep -o '0x[0-9a-f]*'); do
83 if xprop -id "$id" WM_CLASS 2>/dev/null | grep -qi 'gta6rt'; then
84 import -window "$id" "$RUN/shots/$(printf '%04d' "$n").png" 2>/dev/null
85 break
86 fi
87 done
88 done
89 ) &
90 SHOTS=$!
91 fi
92 cd "$GAME_DIR" || { echo 2 > "$RUN/exit_code"; exit 0; }
93 t0=$(date +%s)
94 timeout -k 10 "$LIMIT" "$WINE" "$BUILD/gta6rt.exe" --run "Z:$GAME_EXE" --game-dir "Z:$GAME_DIR" \
95 --overlay "Z:$RUN/overlay" --trace "Z:$RUN/boot.jsonl" --trace-d3d12 "$@" \
96 </dev/null > "$RUN/stdout.log" 2> "$RUN/stderr.log"
97 code=$?
98 echo "$(( $(date +%s) - t0 ))" > "$RUN/seconds"
99 echo "$code" > "$RUN/exit_code"
100 [ -n "$SHOTS" ] && kill "$SHOTS" 2>/dev/null
101 "$WINESERVER" -k 2>/dev/null
102 exit 0
103fi
104
105# ---- arguments ----
106SRC= BUILD_DIR= OUT= PREFIX=${WINEPREFIX:-} LIMIT=600 VISIBLE=0 DEVICE= SHOT_EVERY=0 LOCK=
107EXE=${LEONIDA_GAME_EXE:-} GAME=${LEONIDA_GAME_DIR:-} SHADERS=${LEONIDA_SHADERS:-}
108need() { [ $# -ge 2 ] && [ -n "$2" ] || die "$1 needs a value (see --help)"; }
109while [ $# -gt 0 ]; do
110 case $1 in
111 -h|--help) usage; exit 0 ;;
112 --build) need "$@"; SRC=$2; shift 2 ;;
113 --build-dir) need "$@"; BUILD_DIR=$2; shift 2 ;;
114 --exe) need "$@"; EXE=$2; shift 2 ;;
115 --game-dir) need "$@"; GAME=$2; shift 2 ;;
116 --shaders) need "$@"; SHADERS=$2; shift 2 ;;
117 --out) need "$@"; OUT=$2; shift 2 ;;
118 --prefix) need "$@"; PREFIX=$2; shift 2 ;;
119 --seconds) need "$@"; LIMIT=$2; shift 2 ;;
120 --visible) VISIBLE=1; shift ;;
121 --device) need "$@"; DEVICE=$2; shift 2 ;;
122 --screenshot-every) need "$@"; SHOT_EVERY=$2; shift 2 ;;
123 --lock) need "$@"; LOCK=$2; shift 2 ;;
124 --) shift; break ;;
125 *) die "unknown argument: $1 (see --help)" ;;
126 esac
127done
128
129[ -n "$SRC" ] || die "--build is required: a build folder with gta6rt.exe, or a checkout"
130[ -n "$EXE" ] || die "--exe (or LEONIDA_GAME_EXE) is required: the game executable"
131[ -n "$GAME" ] || die "--game-dir (or LEONIDA_GAME_DIR) is required: the package folder"
132[ -n "$OUT" ] || die "--out is required: the run folder"
133[ -n "$SHADERS" ] || die "--shaders (or LEONIDA_SHADERS) is required: the translated shader library, or none"
134case $LIMIT in ''|*[!0-9]*|0*) die "--seconds must be a whole number of seconds above 0, not '$LIMIT'" ;; esac
135case $SHOT_EVERY in ''|*[!0-9]*) die "--screenshot-every must be a whole number of seconds, not '$SHOT_EVERY'" ;; esac
136if [ -n "$DEVICE" ] && ! [[ $DEVICE =~ ^[0-9a-fA-F]{4}:[0-9a-fA-F]{4}$ ]]; then
137 die "--device takes VID:DID in hex, as lspci -nn prints it (e.g. 1002:744c), not '$DEVICE'"
138fi
139[ -f "$EXE" ] || die "no game executable at $EXE"
140[ -d "$GAME" ] || die "no package folder at $GAME"
141if [ "$SHADERS" != none ]; then
142 SHADERS=${SHADERS#Z:}
143 [ -d "$SHADERS" ] || die "no shader library at $SHADERS"
144fi
145EXE=$(readlink -f "$EXE"); GAME=$(readlink -f "$GAME"); SRC=$(readlink -f "$SRC")
146
147# ---- what the host needs ----
148WINE=${WINE:-wine}
149missing=()
150command -v "$WINE" >/dev/null 2>&1 || missing+=("$WINE (Wine)")
151for t in timeout flock setsid python3; do command -v $t >/dev/null 2>&1 || missing+=("$t"); done
152if [ "$VISIBLE" = 1 ]; then
153 [ -n "${DISPLAY:-}" ] || die "--visible needs DISPLAY: run it from the desktop session (an X11 or Xwayland display)"
154else
155 for t in kwin_wayland dbus-run-session Xwayland; do command -v $t >/dev/null 2>&1 || missing+=("$t"); done
156fi
157if [ "$SHOT_EVERY" != 0 ]; then
158 for t in import xprop; do command -v $t >/dev/null 2>&1 || missing+=("$t (for --screenshot-every)"); done
159fi
160if [ ${#missing[@]} -gt 0 ]; then
161 echo "run_game_wine.sh: missing: ${missing[*]}" >&2
162 [ "$VISIBLE" = 1 ] || echo " headless runs need kwin_wayland with Xwayland: Xvfb has no DRI3, so RADV cannot" \
163 "present there. Install KWin, or run on your display with --visible." >&2
164 exit 2
165fi
166
167# ---- the run folder ----
168mkdir -p "$OUT" || die "cannot create $OUT"
169OUT=$(readlink -f "$OUT")
170RUN=$OUT
171if [ -e "$RUN/boot.jsonl" ] || [ -e "$RUN/stderr.log" ]; then
172 die "$RUN already holds a run; name a new --out"
173fi
174
175# ---- the runtime: a build folder as is, or a checkout built here ----
176if [ -f "$SRC/gta6rt.exe" ]; then
177 BUILD=$SRC
178elif [ -f "$SRC/runtime/CMakeLists.txt" ]; then
179 [ -n "${XWIN_DIR:-}" ] || die "building $SRC needs XWIN_DIR (an xwin splat, docs/linux.md); or pass a build folder"
180 BUILD=$(readlink -f -m "${BUILD_DIR:-$SRC/runtime/build/wine-game-run}")
181 mkdir -p "$BUILD"
182 echo "building the runtime into $BUILD"
183 if [ ! -f "$BUILD/CMakeCache.txt" ]; then
184 cmake -S "$SRC/runtime" -B "$BUILD" --toolchain "$SRC/runtime/cmake/clang-cl-xwin.cmake" \
185 -DCMAKE_BUILD_TYPE=RelWithDebInfo > "$RUN/configure.log" 2>&1 \
186 || die "configure failed (see $RUN/configure.log)"
187 fi
188 cmake --build "$BUILD" --parallel --target gta6rt gta6rt_tls_host > "$RUN/build.log" 2>&1 \
189 || die "build failed (see $RUN/build.log)"
190else
191 die "$SRC is neither a build folder with gta6rt.exe nor a checkout with runtime/CMakeLists.txt"
192fi
193[ -f "$BUILD/gta6rt_tls_host.dll" ] || die "no gta6rt_tls_host.dll next to $BUILD/gta6rt.exe"
194
195# ---- one run at a time: a shared prefix has one wineserver ----
196LOCK=${LOCK:-${XDG_RUNTIME_DIR:+$XDG_RUNTIME_DIR/leonida-run-game-wine.lock}}
197LOCK=${LOCK:-$RUN/run.lock}
198exec 9>"$LOCK" || die "cannot open the lock $LOCK"
199flock -n 9 || die "another run holds $LOCK"
200mkdir -p "$RUN/overlay" "$RUN/saves"
201
202# ---- environment: private session, sound off, pinned device ----
203export GAME_EXE=$EXE GAME_DIR=$GAME
204unset LEONIDA_GAME_EXE LEONIDA_GAME_DIR # launcher inputs; LEONIDA_GAME_DIR also switches the runtime's tests
205export WINE
206export XDG_RUNTIME_DIR=$RUN/xdg
207rm -rf "$XDG_RUNTIME_DIR"; mkdir -p -m 700 "$XDG_RUNTIME_DIR"
208export XDG_CONFIG_HOME=$RUN/session/config XDG_DATA_HOME=$RUN/session/data XDG_CACHE_HOME=$RUN/session/cache \
209 XDG_STATE_HOME=$RUN/session/state
210mkdir -p "$XDG_CONFIG_HOME" "$XDG_DATA_HOME" "$XDG_CACHE_HOME" "$XDG_STATE_HOME"
211unset WAYLAND_DISPLAY WAYLAND_SOCKET DBUS_SESSION_BUS_ADDRESS
212if [ "$VISIBLE" = 1 ]; then
213 if command -v xdpyinfo >/dev/null 2>&1 && ! xdpyinfo >/dev/null 2>&1; then
214 die "--visible: cannot open display $DISPLAY (XAUTHORITY=${XAUTHORITY:-unset})"
215 fi
216else
217 unset DISPLAY XAUTHORITY
218fi
219export QT_QPA_PLATFORM=offscreen
220if [ -n "$DEVICE" ]; then
221 export MESA_VK_DEVICE_SELECT="$DEVICE!"
222 # kwin and Xwayland's glamor on the card that renders, so the present path stays on one device.
223 for n in /sys/class/drm/renderD*; do
224 [ "$(cat "$n/device/vendor" 2>/dev/null):$(cat "$n/device/device" 2>/dev/null)" = "0x${DEVICE%%:*}:0x${DEVICE#*:}" ] \
225 && export KWIN_DRM_DEVICES=/dev/dri/${n##*/}
226 done
227else
228 unset MESA_VK_DEVICE_SELECT
229 echo "warning: no --device: Mesa picks the Vulkan device (pass --device VID:DID to pin it)" >&2
230fi
231export WINEPREFIX=${PREFIX:-$RUN/prefix} WINEDEBUG=${WINEDEBUG:--all}
232export WINEDLLOVERRIDES="winedbg.exe=d;winemenubuilder.exe=d;winepulse.drv=d;winealsa.drv=d;wineoss.drv=d;winecoreaudio.drv=d"
233export PULSE_SERVER=unix:/nonexistent PIPEWIRE_REMOTE=/nonexistent ALSA_CONFIG_PATH=/dev/null SDL_AUDIODRIVER=dummy
234export LEONIDA_AUDIO=silent
235export LEONIDA_D3D12=${LEONIDA_D3D12:-vulkan}
236export LEONIDA_RUMBLE=${LEONIDA_RUMBLE:-0}
237export LEONIDA_SAVE_DIR=${LEONIDA_SAVE_DIR:-Z:$RUN/saves}
238if [ "$SHADERS" = none ]; then
239 unset LEONIDA_SHADERS
240else
241 export LEONIDA_SHADERS=Z:$SHADERS
242fi
243env | grep -E '^(LEONIDA_|MESA_VK|WINEDLL|KWIN_DRM)' | sort > "$RUN/env.txt"
244
245WINESERVER=$(dirname "$(command -v "$WINE")")/wineserver
246[ -x "$WINESERVER" ] || WINESERVER=wineserver
247SESSION_PID=
248teardown() {
249 "$WINESERVER" -k 2>/dev/null
250 if [ -n "$SESSION_PID" ] && kill -0 "$SESSION_PID" 2>/dev/null; then
251 pkill -TERM -s "$SESSION_PID" 2>/dev/null; sleep 2; pkill -KILL -s "$SESSION_PID" 2>/dev/null
252 fi
253 rm -rf "$XDG_RUNTIME_DIR"
254}
255trap teardown EXIT
256trap 'exit 130' INT TERM HUP
257
258# The session command with its arguments baked in (kwin takes one program path).
259{
260 echo '#!/bin/sh'
261 printf 'exec %q --inner %q %q %q %q' "$SELF" "$RUN" "$BUILD" "$LIMIT" "$SHOT_EVERY"
262 for a in "$@"; do printf ' %q' "$a"; done
263 echo
264} > "$RUN/inner.sh"
265chmod +x "$RUN/inner.sh"
266
267T0=$(date +%s)
268# setsid: Wine (and kwin, Xwayland and the private D-Bus when headless) form one session that teardown ends as a
269# whole, and never the user's desktop.
270if [ "$VISIBLE" = 1 ]; then
271 setsid "$RUN/inner.sh" > "$RUN/session.log" 2>&1 9>&- &
272else
273 setsid dbus-run-session -- kwin_wayland --virtual --xwayland --socket leonida-run-game-wine --width 1920 \
274 --height 1080 --no-lockscreen --no-global-shortcuts --exit-with-session "$RUN/inner.sh" \
275 > "$RUN/session.log" 2>&1 9>&- &
276fi
277SESSION_PID=$!
278# The session ends when the inner run returns; this outer limit adds a margin for the start-up.
279( sleep $((LIMIT + 180)); kill -TERM "$SESSION_PID" 2>/dev/null ) 9>&- 2>/dev/null &
280WATCH=$!
281wait "$SESSION_PID"
282pkill -P "$WATCH" 2>/dev/null; kill "$WATCH" 2>/dev/null
283teardown; SESSION_PID=
284T1=$(date +%s)
285
286echo "== $(tr '\n' ';' < "$RUN/session.txt" 2>/dev/null | sed 's/;$//')"
287if [ ! -f "$RUN/exit_code" ]; then
288 echo "the run did not start or the session ended early ($((T1 - T0)) s); see $RUN/session.log" >&2
289 exit 3
290fi
291python3 -I "$ROOT/tools/game_run_summary.py" "$RUN" --limit-seconds "$LIMIT" | tee "$RUN/summary.txt"
292echo "output: $RUN (stderr.log, boot.jsonl, summary.txt); total $((T1 - T0)) s. The logs stay on this machine."
293exit 0
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index 8ba62104d..a9d18b6ea 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -678,7 +678,8 @@ def check_clip_half(raw_path: str, want_b: float, want_a: float) -> tuple[bool,
678# Fixtures run by another harness, which needs what these tools do not have (a D3D12 device, the layer's root 678# Fixtures run by another harness, which needs what these tools do not have (a D3D12 device, the layer's root
679# arguments and code base). They are still assembled and translated here, so a translator regression shows, but no 679# arguments and code base). They are still assembled and translated here, so a translator regression shows, but no
680# checker runs them: the test program that owns them judges them. 680# checker runs them: the test program that owns them judges them.
681OTHER_HARNESS = {"ps_m15": "d3d12_translated_draw_test", "vs_m15": "d3d12_translated_draw_test", 681OTHER_HARNESS = {"ps_m15": "d3d12_translated_draw_test", "ps_m15_dual": "d3d12_translated_draw_test",
682 "vs_m15": "d3d12_translated_draw_test",
682 "ps_m2": "d3d12_m2_textured_test", "vs_m2": "d3d12_m2_textured_test", "ps_m2_uoff": "d3d12_m2_textured_test", 683 "ps_m2": "d3d12_m2_textured_test", "vs_m2": "d3d12_m2_textured_test", "ps_m2_uoff": "d3d12_m2_textured_test",
683 "ps_m2_literal": "d3d12_m2_textured_test", "ps_m2_array": "d3d12_m2_formats_test", 684 "ps_m2_literal": "d3d12_m2_textured_test", "ps_m2_array": "d3d12_m2_formats_test",
684 "ps_m3": "d3d12_m3_frame_test", "vs_m3": "d3d12_m3_frame_test", 685 "ps_m3": "d3d12_m3_frame_test", "vs_m3": "d3d12_m3_frame_test",