Skip to content
Merged
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
7 changes: 4 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ Shard runs write `index.part*.json`; merge them into `index.json` with `--merge`
## Conventions

- Python tools run with `python -I` and use only the standard library unless a file says otherwise; the exceptions
are the texture and model tools that import numpy or Pillow: `bc_feature.py`, `amd_swizzle.py`, `tile_probe.py`,
`swizzle_search.py`, `tex_export.py`, `tex_mode_probe.py`, `calibrated_texture.py`, `world_grid_atlas.py`,
`tex_headers.py` and `skinned_glb.py` (which fall back to the standard library when numpy is absent).
are the texture, model and control tools that import numpy or Pillow: `bc_feature.py`, `amd_swizzle.py`,
`tile_probe.py`, `swizzle_search.py`, `tex_export.py`, `tex_mode_probe.py`, `calibrated_texture.py`,
`world_grid_atlas.py`, `port_ctl.py`, `tex_headers.py` and `skinned_glb.py` (the last two fall back to the
standard library when numpy is absent).
- A text file a tool writes names its line ending - `open(path, "w", encoding="utf-8", newline="\n")` - so the same
input gives the same bytes on every platform; `tests/test_text_write_line_endings.py` catches a writer that forgets.
- Keep `make_game.py` working on Windows first: paths through `os.path`, no bash in the build.
Expand Down
2 changes: 1 addition & 1 deletion d3d12/docs/replay.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ targets (where the viewport has the picture's shape), dispatches and draws with
the textures of the picture's shape shaders may write at that time, copies,
resolves and clears. `--of` is the size of the picture the point was read from
(a screenshot's). The commands are numbered `<list>:<command>` as in
`--listing`, `--slots` and `--looks`.
`--listing`, `--slots` and `--flow`.

| switch | does |
|---|---|
Expand Down
2 changes: 1 addition & 1 deletion docs/port_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ translate it.

- `apps/victory/src/native_1440p.rs`, `fsr_preset.rs`: the title told a 1440p
display with FSR at Quality: the display-mode lever (`port/present`).
- `crates/victory-hle/src/modules/fidelityfx.rs` (+ `tests/fidelityfx.rs`): the
- `crates/victory-hle/src/modules/fidelityfx.rs` (+ `crates/victory-hle/tests/fidelityfx.rs`): the
title's `amd_fidelityfx_upscaler_xbox.dll` served on the host; Leonida's
shader stage translates only 18 of the 29 FidelityFX programs.
- `crates/victory-gpu/src/texture/ahead.rs`, `texture/upload.rs`, `tiles.rs`,
Expand Down
10 changes: 6 additions & 4 deletions docs/port_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ is on), so title GPU memory can live in VRAM and still be written by the CPU.
just before its first `SetFrameIntervalX`, but 1920x1080 (also at 120 Hz,
also with `LEONIDA_DEVICE_TYPE=6`) leaves both at 3840x2160. The size is the
executable's Series X SDR mode: VIctory upstream's native 1440p profile
(`native_1440p.rs`), ported as `runtime/src/display_profile.h`, patches it
(`native_1440p.rs`, ported on an unmerged `runtime/` branch as `display_profile.h`
and later into `d3d12/crates/leonida-loader/src/hooks.rs`) patches it
and three related places in the mapped image, and with
`LEONIDA_DISPLAY_MODE=2560x1440` the window and both back buffers are
2560x1440 (`LEONIDA_RENDER_SCALE=0.75` renders 1080p into it). Other sizes
Expand Down Expand Up @@ -218,7 +219,7 @@ is on), so title GPU memory can live in VRAM and still be written by the CPU.
writes when it gets there, the system timestamp the performance counter
once the submission has run. The real title cannot exercise them yet: it
stops at its render-target pool check before its first frame.
- Time step (`port/frame-timing`, `runtime/src/frame_step.h`): the title's
- Time step (unmerged `port/frame-timing` branch, `frame_step.h`): the title's
timer (+0x22264d0, once a frame) steps its time sets by the measured
QueryPerformanceCounter delta held to [1/30 s, 1/15 s]: the floor is
1 / the target frame rate (+0x6849844, from the graphics settings), the cap a
Expand Down Expand Up @@ -379,8 +380,9 @@ scope instead. Measured in run 103:
- draws stopped at about 180 s;
- the write to 0 came at 211 s, from `game+0x2215c35` through the hook to `game+0x23cf683`.

