Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ translates every shader again. A `disasm` folder that is a symlink is refused wh
|---|---|---|---|---|
| your package | `--game` | your copy of the game; only read, never written | as copied | yes, in place (`game_path.txt`) |
| work | `--work` (default `<out>\work`) | `shaders` (carved, disassembled, translated) and `assets` (exports) | about 30 GB + about 370 GB | only `shaders\spirv` (`shader_path.txt`) |
| port | `--out` (default `Documents\Leonida`) | `gta6rt.exe`, its DLL, the path files, the pipeline cache, `overlay` | small | yes |
| port | `--out` (default `Documents\Leonida`) | `gta6rt.exe`, its DLL, the path files, `pipeline_cache.d`, `overlay` | small | yes |

The free-space check before a build counts the `--work` drive only, because that is where the large files go.
Nothing in `<work>\assets` is read by the game, so with a small SSD you can keep what the game loads on the SSD and
Expand Down Expand Up @@ -221,11 +221,10 @@ upgrading.

Stages: `check` always runs first; then `shaders`, `assets` and `runtime` run together when selected (they do not
depend on each other). `pipelines` starts once the translated shaders are ready and, when this run includes runtime,
that stage has finished rebuilding `vk_pipeline_check`, so it can overlap the rest of assets; it creates every
translated shader on your GPU driver, reports any it has to skip, and saves a pipeline cache to `pipeline_cache.bin`
in `--out`, which also holds `gta6rt.exe` after the `runtime` stage. The runtime seeds its Vulkan pipeline cache
from the file beside the executable when its header matches the device and pipeline cache UUID. It falls back to
an empty cache if the file is missing, incompatible, or rejected by the driver. Shader translation is the longest
that stage has finished building `gta6rt.exe`, so it can overlap the rest of assets; it runs
`gta6rt.exe --precompile-pipelines` (under Wine off Windows) to fill the runtime's own compute pipeline journal in
`pipeline_cache.d` under `--out`, and reports any failures or crashing entries (writing `pipeline_crashes.json` if
any entry crashed the driver). Shader translation is the longest
CPU step. It runs on `--jobs` processes (half the CPU threads by default). When shaders and assets share the machine,
that budget is split between them and passed to `rpf9dump` as `--jobs`. A solo assets run still lets `rpf9dump` use
every core. Progress lines include percent and a rough ETA for translation shards, asset steps, and overall stage
Expand All @@ -250,8 +249,8 @@ cmake --build runtime/build/linux --parallel

Pass the directory containing `index.json` and the translated SPIR-V files to `vk_pipeline_check`.

`make_game.py` runs on Linux too. The `pipelines` stage uses the `vk_pipeline_check` built above
(`runtime/build/linux`, or `runtime/build`), and builds it there itself before any other work if it is missing.
`make_game.py` runs on Linux too. Its `pipelines` stage runs `gta6rt.exe --precompile-pipelines` under Wine
(honouring `WINE`) to populate `<out>/pipeline_cache.d`, rather than `vk_pipeline_check`.

### Running the loader on Linux

