diff options
| author | NotRexed <therealnothingfn@gmail.com> | 2026-11-26 15:49:02 -0500 |
|---|---|---|
| committer | NotRexed <therealnothingfn@gmail.com> | 2026-11-26 15:49:02 -0500 |
| commit | 8a73677be8ad634fa4d8abd4955c4fd2b19bb26f (patch) | |
| tree | a2e2d1f1dcf4002af1932a2e8ee1ac714c944d2d /scripts | |
| parent | bafb0e25b6aaddacaa3a3c9e2593e11d03975eaa (diff) | |
Linux: bundle VKD3D-Proton with the D3D12 runtime
On Linux the D3D12 runtime (victory/) runs under Wine. Its Direct3D 12 now comes in the package, so
players download nothing else for D3D12.
- scripts/fetch_vkd3d_proton.py puts VKD3D-Proton 3.1's unmodified 64-bit d3d12.dll and
d3d12core.dll in the package. It also adds the LGPL-2.1 text and notice from the v3.1 tag and a
note on where the source is. Every download is checked against a pinned SHA-256. Standard
library only; Python 3.14 for compression.zstd.
- scripts/play-linux.sh installs the bundled DLLs into Leonida's own Wine prefix (no other prefix is
touched) and sets WINEDLLOVERRIDES=d3d12,d3d12core=n. It runs the runtime with the measured
NVIDIA defaults of play-nvidia.ps1.
- docs/linux.md describes the package and what is still untested: the launcher is syntax-checked
only; it has not run on a Linux machine yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/fetch_vkd3d_proton.py | 75 | ||||
| -rwxr-xr-x | scripts/play-linux.sh | 71 |
2 files changed, 146 insertions, 0 deletions
diff --git a/scripts/fetch_vkd3d_proton.py b/scripts/fetch_vkd3d_proton.py new file mode 100755 index 000000000..1c3fe22d5 --- /dev/null +++ b/scripts/fetch_vkd3d_proton.py | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | #!/usr/bin/env python3 | ||
| 2 | """Fetch the pinned VKD3D-Proton release for Leonida's Linux package. | ||
| 3 | |||
| 4 | On Linux the D3D12 runtime (victory/, a Windows program) runs under Wine, and Wine needs a Direct3D 12 implementation: | ||
| 5 | VKD3D-Proton (LGPL-2.1-or-later, https://github.com/HansKristian-Work/vkd3d-proton) translates it to Vulkan. This | ||
| 6 | tool puts the 64-bit d3d12.dll and d3d12core.dll of one pinned release, with its license and a note on where its | ||
| 7 | source is, into the package folder, so a Linux player needs nothing else for D3D12 (scripts/play-linux.sh installs | ||
| 8 | them into Leonida's own Wine prefix). Every download is checked against the SHA-256 pinned below. | ||
| 9 | |||
| 10 | Standard library only (Python 3.14 or newer: compression.zstd reads the release's .tar.zst). | ||
| 11 | |||
| 12 | python -I scripts/fetch_vkd3d_proton.py --out dist/linux/vkd3d-proton | ||
| 13 | """ | ||
| 14 | import argparse | ||
| 15 | import hashlib | ||
| 16 | import io | ||
| 17 | import os | ||
| 18 | import sys | ||
| 19 | import tarfile | ||
| 20 | import urllib.request | ||
| 21 | |||
| 22 | VERSION = "3.1" | ||
| 23 | RELEASE = (f"https://github.com/HansKristian-Work/vkd3d-proton/releases/download/v{VERSION}/" | ||
| 24 | f"vkd3d-proton-{VERSION}.tar.zst", | ||
| 25 | "b85ea8219b71093a3924913dd7aae6172333dc0c069983ed510816d67f02120b") | ||
| 26 | # The release archive carries no license text: the notice and the LGPL-2.1 from the same tag. | ||
| 27 | LICENSE_FILES = { | ||
| 28 | "COPYING": (f"https://raw.githubusercontent.com/HansKristian-Work/vkd3d-proton/v{VERSION}/COPYING", | ||
| 29 | "f51ad4bf5a3bd2b5f383fe28150b23d01e6f5d7b620b194150e7c6a620c43c1f"), | ||
| 30 | "LICENSE": (f"https://raw.githubusercontent.com/HansKristian-Work/vkd3d-proton/v{VERSION}/LICENSE", | ||
| 31 | "dc626520dcd53a22f727af3ee42c770e56c97a64fe3adb063799d8ab032fe551"), | ||
| 32 | } | ||
| 33 | DLLS = ("d3d12.dll", "d3d12core.dll") | ||
| 34 | |||
| 35 | |||
| 36 | def fetch(url, sha256): | ||
| 37 | with urllib.request.urlopen(url, timeout=120) as response: | ||
| 38 | data = response.read() | ||
| 39 | got = hashlib.sha256(data).hexdigest() | ||
| 40 | if got != sha256: | ||
| 41 | raise SystemExit(f"{url}: SHA-256 {got}, expected {sha256}; not used") | ||
| 42 | return data | ||
| 43 | |||
| 44 | |||
| 45 | def main(): | ||
| 46 | parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) | ||
| 47 | parser.add_argument("--out", default=os.path.join("dist", "linux", "vkd3d-proton"), | ||
| 48 | help="folder for the DLLs, license and source note (created)") | ||
| 49 | args = parser.parse_args() | ||
| 50 | try: | ||
| 51 | import compression.zstd as zstd | ||
| 52 | except ImportError: | ||
| 53 | raise SystemExit("Python 3.14 or newer is needed (compression.zstd reads the .tar.zst release)") | ||
| 54 | |||
| 55 | os.makedirs(args.out, exist_ok=True) | ||
| 56 | archive = zstd.decompress(fetch(*RELEASE)) | ||
| 57 | with tarfile.open(fileobj=io.BytesIO(archive)) as tar: | ||
| 58 | for name in DLLS: | ||
| 59 | member = tar.getmember(f"vkd3d-proton-{VERSION}/x64/{name}") | ||
| 60 | with tar.extractfile(member) as src, open(os.path.join(args.out, name), "wb") as dst: | ||
| 61 | dst.write(src.read()) | ||
| 62 | for name, (url, sha256) in LICENSE_FILES.items(): | ||
| 63 | with open(os.path.join(args.out, name), "wb") as dst: | ||
| 64 | dst.write(fetch(url, sha256)) | ||
| 65 | with open(os.path.join(args.out, "SOURCE.txt"), "w", encoding="utf-8", newline="\n") as note: | ||
| 66 | note.write(f"VKD3D-Proton {VERSION}, unmodified 64-bit d3d12.dll and d3d12core.dll from\n" | ||
| 67 | f"{RELEASE[0]}\n(SHA-256 {RELEASE[1]}).\n" | ||
| 68 | f"Licensed under the GNU Lesser General Public License 2.1 or later (LICENSE, COPYING).\n" | ||
| 69 | f"Source: https://github.com/HansKristian-Work/vkd3d-proton/tree/v{VERSION}\n") | ||
| 70 | print(f"VKD3D-Proton {VERSION}: {', '.join(DLLS)}, LICENSE, COPYING and SOURCE.txt in {args.out}") | ||
| 71 | return 0 | ||
| 72 | |||
| 73 | |||
| 74 | if __name__ == "__main__": | ||
| 75 | sys.exit(main()) | ||
diff --git a/scripts/play-linux.sh b/scripts/play-linux.sh new file mode 100755 index 000000000..f9ac0c3cb --- /dev/null +++ b/scripts/play-linux.sh | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Starts Leonida's D3D12 runtime (victory/, a Windows program) on Linux under Wine, with the VKD3D-Proton that comes in | ||
| 3 | # the package (scripts/fetch_vkd3d_proton.py puts it in vkd3d-proton/ beside this script), so nothing else needs to be | ||
| 4 | # downloaded for Direct3D 12. Wine itself and a Vulkan driver (Mesa or NVIDIA's) are the system's. | ||
| 5 | # | ||
| 6 | # ./play-linux.sh /path/to/your/game_scarlett_master.exe [--series-x] | ||
| 7 | # | ||
| 8 | # Leonida keeps its own Wine prefix (LEONIDA_WINEPREFIX, default ~/.local/share/leonida/prefix): the bundled | ||
| 9 | # d3d12.dll and d3d12core.dll are installed there and preferred over Wine's (WINEDLLOVERRIDES), so no other prefix | ||
| 10 | # is changed. VICTORY_* variables already set win over the defaults below. | ||
| 11 | set -eu | ||
| 12 | |||
| 13 | if [ $# -lt 1 ]; then | ||
| 14 | echo "usage: $0 /path/to/game_scarlett_master.exe [--series-x]" >&2 | ||
| 15 | exit 2 | ||
| 16 | fi | ||
| 17 | game_exe=$1 | ||
| 18 | shift | ||
| 19 | console=series-s | ||
| 20 | if [ "${1:-}" = "--series-x" ]; then console=series-x; fi | ||
| 21 | [ -f "$game_exe" ] || { echo "No $game_exe" >&2; exit 1; } | ||
| 22 | |||
| 23 | here=$(cd "$(dirname "$0")" && pwd) | ||
| 24 | victory=${LEONIDA_VICTORY:-$here/victory.exe} | ||
| 25 | vkd3d=${LEONIDA_VKD3D:-$here/vkd3d-proton} | ||
| 26 | [ -f "$victory" ] || { echo "No $victory (the Windows build of victory/)" >&2; exit 1; } | ||
| 27 | for dll in d3d12.dll d3d12core.dll; do | ||
| 28 | [ -f "$vkd3d/$dll" ] || { echo "No $vkd3d/$dll: run scripts/fetch_vkd3d_proton.py when packaging" >&2; exit 1; } | ||
| 29 | done | ||
| 30 | command -v wine >/dev/null 2>&1 || { echo "Wine is needed (your distribution's wine package, or Proton's)" >&2; exit 1; } | ||
| 31 | |||
| 32 | data=${XDG_DATA_HOME:-$HOME/.local/share}/leonida | ||
| 33 | export WINEPREFIX=${LEONIDA_WINEPREFIX:-$data/prefix} | ||
| 34 | export WINEARCH=win64 | ||
| 35 | if [ ! -d "$WINEPREFIX/drive_c/windows/system32" ]; then | ||
| 36 | echo "Leonida: making its Wine prefix in $WINEPREFIX" | ||
| 37 | mkdir -p "$WINEPREFIX" | ||
| 38 | WINEDEBUG=-all wineboot -u >/dev/null 2>&1 | ||
| 39 | fi | ||
| 40 | # The bundled VKD3D-Proton, copied in when it is missing or differs (a new package). | ||
| 41 | system32=$WINEPREFIX/drive_c/windows/system32 | ||
| 42 | for dll in d3d12.dll d3d12core.dll; do | ||
| 43 | if ! cmp -s "$vkd3d/$dll" "$system32/$dll"; then cp "$vkd3d/$dll" "$system32/$dll"; fi | ||
| 44 | done | ||
| 45 | export WINEDLLOVERRIDES="d3d12,d3d12core=n${WINEDLLOVERRIDES:+;$WINEDLLOVERRIDES}" | ||
| 46 | |||
| 47 | # Where the title's files are, and where the caches and saves go. | ||
| 48 | export VICTORY_GAME_DIR=${VICTORY_GAME_DIR:-$(cd "$(dirname "$game_exe")" && pwd)} | ||
| 49 | export VICTORY_CACHE_DIR=${VICTORY_CACHE_DIR:-$data/cache} | ||
| 50 | export VICTORY_DATA_DIR=${VICTORY_DATA_DIR:-$data/data} | ||
| 51 | mkdir -p "$VICTORY_CACHE_DIR" "$VICTORY_DATA_DIR" | ||
| 52 | |||
| 53 | # The settings scripts/play-nvidia.ps1 measured (victory/README.md), as defaults. | ||
| 54 | set_default() { eval "[ -n \"\${$1:-}\" ] || export $1=\"$2\""; } | ||
| 55 | set_default VICTORY_TEXTURE_NO_WAIT 1 | ||
| 56 | set_default VICTORY_RELAY 2 | ||
| 57 | set_default VICTORY_CARD_STEPS 2 | ||
| 58 | set_default VICTORY_DYNAMIC_SLOTS 524288 | ||
| 59 | set_default VICTORY_PIPELINE_WAIT_MS 10000 | ||
| 60 | set_default VICTORY_RENDER_SCALE 0.5 | ||
| 61 | set_default VICTORY_OWN_UPSCALER 1 | ||
| 62 | set_default VICTORY_BVH_MISS 1 | ||
| 63 | set_default VICTORY_CARD_BUFFERS_MIN_MB 1 | ||
| 64 | set_default VICTORY_CARD_BUFFERS_MB 1536 | ||
| 65 | set_default VICTORY_COMPOSE 1 | ||
| 66 | set_default VICTORY_NAN_SCRUB 1 | ||
| 67 | set_default VICTORY_AMBIENT_AIR 1.5 | ||
| 68 | set_default VICTORY_AMBIENT_MOST 2 | ||
| 69 | |||
| 70 | echo "Leonida: $console under Wine with the bundled VKD3D-Proton ($(head -n 1 "$vkd3d/SOURCE.txt" 2>/dev/null || echo bundled))" | ||
| 71 | exec wine "$victory" run "$game_exe" --execute --console "$console" | ||