So the earlier runs that set that budget to delay "the device loss" were what caused it. The budget is now cut to 10 s
(`kMaxWaitMs` in `runtime/src/pipeline_queue.h`), and runs use the default 500 ms. GPU-assisted validation (run 102,
So the earlier runs that set that budget to delay "the device loss" were what caused it. The wait cap was later cut
to 10 s (and the pipeline-wait coordination now lives in `runtime/src/pipeline_wait.h`), with runs using the default
500 ms budget. GPU-assisted validation (run 102,
30 minutes) reported nothing but the known sparse-bind message.

Still unexplained in the same load:
Expand Down
40 changes: 32 additions & 8 deletions docs/running.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@ Paths are placeholders: `<checkout>` is the repository, `<build>` the folder wit
`<work>/shaders/spirv/library/index.json`), which drops their dispatches at play, and `LEONIDA_RT_AS=off`, which
drops acceleration-structure builds. The picture then lacks what they draw.

## Recommended variables (all platforms)

Beyond the required platform settings above, these runtime variables (all documented in
[runtime/README.md](../runtime/README.md)) are recommended for smoother start-up, faster pipeline compilation and
better fault diagnostics on current `main`:

| Setting | Default | Why |
|---|---|---|
| `LEONIDA_SUBMIT_ASYNC=4` | `0` | Moves command-list replay, before-submission refreshes and `vkQueueSubmit` off the title's submitting thread onto per-queue worker threads (up to 4 batches queued). |
| `LEONIDA_ASYNC_PIPELINES=1` | `0` | Builds pipelines on the compile pool instead of blocking draws (pair with `LEONIDA_ASYNC_MIN_BYTES=2097152` and optionally `LEONIDA_ASYNC_MIN_BYTES_GRAPHICS=0` to keep small compute lighting/post passes synchronous while large ray-tracing or graphics pipelines build asynchronously; use `=0` when every pipeline is already pre-compiled and you want zero skipped draws). |
| `LEONIDA_COMPILE_THREADS=16`, `LEONIDA_COMPILE_HEAVY_MAX=14` | half logical cores (2-8) / `threads-1` | Scales parallel pipeline compilation on high-core-count CPUs (adjust to available cores and RAM; pair with `LEONIDA_SERIAL_BIG_COMPILES=0`). |
| `LEONIDA_COMPUTE_WARMUP_MAX_BYTES=8388608`, `LEONIDA_COMPUTE_WARMUP_LIVE_MAX_BYTES=131072` | `8388608` / unset | Bounds speculative warm-up module size and holds back large warm-ups while the title is actively submitting so warm-ups do not starve live frames. |
| `LEONIDA_HEAVY_PIPELINE_CACHE_MS=0` | `0` | Keeps pipeline-cache lookups active for heavy modules instead of bypassing the cache after a threshold. |
| `LEONIDA_STARTUP_CACHE_CHECKPOINTS=1` | unset | Periodically saves pipeline-cache session checkpoints during boot so progress is preserved if a run stops early. |
| `LEONIDA_ARENA_MB=4095`, `LEONIDA_TITLE_WINDOWS_MB=4096`, `LEONIDA_GEOMETRY_MB=6144` | smaller defaults | Room for the title's buffers in the world on 16-24 GB GPUs (reduce on 8 GB cards; with sparse binding the arena size is address range and memory is bound on demand). |
| `LEONIDA_KEYBOARD_PAD=always`, `LEONIDA_RUMBLE=0` | unset / on | Exposes the keyboard as player 1 when no gamepad is attached and disables rumble/haptics overhead. |
| `LEONIDA_DEVICE_FAULT=1`, `LEONIDA_DEVICE_MARKERS=1` | unset | Enables device-loss/stall reports and (on AMD / `VK_AMD_buffer_marker`) per-draw/dispatch GPU markers to pinpoint hangs. |
| `LEONIDA_TITLE_HUD=1` or `LEONIDA_DEV_OVERLAY=1` | unset | Live frame rate, frame time, submission phases, pipeline-compile counts and VRAM/RAM usage on screen. |
| `LEONIDA_GPU_LATENCY=1`, `LEONIDA_MEM_PROBE=30` | unset | Periodic per-queue GPU latency (every 10 s) and VRAM breakdown by consumer (every 30 s) in the runtime log. |