Expand Down
6 changes: 3 additions & 3 deletions docs/d3d12_vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -2637,7 +2637,7 @@ Pipeline creation:
- Request the subgroup size each shader was translated for (`requiredSubgroupSize` 64 or 32) where the device lists the stage
in `requiredSubgroupSizeStages`, and say so in the log where it cannot (section 3.2, "Subgroup size").
- Pipeline caches: graphics and compute PSOs use one `VkPipelineCache` per device. On first use the runtime reads
the `pipelines` build stage's `pipeline_cache.bin` beside the executable if its Vulkan header matches the device
an offline `pipeline_cache.bin` beside the executable if its Vulkan header matches the device
and pipeline-cache UUID. When the file is absent or incompatible, the runtime starts with an empty cache.
The offline checker matches the runtime's layout and subgroup request for compute shaders with no descriptor
bindings and the standard 144-byte push-constant range.
Expand Down Expand Up @@ -2713,8 +2713,8 @@ Pipeline creation:
folders can share one; the file names and the driver's checks keep a pipeline from one build from being taken
for another's.
`gta6rt --precompile-pipelines [--threads N] [--big-threads N] [--all] [--smallest-first] [--limit N]
[--min-bytes N] [--max-bytes N] [--filter PART]... [--skip-listed] [--list]` fills the journal ahead of play, with
no game: it
[--min-bytes N] [--max-bytes N] [--filter PART]... [--skip-listed] [--list]` (which `make_game.py --stages
pipelines` runs) fills the journal ahead of play, with no game: it
creates the Vulkan device as `--run` does (so the same environment gives the same journal names and driver keys:
LEONIDA_SHADERS, LEONIDA_PIPELINE_CACHE_DIR, and LEONIDA_DEVICE_FAULT/LEONIDA_AFTERMATH, whose diagnostics config
makes other pipelines) and builds every compute entry of the library through the dispatch path
Expand Down
8 changes: 4 additions & 4 deletions docs/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ names; the build lists anything it can't find before it starts.

| Piece | On Linux | How it is checked |
|---|---|---|
| `make_game.py`: check, shaders, assets, pipelines | Native | CI (`stdlib-tests-linux`, `translator-tests`, `semantic-tests`) |
| `make_game.py`: check, shaders, assets | Native | CI (`stdlib-tests-linux`, `translator-tests`, `semantic-tests`) |
| `Build.sh`, `Mods.sh` | Native (`/bin/sh`) | `tests/test_shell_launchers.py`, in the standard-library loop of `stdlib-tests-linux` |
| 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 |
| `rpf9dump` (asset export) | Native, .NET 8 or newer | CI builds it on Windows only (the `check` job) |
Expand All @@ -32,7 +32,7 @@ sudo apt install git python3 \
# llvm-21, spirv-tools the shaders stage: llvm-mc with the AMDGPU target, spirv-as and spirv-val
# dotnet-sdk-10.0 the assets stage builds rpf9dump; Ubuntu 26.04 packages no .NET 8 SDK, and 10 builds the
# net8.0 project through global.json's roll-forward
# cmake ... libvulkan-dev the pipelines stage builds vk_pipeline_check
# cmake ... libvulkan-dev optional: standalone native Vulkan test tools (vk_harness, vk_pipeline_check)
# ffmpeg optional: XMA2 audio and --wav
# zenity, python3-tk optional: the --pick folder dialog and the mod manager window
```
Expand All @@ -48,8 +48,8 @@ cd leonida
```

`./Build.sh` is `python3 -I make_game.py` with the newest Python 3.12+ it finds, so every `make_game.py` option in
the README works with it (`--game`, `--out`, `--work`, `--stages`, ...). Without the cross-build tools below, the
default stages leave `runtime` out (`check,shaders,assets,pipelines`).
the README works with it (`--game`, `--out`, `--work`, `--stages`, ...). Without the cross-build tools below (or
`--runtime-build`), the default stages leave `runtime` and `pipelines` out (`check,shaders,assets`).

Notes:

Expand Down
12 changes: 7 additions & 5 deletions docs/linux_proton.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ scripts/linux-boot/configure-worktree.sh <checkout> # XWIN_DIR=<sdk>, SDL3_
cmake --build <checkout>/runtime/build/boot --target gta6rt -j6
```

