mirror of
https://github.com/gamingwithhomie/larp.git
synced 2026-12-06 07:38:36 +00:00
- Upgrade the known 2013 compiler from Microsoft SDK after verifying its hash. - Warn about the outdated DLL and document shader model 5.1 failures.
209 lines
6.8 KiB
Bash
Executable File
209 lines
6.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
SCRIPT_PATH="$SCRIPT_DIR/$(basename "${BASH_SOURCE[0]}")"
|
|
# shellcheck source=/dev/null
|
|
source "$SCRIPT_DIR/common.sh"
|
|
|
|
REPO_ROOT="$(larp_repo_root)"
|
|
larp_load_config "$REPO_ROOT"
|
|
|
|
CHECK_ONLY=0
|
|
SKIP_D3DCOMPILER=0
|
|
FORCE_D3DCOMPILER=0
|
|
DLSS_SOURCE_ARG=""
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage: linux/setup.sh [options]
|
|
|
|
Prepare runtime directories, Proton prefix, native d3dcompiler_47.dll (for ray tracing),
|
|
and optional NVIDIA DLSS symlinks outside the larp repository.
|
|
|
|
Options:
|
|
--check Check current Linux setup status without modifying anything
|
|
--dlss-dir <dir> Copy/symlink user-provided nvngx_dlss.dll from <dir>
|
|
--skip-d3dcompiler Skip winetricks installation of native d3dcompiler_47.dll
|
|
--force-d3dcompiler Reinstall native d3dcompiler_47.dll via winetricks even if present
|
|
-h, --help Show this help message
|
|
EOF
|
|
}
|
|
|
|
ORIG_ARGS=("$@")
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--check)
|
|
CHECK_ONLY=1
|
|
shift
|
|
;;
|
|
--dlss-dir)
|
|
if [[ $# -lt 2 ]]; then
|
|
printf 'error: --dlss-dir requires a directory argument.\n' >&2
|
|
exit 1
|
|
fi
|
|
DLSS_SOURCE_ARG="$2"
|
|
shift 2
|
|
;;
|
|
--skip-d3dcompiler)
|
|
SKIP_D3DCOMPILER=1
|
|
shift
|
|
;;
|
|
--force-d3dcompiler)
|
|
FORCE_D3DCOMPILER=1
|
|
shift
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
printf 'error: unknown option: %s\n' "$1" >&2
|
|
usage >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
GPU_VENDOR="$(larp_detect_gpu)"
|
|
PROTON_DIR="$(larp_find_proton || true)"
|
|
|
|
if [[ "$CHECK_ONLY" -eq 1 ]]; then
|
|
printf 'larp Linux setup check\n'
|
|
printf ' repo: %s\n' "$REPO_ROOT"
|
|
printf ' data dir: %s\n' "$LARP_LINUX_DATA"
|
|
printf ' cache dir: %s\n' "$LARP_LINUX_CACHE"
|
|
printf ' wineprefix: %s\n' "$WINEPREFIX"
|
|
printf ' gpu: %s\n' "$GPU_VENDOR"
|
|
printf ' proton: %s\n' "${PROTON_DIR:-MISSING}"
|
|
printf ' umu-run: %s\n' "$(command -v umu-run || echo MISSING)"
|
|
printf ' winetricks: %s\n' "$(command -v winetricks || echo MISSING)"
|
|
if [[ -f "$WINEPREFIX/pfx/system.reg" ]]; then
|
|
printf ' prefix init: yes\n'
|
|
else
|
|
printf ' prefix init: no\n'
|
|
fi
|
|
if larp_has_old_d3dcompiler; then
|
|
printf ' d3dcompiler: outdated 2013 version (run setup to upgrade)\n'
|
|
elif larp_has_native_d3dcompiler; then
|
|
printf ' d3dcompiler: native d3dcompiler_47.dll present (version not checked)\n'
|
|
else
|
|
printf ' d3dcompiler: missing or Wine builtin (host ray tracing disabled)\n'
|
|
fi
|
|
if [[ "$GPU_VENDOR" == "nvidia" ]]; then
|
|
for dll in nvngx_dlss.dll nvngx_dlssg.dll nvngx_dlssd.dll; do
|
|
if [[ -e "$LARP_LINUX_DLSS_DIR/$dll" ]]; then
|
|
printf ' %s: present (%s)\n' "$dll" "$LARP_LINUX_DLSS_DIR/$dll"
|
|
else
|
|
printf ' %s: missing in %s\n' "$dll" "$LARP_LINUX_DLSS_DIR"
|
|
fi
|
|
done
|
|
fi
|
|
exit 0
|
|
fi
|
|
|
|
missing_tools=()
|
|
if ! command -v umu-run >/dev/null 2>&1; then
|
|
missing_tools+=(umu-run)
|
|
fi
|
|
if [[ "$SKIP_D3DCOMPILER" -eq 0 ]] && ! command -v winetricks >/dev/null 2>&1; then
|
|
missing_tools+=(winetricks)
|
|
fi
|
|
|
|
if [[ "${#missing_tools[@]}" -gt 0 ]]; then
|
|
larp_reexec_in_nix "$REPO_ROOT" "$SCRIPT_PATH" "${ORIG_ARGS[@]}" || true
|
|
printf 'error: missing required runtime tool(s): %s\n' "${missing_tools[*]}" >&2
|
|
printf 'Install them with your package manager or run: nix develop "path:%s"\n' "$REPO_ROOT" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "$PROTON_DIR" ]]; then
|
|
printf 'error: no Steam Proton installation found.\n' >&2
|
|
printf 'Install Proton Experimental via Steam, or set PROTONPATH=/path/to/proton.\n' >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p \
|
|
"$LARP_LINUX_DATA/data" \
|
|
"$LARP_LINUX_DLSS_DIR" \
|
|
"$WINEPREFIX" \
|
|
"$LARP_LINUX_CACHE/gl-shader-cache" \
|
|
"$LARP_LINUX_CACHE/dstorage" \
|
|
"$LARP_LINUX_CACHE/images" \
|
|
"$LARP_LINUX_CACHE/pipelines" \
|
|
"$LARP_LINUX_CACHE/shaders"
|
|
|
|
PV_RW="$(larp_collect_pv_paths "$REPO_ROOT" "$LARP_LINUX_DATA" "$LARP_LINUX_CACHE" "$WINEPREFIX")"
|
|
if [[ -n "$PV_RW" ]]; then
|
|
export PRESSURE_VESSEL_FILESYSTEMS_RW="$PV_RW"
|
|
fi
|
|
|
|
export GAMEID="${GAMEID:-umu-default}"
|
|
export PROTONPATH="$PROTON_DIR"
|
|
|
|
if [[ ! -f "$WINEPREFIX/pfx/system.reg" ]]; then
|
|
printf 'Initializing Proton prefix at %s...\n' "$WINEPREFIX"
|
|
umu-run cmd /c exit 0
|
|
fi
|
|
|
|
if [[ "$SKIP_D3DCOMPILER" -eq 0 ]]; then
|
|
if [[ "$FORCE_D3DCOMPILER" -eq 1 ]] || ! larp_has_native_d3dcompiler; then
|
|
printf 'Installing native Microsoft d3dcompiler_47.dll into %s/pfx (for host ray tracing)...\n' "$WINEPREFIX"
|
|
WINEPREFIX="$WINEPREFIX/pfx" winetricks -q d3dcompiler_47
|
|
else
|
|
printf 'Native d3dcompiler_47.dll already present in %s/pfx.\n' "$WINEPREFIX"
|
|
fi
|
|
if larp_has_old_d3dcompiler; then
|
|
(
|
|
set -e
|
|
for tool in curl cabextract sha256sum; do
|
|
if ! command -v "$tool" >/dev/null 2>&1; then
|
|
printf 'error: %s is required to update the outdated d3dcompiler_47.dll.\n' "$tool" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
tmp="$(mktemp -d)"
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
printf 'Updating the 2013 d3dcompiler_47.dll to the Microsoft Windows SDK version...\n'
|
|
curl -fsSL 'https://download.microsoft.com/download/38ab8f6d-3676-4860-ae84-3361308b9d7f/KIT_BUNDLE_WINDOWSSDK_MEDIACREATION/Installers/61d57a7a82309cd161a854a6f4619e52.cab' -o "$tmp/compiler.cab"
|
|
cabextract -q -L -F fil3585cb2ea5db13cc0838f8d06b5c9679 -d "$tmp" "$tmp/compiler.cab"
|
|
printf '%s %s\n' '3e56c1a0867aa04cbca948b3664fcac5d51275865cd044a45a3fd6ce636ee914' "$tmp/fil3585cb2ea5db13cc0838f8d06b5c9679" | sha256sum -c -
|
|
dll="$(larp_wine_system32_dir)/d3dcompiler_47.dll"
|
|
cp -n "$dll" "$dll.old-2013"
|
|
cp "$tmp/fil3585cb2ea5db13cc0838f8d06b5c9679" "$dll"
|
|
)
|
|
fi
|
|
fi
|
|
|
|
if [[ "$GPU_VENDOR" == "nvidia" ]]; then
|
|
nv_wine_dir="$(larp_find_nvidia_wine_dir || true)"
|
|
if [[ -n "$nv_wine_dir" ]]; then
|
|
for dll in nvngx_dlssg.dll nvngx_dlssd.dll; do
|
|
if [[ ! -e "$LARP_LINUX_DLSS_DIR/$dll" && -e "$nv_wine_dir/$dll" ]]; then
|
|
ln -s "$nv_wine_dir/$dll" "$LARP_LINUX_DLSS_DIR/$dll"
|
|
printf 'Linked %s -> %s\n' "$LARP_LINUX_DLSS_DIR/$dll" "$nv_wine_dir/$dll"
|
|
fi
|
|
done
|
|
fi
|
|
|
|
dlss_src="${DLSS_SOURCE_ARG:-${LARP_DLSS_SOURCE_DIR:-}}"
|
|
if [[ -n "$dlss_src" ]]; then
|
|
if [[ -f "$dlss_src/nvngx_dlss.dll" ]]; then
|
|
ln -sf "$(larp_abspath "$dlss_src/nvngx_dlss.dll")" "$LARP_LINUX_DLSS_DIR/nvngx_dlss.dll"
|
|
printf 'Linked user-supplied nvngx_dlss.dll from %s\n' "$dlss_src"
|
|
else
|
|
printf 'warning: --dlss-dir / LARP_DLSS_SOURCE_DIR (%s) does not contain nvngx_dlss.dll\n' "$dlss_src" >&2
|
|
fi
|
|
fi
|
|
|
|
if [[ ! -e "$LARP_LINUX_DLSS_DIR/nvngx_dlss.dll" ]]; then
|
|
cat <<EOF
|
|
note: nvngx_dlss.dll was not found in $LARP_LINUX_DLSS_DIR.
|
|
NVIDIA DLSS upscaling requires you to supply your own nvngx_dlss.dll (not included with drivers or larp).
|
|
Copy or symlink nvngx_dlss.dll into $LARP_LINUX_DLSS_DIR, or re-run with --dlss-dir /path/to/dir.
|
|
EOF
|
|
fi
|
|
fi
|
|
|
|
printf 'Setup complete.\n'
|