## Linux, Wine, AMD RX 7900 XTX (RADV)

Measured by us on 2026-11-26: RX 7900 XTX, Ryzen 9 7950X3D, Linux 7.3, Mesa 26.3.1 (RADV), Wine. Details and the
Expand All @@ -59,19 +79,22 @@ reasons behind each step: [linux_proton.md](linux_proton.md#amd-on-linux-what-go
| Setting | Why |
|---|---|
| `LEONIDA_D3D12=vulkan` | the Vulkan backend |
| `MESA_VK_DEVICE_SELECT=1002:744c!` | pins the discrete RX 7900 XTX on systems that also have an integrated GPU |
| `LEONIDA_SHADERS=Z:<work>/shaders/spirv` | the native pack |
| `LEONIDA_PIPELINE_CACHE_DIR=Z:<cache>/pso` | the journal the pre-compile filled |
| `MESA_SHADER_CACHE_DIR=<cache>/mesa`, `MESA_SHADER_CACHE_MAX_SIZE=16G` | RADV's own cache, large enough for the pack |
| `LEONIDA_STARTUP_CACHE_CHECKPOINTS=1` | session cache snapshots during the boot |
| `LEONIDA_ASYNC_PIPELINES=0` | draws wait for their pipeline instead of being skipped |
| `LEONIDA_SERIAL_BIG_COMPILES=0`, `LEONIDA_COMPUTE_WARMUP_MAX_BYTES=8388608` | warm-up limits, as in the NVIDIA report below |
| `LEONIDA_SUBMIT_ASYNC=4` | offloads submission prep and `vkQueueSubmit` onto per-queue workers |
| `LEONIDA_ASYNC_PIPELINES=1` (or `=0`) | `=1` keeps first-run/streaming pipeline compiles off the draw thread (pair with `LEONIDA_COMPILE_THREADS=16`, `LEONIDA_COMPILE_HEAVY_MAX=14`); `=0` waits for every pipeline instead of skipping draws |
| `LEONIDA_SERIAL_BIG_COMPILES=0`, `LEONIDA_HEAVY_PIPELINE_CACHE_MS=0`, `LEONIDA_COMPUTE_WARMUP_MAX_BYTES=8388608`, `LEONIDA_COMPUTE_WARMUP_LIVE_MAX_BYTES=131072` | parallel big compiles with cache lookups kept active and live-frame warm-up throttling |
| `LEONIDA_RT_AS=off`, `LEONIDA_SKIP_COMPUTE=<list>` | the large ray-tracing programs, left out at play as in our longest runs ([above](#settings-every-platform-needs)) |
| `LEONIDA_TITLE_WATCHDOG=0`, `LEONIDA_TITLE_WATCHDOG_KICK=<trap RVA>,<kick RVA>` | the title's hang watchdog ([above](#settings-every-platform-needs)) |
| `LEONIDA_DEVICE_TYPE=6`, `LEONIDA_MAP_READBACK=1`, `LEONIDA_FRAME_PACING=1`, `LEONIDA_PRESENT_NO_TEAR=1` | taken over from the NVIDIA report below; their effect on AMD was not measured one by one |
| `LEONIDA_ARENA_MB=4095`, `LEONIDA_TITLE_WINDOWS_MB=4096`, `LEONIDA_GEOMETRY_MB=6144` | room for the title's buffers in the world |
| `LEONIDA_SHADOW_ALIAS_MS=5000`, `LEONIDA_CONSOLE_FIX_US=0` | carried from earlier boot runs; their effect here was not measured one by one |
| `LEONIDA_DEVICE_FAULT=1` | a device-loss report if the GPU hangs |
| `LEONIDA_KEYBOARD_PAD=always` | the keyboard as the pad |
| `LEONIDA_DEVICE_FAULT=1`, `LEONIDA_DEVICE_MARKERS=1` | device-loss/stall report plus `VK_AMD_buffer_marker` draw/dispatch attribution if the GPU hangs |
| `LEONIDA_GPU_LATENCY=1`, `LEONIDA_MEM_PROBE=30`, `LEONIDA_TITLE_HUD=1`, `LEONIDA_DEV_OVERLAY=1` | optional live telemetry and overlays |
| `LEONIDA_KEYBOARD_PAD=always`, `LEONIDA_RUMBLE=0` | keyboard as player 1 without rumble overhead |

- **Command:** from `<package>`, `wine <build>/gta6rt.exe --run Z:<exe> --game-dir Z:<package>`.
- **What to expect:** menus at 30 frames/s with no in-game compiling; the world after the story load, over eight
Expand Down Expand Up @@ -157,7 +180,8 @@ TBD.

## Reporting

Post a run in the coordination issue, with the fields of these sections: machine (OS, GPU, driver, RAM), the commit,
how the shaders were made, the pipeline pre-compile, the OS and driver settings, every `LEONIDA_*` variable that
differs from the defaults (never the watchdog's RVA values), and how far the run got with its frame rate. Keep logs,
traces and screenshots on your machine ([linux_proton.md](linux_proton.md#reporting-a-result)).
Post a `RUN` block ([agent_collaboration.md](agent_collaboration.md)) in the game-run tracking or coordination issue,
with the fields of these sections: machine (OS, GPU, driver, RAM), the commit, how the shaders were made, the pipeline
pre-compile, the OS and driver settings, every `LEONIDA_*` variable that differs from the defaults (never the
watchdog's RVA values), and how far the run got with its frame rate. Keep logs, traces and screenshots on your machine
([linux_proton.md](linux_proton.md#reporting-a-result)).
20 changes: 12 additions & 8 deletions docs/ultrawide.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ How the output size goes from the window to the title and back to the screen, an
change. **Measured** means a run, a test or the code shows it (file:line quoted, line numbers as of this note);
**hypothesis** means nobody has checked it yet.

> **Status on `main`:** The C++ `runtime/` changes described in the first two sections below were written against an
> unmerged `runtime/` branch (`aspect_fit.h`, `display_mode.h`, `display_profile.h` are not in `runtime/` on `main`).
> The Rust `d3d12/` implementation in [The D3D12 runtime (`d3d12/`)](#the-d3d12-runtime-d3d12) below is on `main`.
## Settings

| variable | default | what it changes |
|---|---|---|
| `LEONIDA_ASPECT` | unset | `21:9`, `32:9`, `43:18`, any `W:H` or decimal from 1 to 4, or `auto` (the primary monitor's shape). The display mode the console output reports is widened to that aspect at the same height, and so is the title's window. `off`, `none` or empty: unset. |
| `LEONIDA_PRESENT_SCALE` | `stretch`, or `fit` with `LEONIDA_ASPECT` | `fit`: a frame whose shape is not the window's keeps its aspect, centred, with black bars beside it (pillarbox) or above and below (letterbox). A frame of the window's shape fills it. `stretch`: the frame fills the window, as before. |

`scripts/play.ps1 -Aspect 21:9` (and `-PresentScale fit|stretch`) sets them. The arithmetic is in
`runtime/src/aspect_fit.h` and `runtime/test/aspect_fit_test.cpp` tests it.
On that unmerged `runtime/` branch, `scripts/play.ps1 -Aspect 21:9` (and `-PresentScale fit|stretch`) set them, with
the arithmetic in `aspect_fit.h` and unit tests in `aspect_fit_test.cpp`.

| `LEONIDA_DISPLAY_MODE` | `LEONIDA_ASPECT` | the title is told |
|---|---|---|
Expand All @@ -26,13 +30,13 @@ change. **Measured** means a run, a test or the code shows it (file:line quoted,

1. **The display mode the title is told.** `rt::d3d12::title_display_mode()` (`runtime/shims/xbox_display.cpp:324`)
answers the console output's slot 21 (`output_modes`, `:230`), its `GetDesc` desktop coordinates (`:178`),
`GetDisplayModeList` (`:202`) and `FindClosestMatchingMode`. It reads `LEONIDA_DISPLAY_MODE` (default 3840x2160,
`runtime/src/display_mode.h`) and now widens the result with `LEONIDA_ASPECT` (`title_aspect_ratio()`, `:294`).
`GetDisplayModeList` (`:202`) and `FindClosestMatchingMode`. On that branch it read `LEONIDA_DISPLAY_MODE`
(default 3840x2160, `display_mode.h`) and widened the result with `LEONIDA_ASPECT` (`title_aspect_ratio()`, `:294`).
Measured (docs/port_status.md, "The title makes its window at 3840x2160"): the 1.0.2.1 title calls slot 21 just
before its first `SetFrameIntervalX`, but its window and back buffers stay 3840x2160 whatever slot 21 reports.
1920x1080 was tried at 60 and 120 Hz.
2. **The size the title renders at.** This size is compiled into the executable: the Series X SDR mode at RVA
`0x0615c100` (`runtime/src/display_profile.h:46`), the scanout reservation, the temporal scene scale and the
`0x0615c100` (`display_profile.h:46`), the scanout reservation, the temporal scene scale and the
Settings viewport. `runtime/src/main.cpp:65-82` patches these when `LEONIDA_DISPLAY_MODE=2560x1440`. Every other
output is refused (`display_profile.h:100`). Measured: with the SDR mode set to 1920x1080 the title still made
2560x1440 buffers. `LEONIDA_ASPECT` does not change the executable.
Expand Down Expand Up @@ -123,9 +127,9 @@ Read from the 1.0.2.1 executable (offsets are RVAs; none of this is measured in
for 7:3 by whatever uses that function. The constant 16/9 at 0x615a1c0 is loaded by at least seven more
instructions (0x73c7a7, 0x19148bc, 0x28c07bd, 0x3108ddd, 0x32be281, 0x3b6c5f5, 0x4163240), none of them read yet.

`LEONIDA_OUTPUT=WIDTHxHEIGHT` (`hooks.rs`, EXPERIMENTAL) changes the first three together: the 3840x2160 row, the
reservation that fits it and the Settings viewport pointed at the row, after VIctory's native 1440p profile
(`runtime/src/display_profile.h`). `LEONIDA_OUTPUT_1440=1` is now the same with 2560x1440. A unit test checks the
`LEONIDA_OUTPUT=WIDTHxHEIGHT` (`d3d12/crates/leonida-loader/src/hooks.rs`, EXPERIMENTAL) changes the first three
together: the 3840x2160 row, the reservation that fits it and the Settings viewport pointed at the row, after
VIctory's native 1440p profile. `LEONIDA_OUTPUT_1440=1` is now the same with 2560x1440. A unit test checks the
bytes each place holds against the 1.0.2.1 executable (`LEONIDA_GAME_DIR`).

What blocks calling it ultrawide, each needing a run:
Expand Down
3 changes: 2 additions & 1 deletion docs/victory_gap_gpu.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ closed on this branch; **left** = gap kept, with the reason. "V" is `victory/cra

- `xs_proxy_mock` (`runtime/test/xs_proxy_mock_test.cpp`): `check_console_headers`, `check_console_features`, and
slot 13 in the slot-table check.
- `d3d12_xs_exports` (`runtime/test/d3d12_xs_exports_test.cpp`): the IID data import and the virtual memory range.
- `d3d12_xs_exports` (`d3d12_xs_exports_test.cpp` on the gap branch; not merged into `main`): the IID data import and
the virtual memory range.
- `xgameruntime_offline`: the deferral is an open power-request handle; null output refused.
Loading
Loading