mirror of
https://github.com/DoubleGhosty/cool_fox.git
synced 2026-12-06 09:08:37 +00:00
182 lines
11 KiB
Bash
Executable File
182 lines
11 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Starts the title on Linux under Proton (umu-run) or Wine, with the settings
|
|
# of Play-VIctory.cmd's pareto-residency selector. Untested with the title:
|
|
# see docs/linux.md.
|
|
#
|
|
# VICTORY_GAME_DIR=~/Games/MyDump scripts/play-proton.sh
|
|
#
|
|
# Any VICTORY_* variable already set wins over the defaults below.
|
|
# VICTORY_EXE: another victory.exe. VICTORY_WINE=1: plain wine, not umu-run.
|
|
set -euo pipefail
|
|
|
|
root=$(cd "$(dirname "$0")/.." && pwd)
|
|
game_dir=${VICTORY_GAME_DIR:?set VICTORY_GAME_DIR to your own dump folder (it holds game_scarlett_master.exe)}
|
|
game_dir=$(realpath "$game_dir")
|
|
title="$game_dir/game_scarlett_master.exe"
|
|
runner=${VICTORY_EXE:-$root/target/x86_64-pc-windows-msvc/release/victory.exe}
|
|
|
|
[[ -f $title ]] || { echo "No $title. Set VICTORY_GAME_DIR to your own dump folder." >&2; exit 2; }
|
|
[[ -f $runner ]] || {
|
|
echo "No $runner. Build it: cargo xwin build --release --locked -p victory --target x86_64-pc-windows-msvc" >&2
|
|
exit 2
|
|
}
|
|
|
|
# A Linux path as Wine sees it: drive Z: is the root of the file system.
|
|
win() { local p; p=$(realpath -m "$1"); printf 'Z:%s' "${p//\//\\}"; }
|
|
|
|
# Kept outside the Wine prefix (and outside this checkout, which the tools
|
|
# refuse to write game-derived data into), so a new prefix keeps both.
|
|
cache=${XDG_CACHE_HOME:-$HOME/.cache}/victory/cache-pareto
|
|
data=${XDG_DATA_HOME:-$HOME/.local/share}/victory/data
|
|
mkdir -p "$cache" "$data"
|
|
|
|
export VICTORY_GAME_DIR="$(win "$game_dir")"
|
|
: "${VICTORY_CACHE_DIR:=$(win "$cache")}"
|
|
: "${VICTORY_DATA_DIR:=$(win "$data")}"
|
|
export VICTORY_CACHE_DIR VICTORY_DATA_DIR
|
|
# vkd3d-proton's own cache (translated shaders), beside ours: it would go in
|
|
# whatever folder the script was started from.
|
|
mkdir -p "$cache/../vkd3d"
|
|
: "${VKD3D_SHADER_CACHE_PATH:=$(win "$cache/../vkd3d")}"
|
|
export VKD3D_SHADER_CACHE_PATH
|
|
# Proton does not pass the title's stderr through: the log goes to a file.
|
|
log=${XDG_STATE_HOME:-$HOME/.local/state}/victory/victory.log
|
|
mkdir -p "$(dirname "$log")"
|
|
: "${VICTORY_LOG_FILE:=$(win "$log")}"
|
|
export VICTORY_LOG_FILE
|
|
|
|
# Play-VIctory.cmd's defaults (pareto-residency, as of upstream 472e841),
|
|
# each only if not set; and for Wine, VICTORY_COMMITTED_QUERY=1: there
|
|
# QueryWorkingSetEx holds Wine's memory lock while it reads /proc/self/pagemap
|
|
# (1.5 s of every 8 in the world), where VirtualQuery is cheap.
|
|
# VICTORY_AMBIENT=1 (the estimate from the frame) where Play-VIctory.cmd has
|
|
# constant:0.8: the prologue's rooms were dark red and its yard milky white
|
|
# with the constant, lit by their lamps and the sunset with the estimate.
|
|
# VICTORY_AMBIENT_FLOOR=0.4: the estimate at least that fill light. It follows only the light the
|
|
# visible surfaces send out directly, so the cell (lit through one window) kept its people as
|
|
# silhouettes; with 0.4 they, the bunks and the card game on the floor show (RTX 5060 prologue).
|
|
# VICTORY_HAIR=1: upstream leaves the hair strands' passes out as broken; on
|
|
# an RTX 5060 under Proton they draw right (101 ms a frame with, 119 without).
|
|
# VICTORY_GUARD_REST=50000 (50 ms, 3 by default): a change of protection costs
|
|
# far more under Wine (Wine's lock, every core's TLB); a block the title just
|
|
# wrote rests longer: blocks made read-only a frame 861 -> 461, faults 478 -> 364.
|
|
# VICTORY_WC_NO_BACK=1 with VICTORY_WC_NO_BACK_MIN_KB=1024 (as VIctory-NVIDIA's launcher): what
|
|
# shaders write into big write-combined title memory, which the title's CPU does not read,
|
|
# stays on the card (RTX 5060 prologue: copying back 27 -> 11 ms a frame, preparing 79 -> 67).
|
|
for setting in \
|
|
VICTORY_AMBIENT_AIR=1.5 VICTORY_TEXTURE_NO_WAIT=1 VICTORY_WIDE_BACK=1 \
|
|
VICTORY_CARD_REHASH_RUNS=1 VICTORY_JOIN_COPIES=1 VICTORY_INDIRECT_WINDOW=1 VICTORY_RELAY_COPY=1 \
|
|
VICTORY_CARD_STEPS=2 VICTORY_INDIRECT_BATCH=2 VICTORY_MAP_THREADS=1 VICTORY_CARD_AWAKE=1 \
|
|
VICTORY_SHOW_AFTER=1 VICTORY_AMBIENT=1 VICTORY_THIN=0 VICTORY_JOIN_PARTS=0 \
|
|
VICTORY_TEXTURE_GUARD=0 VICTORY_PORT_CONSTANTS=1 VICTORY_PORT_CBV=1 \
|
|
VICTORY_UPLOAD_AHEAD=1 VICTORY_LEVELS_ON_DEMAND=1 VICTORY_CARD_BUFFERS_MIN_KB=64 \
|
|
VICTORY_COMMITTED_QUERY=1 VICTORY_HAIR=1 VICTORY_GUARD_REST=50000 \
|
|
VICTORY_WC_NO_BACK=1 VICTORY_WC_NO_BACK_MIN_KB=1024 VICTORY_AMBIENT_FLOOR=0.4; do
|
|
name=${setting%%=*}
|
|
[[ -n ${!name:-} ]] || export "$setting"
|
|
done
|
|
[[ -n ${VICTORY_LOG:-} || -n ${RUST_LOG:-} ]] || export VICTORY_LOG=warn
|
|
# Wine writes a `fixme` line for every call it does not implement, and the
|
|
# layer makes some in hot paths: one session logged 33,198 (#116). Proton
|
|
# defaults to this already; plain wine (VICTORY_WINE=1) does not.
|
|
# The title ends itself (a write to 0 at +0x23cf683) when its main loop has
|
|
# not ticked for 30 s, as while its first frames wait for their compute
|
|
# pipelines: while bit 0 of title+0x71b6330 is set its watchdog starts over.
|
|
# Only for that build (image hash b99f876b74d4a77f...), as in Play-VIctory*.cmd.
|
|
: "${VICTORY_POKE:=b99f876b74d4a77f@71b6330:1}"
|
|
export VICTORY_POKE
|
|
: "${WINEDEBUG:=-all}"
|
|
export WINEDEBUG
|
|
# On an NVIDIA card the title's own upscaler (VICTORY_UPSCALER=6), not
|
|
# FidelityFX's (7, the title's choice on Series S): FidelityFX's is a network
|
|
# of 8-bit dot products, and its eight largest layers took 120 of the 200 ms
|
|
# of an RTX 5060's frame (the prologue: 207 -> 115 ms a frame). It also
|
|
# avoids its divide by zero at output sizes other than 1920x1080.
|
|
if [[ -z ${VICTORY_UPSCALER:-} && -e /proc/driver/nvidia/version ]]; then
|
|
export VICTORY_UPSCALER=6
|
|
fi
|
|
# On a host of 32-lane waves (NVIDIA) the decal heap's CS_DefragHeap_ComputeRelocations
|
|
# (02384a60fda6f2d0) runs only in a form whose two host waves meet by spinning: 18.6 ms of an
|
|
# RTX 5060's frame, the costliest command (VICTORY_GPU_TIMING). VICTORY_SKIP_DEFRAG=1 leaves it
|
|
# out, as VIctory-NVIDIA's launcher does: prologue 102 -> 91 ms a frame, waits for the card
|
|
# 22.7 -> 5.2 ms. Not by default: without it decals the heap moves come out black (beer
|
|
# bottles' labels in the boat mission, #94).
|
|
if [[ ${VICTORY_SKIP_DEFRAG:-0} == 1 && -z ${VICTORY_SKIP_PIPELINES:-} ]]; then
|
|
export VICTORY_SKIP_PIPELINES=02384a60fda6f2d0
|
|
fi
|
|
# Blocks of 16 MiB for textures on NVIDIA cards of 10 GB or less (VICTORY_TEXTURE_BLOCK_MB): a
|
|
# block goes back only when empty, and with 64 MiB ones a third of the blocks stood free in pieces
|
|
# (0.95-1.32 of 3.1-3.4 GB) while the card was over its budget. RTX 5060 8 GB prologue, two runs
|
|
# each: blocks 2.3 GB with 0.3 GB free, the cell's frame 93 / 101 ms instead of 111 / 280.
|
|
if [[ -e /proc/driver/nvidia/version ]]; then
|
|
card_mb=$(nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits 2>/dev/null | head -1)
|
|
if [[ ${card_mb:-0} -gt 0 && $card_mb -le 10240 ]]; then
|
|
: "${VICTORY_TEXTURE_BLOCK_MB:=16}"
|
|
export VICTORY_TEXTURE_BLOCK_MB
|
|
fi
|
|
fi
|
|
|
|
# VICTORY_CONSOLE: series-x or series-s (series-s fits an 8 GB card: docs/profiling.md).
|
|
# Wine hands threads the priorities asked for (the title's ahead of our
|
|
# pipeline workers and streaming) only if it may raise priority: a hard
|
|
# RLIMIT_NICE above 20. Without, every thread is at the same niceness, on
|
|
# eight cores busy with some 140 threads (prologue: 120 -> 105 ms a frame,
|
|
# p90 140 -> 114, with it). Fedora's gamemode group is allowed -10.
|
|
if (( $(ulimit -He) <= 20 )); then
|
|
echo "Thread priorities off: RLIMIT_NICE is $(ulimit -He). For about 15 ms a frame less:" >&2
|
|
echo " sudo usermod -aG gamemode $USER (then log in again)" >&2
|
|
fi
|
|
|
|
# Card memory on NVIDIA (8 GB: the driver keeps ~3 MB per pipeline outside vkd3d's heaps, #140,
|
|
# and the budget falls from ~5.7 to ~3.5 GB as a run makes its ~1,900 pipelines):
|
|
# - VKD3D_CONFIG=no_upload_hvv: vkd3d keeps upload heaps in the PC's memory instead of the card's
|
|
# CPU-visible memory: ~0.5 GB of the card back, frames no slower (as #140 measured, ~1 GB there).
|
|
# - VICTORY_CARD_ROOM_FOR_TARGETS_MB=768: the texture queue keeps room for render targets not
|
|
# made yet; its 3,072 MB default came from runs whose targets reached ~3 GB, the Series S
|
|
# prologue at 1080p peaks at ~1.36 GB, so ~1.7 GB stood unused while textures due waited (the
|
|
# oldest 1,163 frames; with 1536, 55). While the world loads the targets hold ~0.25 GB, so 1536
|
|
# still kept ~1.3 GB from the textures of the opening cutscene: faces black or blotched in its
|
|
# first shots, the jumpsuit dark red, black frames. With 768 (two runs each, a capture every
|
|
# 2 s): faces and jumpsuit right, the shots lit, no black frames; card peak and frames the same.
|
|
if [[ -e /proc/driver/nvidia/version ]]; then
|
|
[[ -n ${VKD3D_CONFIG+x} ]] || export VKD3D_CONFIG=no_upload_hvv
|
|
: "${VICTORY_CARD_ROOM_FOR_TARGETS_MB:=768}"
|
|
export VICTORY_CARD_ROOM_FOR_TARGETS_MB
|
|
fi
|
|
|
|
# NVIDIA cards of 10 GB or less: textures the title fills leave out their largest level
|
|
# (VICTORY_TEXTURE_DROP_MIPS=1: 2D, 512 texels and up), each about a quarter of the bytes. RTX 5060
|
|
# 8 GB prologue: the oldest due texture waited 8 frames instead of 55, 1.1 GB of textures alive
|
|
# instead of 0.8; at 1080p the largest level of a texture is seldom what is seen.
|
|
if [[ -e /proc/driver/nvidia/version ]]; then
|
|
card_mb=$(nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits 2>/dev/null | head -1)
|
|
if [[ ${card_mb:-0} -gt 0 && $card_mb -le 10240 ]]; then
|
|
: "${VICTORY_TEXTURE_DROP_MIPS:=1}"
|
|
export VICTORY_TEXTURE_DROP_MIPS
|
|
# The budget the runtime plans with, at most 55 % of the card (VICTORY_CARD_BUDGET_MB). The
|
|
# system's budget while the world loads depends on what the desktop holds then, and falls by
|
|
# 1-2 GB later as the driver keeps memory for each pipeline made (#140). After a fresh boot
|
|
# it said 5.1-5.6 GB on an 8 GB RTX 5060 (3.8-4.6 GB after hours of desktop use): the
|
|
# texture queue filled the card before the render targets, buffer copies and pipelines
|
|
# came, the card went over, and the run stayed at 260-280 ms a frame (the card 50-100 ms of
|
|
# it), with 1.3-1.6 GB stranded in the texture blocks; 4 runs of 4. With 4,500 MB, on the
|
|
# same freshly booted machine and build: 94 ms (the card 5-12 ms), 0.77 GB in the blocks.
|
|
: "${VICTORY_CARD_BUDGET_MB:=$((card_mb * 55 / 100))}"
|
|
export VICTORY_CARD_BUDGET_MB
|
|
fi
|
|
fi
|
|
|
|
args=(run "$(win "$title")" --console "${VICTORY_CONSOLE:-series-x}" --execute)
|
|
if [[ ${VICTORY_WINE:-0} != 1 ]] && command -v umu-run >/dev/null; then
|
|
# A GE-Proton whose wineserver keeps views in a tree (docs/linux.md): with
|
|
# the stock one every map and unmap of the title's ~30,000 page views
|
|
# searches them all while Wine's memory lock is held. Used if installed.
|
|
patched=${STEAM_COMPAT_TOOLS:-$HOME/.local/share/Steam/compatibilitytools.d}/GE-Proton11-14-victory
|
|
[[ -n ${PROTONPATH:-} || ! -x $patched/proton ]] || PROTONPATH=$patched
|
|
export GAMEID=${GAMEID:-umu-default} PROTONPATH=${PROTONPATH:-GE-Proton}
|
|
exec umu-run "$runner" "${args[@]}"
|
|
fi
|
|
command -v wine >/dev/null || { echo "Install umu-launcher (or wine)." >&2; exit 2; }
|
|
echo "umu-run not found (or VICTORY_WINE=1): plain wine, without Proton's vkd3d-proton unless the prefix has it." >&2
|
|
exec wine "$runner" "${args[@]}"
|