upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/linux.md
diff options
context:
space:
mode:
authorNotRexed <therealnothingfn@gmail.com>2026-11-27 17:50:37 -0500
committerNotRexed <therealnothingfn@gmail.com>2026-11-27 17:50:37 -0500
commitb87abdef5735adc68a614b2025ffcf9869a47cc5 (patch)
tree0d8b473e8e753883a01e00153175994d6b7949c2 /docs/linux.md
parent84e728faffb36cd96a08934e5632ba9b194801f3 (diff)
parent34e33d3ddc4dd95ad14a074db886df3d25588201 (diff)
Merge mandy's main into port/d3d12-nvidia
Brings the D3D12 runtime branch (d3d12/, its launcher scripts and notes, and the pull requests reviewed and applied on it) together with mandy's main. Conflicts (67 files, none under d3d12/): docs/, make_game.py, runtime/, scripts/build_runtime.ps1, tests/ and tools/. Every one takes main's side: main is where that code is maintained, and this branch's copies were older states of the same files or the same pull requests in another form. tests/test_fspx_unpack.py is main's too, as it tests main's tools/fspx_unpack.py. Nothing under d3d12/ is changed by the merge. Checked before pushing: python -m compileall over make_game.py, tools and tests; make_game.py --help; scripts/check_no_game_data.py over the files this adds to main; tests/test_text_write_line_endings.py. The translator suite, the C++ runtime build and CI have not run on the result. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'docs/linux.md')
-rw-r--r--docs/linux.md175
1 files changed, 134 insertions, 41 deletions
diff --git a/docs/linux.md b/docs/linux.md
index b5d62402a..c9ea03b84 100644
--- a/docs/linux.md
+++ b/docs/linux.md
@@ -1,61 +1,154 @@
1# Leonida on Linux (D3D12 runtime) 1# Linux
2 2
3Leonida's D3D12 runtime lives under `d3d12/`, grown from the VIctory runtime (since `bafb0e25b`, trustno1-coder/VIctory-NVIDIA). It is a 3What a Linux user (x86-64, a Vulkan GPU) can do today, from one page: the build of the shaders and assets runs
4Windows program, so on Linux it runs under Wine. Its Direct3D 12 comes from **VKD3D-Proton**, which translates D3D12 4natively, the Vulkan test tools build natively with GCC or Clang, and the loader (`gta6rt`) is a Windows program that
5to Vulkan. VKD3D-Proton ships inside the Linux package, so players download nothing else for D3D12. 5runs under Wine or Proton. Nothing is playable on any platform yet (README, *Project status*).
6 6
7## What a player needs 7The package names below were checked on Ubuntu 26.04 LTS. Other distributions have the same tools under their own
8names; the build lists anything it can't find before it starts.
8 9
9- Wine (the distribution's `wine` package, or Proton's), 64-bit. 10## What runs where
10- A Vulkan driver: Mesa (AMD, Intel) or NVIDIA's.
11- Their own copy of the game.
12 11
13## What the package holds 12| Piece | On Linux | How it is checked |
13|---|---|---|
14| `make_game.py`: check, shaders, assets, pipelines | Native | CI (`stdlib-tests-linux`, `translator-tests`, `semantic-tests`) |
15| `Build.sh`, `Mods.sh` | Native (`/bin/sh`) | `tests/test_shell_launchers.py`, in the standard-library loop of `stdlib-tests-linux` |
16| Shader translator, its tests and the GPU test tools (`vk_harness`, `vk_pipeline_check`, ...) | Native, GCC or Clang | CI (`linux-gpu-tools`: GCC, tests on llvmpipe); Clang builds them too, but no CI job uses it yet |
17| `rpf9dump` (asset export) | Native, .NET 8 or newer | CI builds it on Windows only (the `check` job) |
18| `gta6rt`, its shims and their tests | Windows program, under Wine or Proton | Cross-built with clang-cl and xwin; CI runs the Windows build under Wine on pushes to `main` |
19| `scripts/run_game_wine.sh`: one retail run under Wine, headless or visible, counts only ([linux_proton.md](linux_proton.md#running-the-game-under-wine-with-one-command)) | Native (`bash`) around the Windows `gta6rt` | `tests/test_run_game_wine.py` and `tests/test_game_run_summary.py`, without the game |
14 20
15| Path | What | 21## Build the port
16| --- | --- |
17| `leonida.exe` | The Windows build of `d3d12/` (Leonida's D3D12 runtime) (`cargo build --profile diag -p leonida --features diagnostics`) |
18| `play-linux.sh` | `scripts/play-linux.sh`: the launcher |
19| `vkd3d-proton/d3d12.dll`, `d3d12core.dll` | VKD3D-Proton 3.1, 64-bit, unmodified |
20| `vkd3d-proton/LICENSE`, `COPYING`, `SOURCE.txt` | Its LGPL-2.1 text, notice, and where its source is |
21 22
22The package's `vkd3d-proton/` folder is made with: 23Install the prerequisites (Ubuntu 26.04; the comment says what each is for):
23 24
24```sh 25```sh
25python -I scripts/fetch_vkd3d_proton.py --out dist/linux/vkd3d-proton 26sudo apt install git python3 \
27 llvm-21 spirv-tools \
28 dotnet-sdk-10.0 \
29 cmake ninja-build g++ libvulkan-dev \
30 ffmpeg zenity python3-tk
31# git, python3 the clone and make_game.py (Python 3.12 or newer)
32# llvm-21, spirv-tools the shaders stage: llvm-mc with the AMDGPU target, spirv-as and spirv-val
33# dotnet-sdk-10.0 the assets stage builds rpf9dump; Ubuntu 26.04 packages no .NET 8 SDK, and 10 builds the
34# net8.0 project through global.json's roll-forward
35# cmake ... libvulkan-dev the pipelines stage builds vk_pipeline_check
36# ffmpeg optional: XMA2 audio and --wav
37# zenity, python3-tk optional: the --pick folder dialog and the mod manager window
26``` 38```
27 39
28It downloads the pinned release, checks every file against the SHA-256 in the script, and extracts the two 64-bit DLLs. 40Then, with your own copy of the game already readable on disk:
29It needs Python 3.14 or newer, for `compression.zstd`. `dist/` is not committed.
30 41
31## What the launcher does 42```sh
43git clone --recursive https://github.com/ubiquitarianism/leonida
44cd leonida
45./Build.sh --find # list the copies found: the home folder, Downloads, Documents, /mnt, /media/<user>, ...
46./Build.sh --check # check your copy, build nothing
47./Build.sh # build into ~/Documents/Leonida
48```
49
50`./Build.sh` is `python3 -I make_game.py` with the newest Python 3.12+ it finds, so every `make_game.py` option in
51the README works with it (`--game`, `--out`, `--work`, `--stages`, ...). Without the cross-build tools below, the
52default stages leave `runtime` out (`check,shaders,assets,pipelines`).
53
54Notes:
55
56- **llvm-mc**: Debian and Ubuntu's `llvm-21` installs it only as `llvm-mc-21` and `/usr/lib/llvm-21/bin/llvm-mc`.
57 With `LLVM_MC` unset the tools use the plain `llvm-mc` when it is on `PATH` and otherwise the newest of those
58 versioned names (`tools/mc_command.py`). Set `LLVM_MC` to choose another one.
59- **File names are case-sensitive.** The build opens the package's files by their exact names
60 (`MicrosoftGame.Config`, `Catalog000.bin`, ...). A copy whose names changed case on the way is reported with the
61 name it found and the one it needs; nothing is renamed for you.
62- **Mods**: `./Mods.sh` opens the mod manager window ([modding.md](modding.md)); `python3 -I tools/leonida_mods.py`
63 is the same manager on the command line.
64
65## The runtime, under Wine or Proton
66
67`gta6rt` is a Windows program. To build it on Linux, add the LLVM cross tools and an MSVC CRT and Windows SDK laid
68out by [xwin](https://github.com/Jake-Shadle/xwin) (running xwin downloads them from Microsoft and means accepting
69Microsoft's licence):
32 70
33```sh 71```sh
34./play-linux.sh /path/to/game_scarlett_master.exe [--series-x] 72sudo apt install clang-21 lld-21 llvm-21 wine
73xwin --accept-license --sdk-version 10.0.26100 splat --use-winsysroot-style --preserve-ms-arch-notation \
74 --output ~/.local/share/xwin-sdk
75./Build.sh --stages runtime
35``` 76```
36 77
37- **Wine prefix:** it uses Leonida's own (`LEONIDA_WINEPREFIX`, default `~/.local/share/leonida/prefix`) and makes it 78On Ubuntu 24.04, `clang-cl-<N>` is in `clang-tools-<N>` instead ([testing.md](testing.md#known-problems)).
38 on the first run. No other prefix is touched. 79`make_game.py` finds the five tools under one version suffix (`clang-cl-21`, `lld-link-21`, `llvm-lib-21`,
39- **D3D12:** it copies the bundled `d3d12.dll` and `d3d12core.dll` into that prefix's `system32` when they are 80`llvm-rc-21`, `llvm-mt-21`) or their plain names. Without the SDK it lists what is missing before any work starts.
40 missing or changed, and sets `WINEDLLOVERRIDES=d3d12,d3d12core=n` so Wine uses them. 81`--runtime-build <folder>` takes a Windows build made elsewhere instead, such as the `runtime-windows` artifact of the
41- **Game files:** it points `LEONIDA_GAME_DIR` at the game's folder. Caches and saves go to 82Runtime workflow. The stage writes `<out>/gta6rt.sh`, which starts `gta6rt.exe` with `wine` or the Wine named by `WINE`
42 `~/.local/share/leonida/{cache,data}`. 83(for Proton, its `files/bin/wine`); README, *Running the loader on Linux*, has the commands.
43- **Settings:** it uses the measured NVIDIA settings of `scripts/play-nvidia.ps1` as defaults; any `LEONIDA_*` you set 84[testing.md](testing.md#the-windows-runtime-on-linux-under-wine-or-proton) has the test runs under Wine and Proton
44 wins. 85and what fails there.
45- **Start:** it runs `wine leonida.exe run <exe> --execute --console series-s`, or `series-x` with `--series-x`. 86
87For XMA2 audio, `runtime/CMakeLists.txt` builds `runtime/xma_decoder` for `x86_64-pc-windows-msvc` when `cargo` is on
88`PATH`. Distribution Rust packages typically omit the Windows MSVC standard library, which leaves XMA voices silent
89unless you add the `x86_64-pc-windows-msvc` Rust target or pass a prebuilt static library with
90`-DLEONIDA_XMA2_DECODER_LIB=<path>`, built yourself from this checkout's `runtime/xma_decoder` with the command in
91[runtime/xma_decoder/README.md](../runtime/xma_decoder/README.md).
92
93### Why there is no native Linux `gta6rt`
94
95A native (ELF) loader is not a matter of build flags:
46 96
47On Windows nothing changes: the DLLs live only in the Linux package's `vkd3d-proton/` folder and never sit next to a 97- The loader shims only the console's own modules and a few Win32 entry points it has to own (GDK, XMem,
48Windows `leonida.exe`. 98 `d3d12_xs`, the library loader, the process and file-system shims). Every other import binds to the host's Windows
99 DLLs unchanged (`runtime/src/pe_loader.cpp`; [runtime_imports.md](runtime_imports.md): `XboxBvhBuilder.dll`
100 alone binds 4 imports to shims and 53 to the host). On Linux, those host DLLs are what Wine provides.
101- The mapped code uses the Windows x64 calling convention and the Windows thread and exception model: the loader
102 registers unwind tables with `RtlAddFunctionTable`, keeps a module TLS slot through `gta6rt_tls_host.dll`, and
103 `main.cpp` installs a vectored exception handler. The shims are written against `windows.h`.
49 104
50## Licences 105A Linux-native host would have to reimplement each of those Win32 APIs, which is the work Wine already does, so the
106supported way is the Windows build under Wine or Proton with the D3D12 layer on native Vulkan. What does build
107natively is everything that doesn't touch Win32: the Vulkan tools and the portable runtime pieces with their tests
108(`ctest` on a Linux build runs them, including the root-signature model and the host CPU check).
51 109
52VKD3D-Proton is LGPL-2.1-or-later and VIctory is GPL-3.0-or-later; shipping the unmodified DLLs beside the GPL program, 110## Build and test without the game
53with VKD3D-Proton's license and a pointer to its source (`SOURCE.txt`), meets the LGPL's terms for distributing the
54library.
55 111
56## Not tested yet 112```sh
113cmake -S runtime -B runtime/build/linux -G Ninja # CC=clang CXX=clang++ for Clang
114cmake --build runtime/build/linux --parallel
115ctest --test-dir runtime/build/linux --output-on-failure # Vulkan tests run on Mesa's lavapipe without a GPU
116python3 -I scripts/run_semantic_tests.py tests/semantic # translator suite
117python3 -I tests/test_<name>.py # one standard-library test
118```
119
120[testing.md](testing.md) covers the GPU tests (`scripts/run_gpu_tests.py`), running them on llvmpipe, and choosing
121the GPU.
122
123### Without root (micromamba)
124
125If you cannot install distribution packages (no `sudo`), you can install `llvm-tools` and `spirv-tools` into a
126user-owned folder with [micromamba](https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html)
127(x86-64 glibc; for ARM64 use `linux-aarch64` from the micromamba guide; musl/Alpine is not natively supported) and let
128CMake fetch its pinned, hash-checked Vulkan headers if the system does not provide them:
129
130```bash
131LEO=$HOME/leonida-tools
132mkdir -p "$LEO/bin" "$LEO/mamba"
133# Note: `latest` is unpinned and downloaded without signature verification; inspect or pin per the micromamba guide.
134curl -fsSLo "$LEO/micromamba.tar.bz2" https://micro.mamba.pm/api/micromamba/linux-64/latest
135tar -xjf "$LEO/micromamba.tar.bz2" -C "$LEO/bin" --strip-components=1 bin/micromamba
136
137export MAMBA_ROOT_PREFIX="$LEO/mamba"
138"$LEO/bin/micromamba" create -y -n leonida -c conda-forge --override-channels "llvm-tools>=21" spirv-tools
139export PATH="$LEO/mamba/envs/leonida/bin:$PATH"
140
141cmake -S runtime -B runtime/build/linux -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_VULKAN_HEADERS_FETCH=ON
142cmake --build runtime/build/linux --parallel "$(nproc)"
143LLVM_MC=llvm-mc LEONIDA_VK_DEVICE="<part of your GPU name>" \
144 python3 -I scripts/run_gpu_tests.py --build runtime/build/linux --work "$LEO/run" --require-pass | tee "$LEO/run.log"
145echo "runner exit: ${PIPESTATUS[0]}"
146```
57 147
58- The launcher has been syntax-checked (`sh -n`) only, not run on a Linux machine. 148Notes:
59- The Windows build under Wine has not been run either. 149- `LEONIDA_VK_DEVICE` selects the physical GPU by substring so the runner does not fall back to Mesa's `llvmpipe`.
60- Whether the D3D12 features the game needs (Shader Model 6.6, mesh shaders) all work through VKD3D-Proton 3.1 on a 150- Keep `$LEO` on a filesystem without `noexec` (`findmnt -no OPTIONS "$LEO"`).
61 given driver is still to be measured. 151- System prerequisites still needed: a working Vulkan driver/loader (`vulkaninfo --summary`), `cmake`, `ninja`, `g++`
152 (or `clang++`), `python3`, `curl`, `tar`, and `bzip2`.
153- Cleanup: delete `$LEO` and `runtime/build/linux`. micromamba also writes `~/.conda/environments.txt` and
154 `~/.mamba/pkgs/urls.txt` (delete only those files if you already use conda).