Files
d4r/install.sh
T
ayo d5c8be25c8 ASI add-on for existing OptiScaler installs
Add an optional D4R_INSTALL_MODE=asi release (d4r-<version>-asi.zip)
holding only d4r.asi and a companion d4r/ folder, to drop into an
existing OptiScaler plugin directory.

- Shim: export InitializeASI. It identifies OptiScaler by its PE export
  name to find the active INI, then launches d4r-setup.exe out of
  process (no GPU or network work under the loader lock). The .asi
  build loads its runtime and config from the companion d4r/ folder.

- tools/d4r_asi_setup.cpp: native helper. It waits for the game to
  exit, installs the D3D12 wrapper and the private d4r12core.dll beside
  the EXE, and merges the NGX route into the loader's INI (including
  GE-Proton's prefix-local INI) with backups. Unchanged launches do
  nothing. It skips Proton helpers and background utilities and runs
  setup for one plugin install at a time.

- scripts/private_d3d12_core.py: points vkd3d's d3d12.dll forwarder at
  d4r12core.dll without moving code addresses.

- install.sh runs from inside the ASI's d4r/ as well as the proxy
  release root. d4r-check.sh checks ASI installs (loader, plugin path,
  LoadAsiPlugins, HookOriginalNvngxOnly, Wine drive paths).

- Packaging, build script, docs, ASI_README.txt and tests.
2026-10-12 17:36:01 -04:00

87 lines
4.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# NVIDIA installer: beside the proxy release's d4r/ or inside the ASI's d4r/.
set -euo pipefail
DLSS_URL=https://raw.githubusercontent.com/NVIDIA/DLSS/a291cc7d2cc642a51566f3dfd5376f635cd1b284/lib/Windows_x86_64/rel/nvngx_dlss.dll
DLSS_SHA256=be6e434a94ca32499515eb62ca0e6c274526055d568d0426e4c652dcdfb6ee6e
DRIVER_URL=https://us.download.nvidia.com/Windows/596.36/596.36-desktop-win10-win11-64bit-international-dch-whql.exe
DRIVER_SHA256=4a1793d2bc7792f43270fe8286ec381ae24409fe29049dbe1eb8530ed89e19cf
NGX_SHA256=0e3423b3b7afa1019c7ecac053a8408df8e5d9d9d904434705c6aaeacec02fef
fail() { printf 'install.sh: %s\n' "$*" >&2; exit 1; }
if [[ ${1:-} == --help || ${1:-} == -h ]]; then
printf '%s\n' 'Usage: bash install.sh [extracted-release-directory]' \
'Default: the directory containing this script, regardless of your working directory.' \
'Downloads official NVIDIA DLSS 310.7.0 and NGX from driver 596.36 (~915 MiB).' \
'Requires Bash, curl, sha256sum, and 7zz, 7z or 7za. No sudo needed.' \
'Existing matching DLLs are kept; differing DLLs are backed up. NVIDIA license terms apply.'
exit 0
fi
[[ $# -le 1 ]] || fail 'Usage: bash install.sh [extracted-release-directory]'
ROOT=$(cd -- "${1:-$(dirname -- "${BASH_SOURCE[0]}")}" && pwd)
RUNTIME="$ROOT/d4r"
[[ ! -f "$ROOT/d4r.ini" ]] || RUNTIME="$ROOT"
[[ -f "$RUNTIME/nvngx.dll" && -f "$RUNTIME/d4r.ini" ]] || fail "Extract the release ZIP first; no d4r runtime found in $ROOT"
command -v sha256sum >/dev/null || fail 'Missing sha256sum (install coreutils).'
valid() { [[ -f "$1" ]] && [[ $(sha256sum -- "$1" | cut -d' ' -f1) == "$2" ]]; }
need_dlss=1; need_ngx=1
valid "$RUNTIME/nvngx_dlss.dll" "$DLSS_SHA256" && need_dlss=0
valid "$RUNTIME/ngx/_nvngx.dll" "$NGX_SHA256" && need_ngx=0
if (( need_dlss == 0 && need_ngx == 0 )); then
echo 'NVIDIA DLLs are already installed and verified.'
exit 0
fi
command -v curl >/dev/null || fail 'Missing curl. Install it and run this script again.'
if (( need_ngx )); then
SEVENZIP=''
for tool in 7zz 7z 7za; do
if command -v "$tool" >/dev/null; then SEVENZIP=$tool; break; fi
done
[[ -n "$SEVENZIP" ]] || fail 'Missing 7-Zip. Install 7zip (or p7zip) and run this script again.'
fi
TMP=$(mktemp -d)
STAGED=''
trap '[[ -z "$STAGED" ]] || rm -f -- "$STAGED"; rm -rf -- "$TMP"' EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
download() {
curl --fail --location --show-error --retry 3 --connect-timeout 30 \
--proto '=https' --proto-redir '=https' --output "$2" "$1" || fail "Download failed: $1. Run the installer again to retry."
}
verify() { valid "$1" "$2" || fail "SHA-256 mismatch for $1; no DLLs installed."; }
echo 'Downloading NVIDIA files under NVIDIA license terms:'
echo 'DLSS: https://github.com/NVIDIA/DLSS/blob/v310.7.0/LICENSE.txt'
echo 'Driver: https://www.nvidia.com/en-us/drivers/nvidia-license/'
if (( need_dlss )); then
echo 'Downloading DLSS 310.7.0...'
download "$DLSS_URL" "$TMP/nvngx_dlss.dll"
verify "$TMP/nvngx_dlss.dll" "$DLSS_SHA256"
fi
if (( need_ngx )); then
echo 'Downloading NVIDIA driver 596.36 (~915 MiB); extracting NGX without running the installer...'
download "$DRIVER_URL" "$TMP/driver.exe"
verify "$TMP/driver.exe" "$DRIVER_SHA256"
"$SEVENZIP" e -y -bso0 -bsp0 "-o$TMP/ngx" "$TMP/driver.exe" 'Display.Driver/_nvngx.dll' || fail 'Could not extract NGX; no DLLs installed.'
verify "$TMP/ngx/_nvngx.dll" "$NGX_SHA256"
fi
# Verify all downloads before modifying either destination. Stage on the destination
# filesystem for atomic replacement and retain a unique backup of a differing file.
place() {
local src=$1 dst=$2 backup
mkdir -p -- "$(dirname -- "$dst")"
[[ ! -d "$dst" ]] || fail "Destination is a directory: $dst"
STAGED=$(mktemp "${dst}.install.XXXXXX")
cp -- "$src" "$STAGED"
chmod 644 "$STAGED"
if [[ -e "$dst" || -L "$dst" ]]; then
backup=$(mktemp "${dst}.backup.XXXXXX")
cp -p -- "$dst" "$backup"
printf 'Saved previous DLL: %s\n' "$backup"
fi
mv -f -- "$STAGED" "$dst"
STAGED=''
printf 'Installed: %s\n' "$dst"
}
(( need_dlss == 0 )) || place "$TMP/nvngx_dlss.dll" "$RUNTIME/nvngx_dlss.dll"
(( need_ngx == 0 )) || place "$TMP/ngx/_nvngx.dll" "$RUNTIME/ngx/_nvngx.dll"
echo 'NVIDIA DLLs installed and verified. Follow the included README for Steam launch options.'