`gta6rt_tls_host.dll` is built with the `gta6rt` target and must stay next to the executable. Unit tests are Windows
executables too and run under Wine (`scripts/run_wine_tests.py`, or directly with the same `wine` binary and a
prefix of their own: sharing the game's prefix with tests breaks its window).
`gta6rt_tls_host.dll` is built with the `gta6rt` target and must stay next to the executable. `make_game.py --stages pipelines`
runs `gta6rt.exe --precompile-pipelines` under Wine (honouring `WINE`) to fill `<out>/pipeline_cache.d/`. Unit tests
are Windows executables too and run under Wine (`scripts/run_wine_tests.py`, or directly with the same `wine` binary
and a prefix of their own: sharing the game's prefix with tests breaks its window).

## Booting on Linux

Expand Down Expand Up @@ -194,13 +195,14 @@ they were found.
translator no longer does that for single-wave programs ([design.md](design.md), row "Wave64 emulation:
single-wave barrier fallback").
The auto mode now leaves CPU devices out when a GPU is listed and names the device that decided.
3. **Fill the pipeline journal with the runtime itself.** `gta6rt --precompile-pipelines --threads 16`, under Wine,
3. **Fill the pipeline journal with the runtime itself.** `make_game.py --stages pipelines` (or
`gta6rt --precompile-pipelines --threads 16` directly), under Wine,
with the environment of the game run (`LEONIDA_SHADERS`, `LEONIDA_PIPELINE_CACHE_DIR`, `LEONIDA_DEVICE_FAULT`;
`--precompile-pipelines` in [d3d12_vulkan.md](d3d12_vulkan.md)). It built 3,693 compute pipelines; the next boot took
1,900 of them from the journal in 0.1 s of driver time, and the menus ran at 30 frames/s instead of under one.
That run left out the programs `LEONIDA_SKIP_COMPUTE` named, which kept them out of the journal; the pre-compile
now builds them too unless it is given `--skip-listed`.
The `pipeline_cache.bin` that `make_game.py`'s pipelines stage writes with `vk_pipeline_check` gave no hits: 0 of
The `pipeline_cache.bin` that `make_game.py`'s pipelines stage previously wrote with `vk_pipeline_check` gave no hits: 0 of
5,526 journal pipeline keys were in its 29,861 objects (9 shader binaries were identical, so the machine code
matched and the keys did not). Each of three differences is enough for a miss on RADV:
- **The set of shaders:** the runtime's warm-up builds the library's compute programs (`library/index.json`,
Expand Down
54 changes: 18 additions & 36 deletions docs/pipeline_check.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Build with `make_game.py --stages shaders --compact-spirv` to run SPIRV-Tools lo
| `--stats FILE` | Write the driver's per-shader statistics as CSV rows `name,stage,statistic,value`. Needs `VK_KHR_pipeline_executable_properties`; use it without `cache.bin`, because a cached pipeline may come without statistics. |
| `--cache-feedback` | Group successful pipeline creations by `VkPipelineCreationFeedback`: cache hits, no hit reported, and unavailable. |
| `--isolate` | POSIX only: check in child processes, `--isolate-batch N` modules at a time (default 256), so a crashing module is recorded as `MODULE CRASH` and the pass continues. Not compatible with `--stats`. |
| `--inflight-file F` | Keep the modules currently in the driver in F as `name<TAB>phase` lines. It is rewritten by the watchdog and when a large module enters or leaves, and emptied at the end; `make_game.py`'s pipelines stage reads it. |
| `--skip-file F` | Do not compile modules named one per line in F; each is reported as `MODULE CRASH` and counted as a failed pipeline. `make_game.py` writes F after a crash so the next run checks the rest. |
| `--inflight-file F` | Keep the modules currently in the driver in F as `name<TAB>phase` lines. It is rewritten by the watchdog and when a large module enters or leaves, and emptied at the end. |
| `--skip-file F` | Do not compile modules named one per line in F; each is reported as `MODULE CRASH` and counted as a failed pipeline. |

`--isolate-child` is internal to the parent/child protocol and is not meant to be passed directly. A module with a missing partner stub is skipped; without `--isolate`, a driver crash ends the run.

Expand Down Expand Up @@ -283,7 +283,7 @@ of the arenas (16 modules, 6 threads: 6.2 GB; with `MALLOC_ARENA_MAX=1`: 2.1 GB)
- `--large-parallel N` caps how many large modules compile at once: `0` (default) by the budget, `1` alone with
the other threads waiting (the behaviour before), `N` at most N without a budget.
- `--inflight-file` names every module in flight when a large one enters or leaves the driver, so with several
large modules in flight it names all of them; the `pipelines` stage of `make_game.py` checks each alone.
large modules in flight it names all of them.

## Skipping huge modules

Expand Down Expand Up @@ -344,39 +344,21 @@ the loader's `cl` line in `scripts/build_runtime.ps1`). The CTest `gta6rt_stack`
with `dwStackSize` 0 both report 8 MB. Not covered: a thread the title creates with an explicit smaller size keeps
that size. Which threads the game creates pipelines on is not known without its executable.

## Build-stage batches (BUILD-1030)

`make_game.py` runs the pipelines stage in fresh checker processes over at most **500 index entries** each, on
Windows and POSIX. The ranges partition the same name-sorted index as `--start` / `--count`, including the final
short range. Each finished process saves to the same `pipeline_cache.bin`, and the next loads that checkpoint.
This bounds each invocation to a range that can be split further if concurrent heavy compiles exceed available
memory. A work folder with at most 500 entries keeps the single invocation. An older checker without the range
options keeps the older invocation; rebuild the runtime to get batching.

If a batch crashes, its in-flight modules are checked alone in fresh processes. A module that reproducibly crashes
is recorded as failed, and the rest is checked. If none crashes alone, the entire failed range is retried in
smaller processes, down to one entry; healthy modules are not added to the crash list. An unrecoverable crash,
an interrupted check or a setup error stops the stage. A validation failure in one batch remains a failure even
when subsequent batches succeed; it does not prevent those later batches from being checked.

The native checker returns 1 for initialization failures as well as validation failures. A completed shader pass
writes/clears its in-flight report even when validation fails. Exit 1 without a new report stops the stage instead
of repeating failed setup for the remaining batches; diagnostic probes use the same distinction. Each process
starts with a cleared report path, so an earlier process's report cannot hide an initialization failure.

An abnormal diagnostic-probe exit confirms a module crash only when that probe's fresh in-flight report names
the selected module. A missing, empty or unrelated report makes the result inconclusive and stops the stage
without blaming that module. The native report is periodic for small modules, so even a real fast crash can
leave no evidence; this conservative fallback does not guess its cause or add an unconfirmed crash-list entry.

The batch size limits the index range, **not total memory usage**. Concurrent heavy modules, loading a large
saved cache or compiling one large shader can still exceed a process's available memory; a range that
cannot complete even alone fails with a diagnostic rather than being counted as checked.

`tests/test_make_game_pipeline_batches.py` runs the real build-stage orchestration against scripted child processes:
bounded coverage and cache checkpoints, collective memory-crash recovery, a genuinely crashing module, validation
failures, interruptions, setup failures, inconclusive probes and compatibility with older checkers. It needs no
game files or GPU.
## Relationship to `make_game.py --stages pipelines`

`make_game.py`'s `pipelines` stage no longer drives `vk_pipeline_check`: it runs `gta6rt.exe --precompile-pipelines`
(directly on Windows, or under `WINE` / `wine` elsewhere) so the stage populates the runtime's own compute pipeline
journal in `<out>/pipeline_cache.d` with matching device features and driver keys. If a driver crash kills `gta6rt`
mid-build, `make_game.py` retries up to `PIPELINE_CRASH_RETRIES` times so the runtime can move stale entries from
`pipeline_cache.d/requests/inflight.txt` to `requests/crashed.txt` and skip them, then writes `<out>/pipeline_crashes.json`.
A crash is held against that module file on that device and driver: once the module is translated again or the
driver changes, the next run builds it again, and a build that returns clears it from the list.
`gta6rt --precompile-pipelines --all` tries every recorded entry again now. Exit 3 means another precompile holds
the journal folder (`requests/precompile.lock`). For tests, `LEONIDA_PRECOMPILE_CRASH_TEST=<entry name>` ends the
precompile just before that entry's pipeline create, as a driver crash there would.

`vk_pipeline_check` remains a standalone diagnostic tool (and CI test binary) for corpus-wide module/pipeline checks,
Mesa DRM-shim profiling, `--stats`, `--cache-feedback`, and `--isolate` crash bisection.

## Crash isolation (`--isolate`)

Expand Down
5 changes: 3 additions & 2 deletions docs/running.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ reasons behind each step: [linux_proton.md](linux_proton.md#amd-on-linux-what-go
with SDL3 for the keyboard pad.
- **Shaders:** `python -I make_game.py --stages shaders --wave64-emulate off --work <work> --out <out>`. The GPU runs
wave64 natively; emulation is not needed. (`auto` picks the same here since llvmpipe no longer decides.)
- **Pipeline pre-compile:** `wine <build>/gta6rt.exe --precompile-pipelines --threads 16` with the run's
- **Pipeline pre-compile:** `make_game.py --stages pipelines` (which runs `gta6rt.exe --precompile-pipelines` under
Wine off Windows), or `wine <build>/gta6rt.exe --precompile-pipelines --threads 16` directly, with the run's
`LEONIDA_SHADERS`, `LEONIDA_PIPELINE_CACHE_DIR` and `LEONIDA_DEVICE_FAULT`, before the first run. It built 3,693
compute pipelines. Not `make_game.py --stages pipelines`: its cache never matches the runtime's driver keys.
compute pipelines. `make_game.py --stages pipelines` now runs this pre-compile.
The pre-compile builds the programs `LEONIDA_SKIP_COMPUTE` names too (`--skip-listed` leaves them out) and ends
with one line that counts what it built, what was journaled already and what it left out.
- **Driver and OS:** `amdgpu.lockup_timeout=30000,60000,10000,10000` on the kernel command line (the default is
Expand Down
Loading
Loading