[integration] RT-LINUX-AMD-WORLD: what drew the world on Linux/AMD, with eleven runtime PRs, docs for running per GPU #2350

Manually merged
github merged 60 commits from github-bot/gh-2350 into gh-pr/2350/base 2026-11-26 14:53:21 +00:00 AGit
Owner

@⁠aslan2142 on GitHub · 2026-11-26 14:38 UTC · original
aslan2142:linux-amd-world → main · +7421 −391 · 80 files · 60 commits · merged 2026-11-26 14:41 UTC

Claimed in the coordination issue as: RT-LINUX-AMD-WORLD

Everything that got the title's 3D world drawn on Linux with an AMD GPU (RX 7900 XTX, RADV, Wine) on 2026-11-26, as one integration PR, plus a page on how to run the game per platform and GPU.

  • Eleven runtime PRs, merged with their authors' commits kept (list under Includes). Ten are open and will be closed in favour of this one, with credit; #1972 is already closed.
  • Our own commits: a translator fix, make_game.py's wave64 choice, the address guard, night diagnostics, the BCPack fit fix and docs.
  • Branch: aslan2142:linux-amd-world, on main 73516a290.

What we measured

  • The world is drawn: opening night street and a sunset street with palms, cars and a character.
    • Over eight minutes in the world without a GPU hang, about one frame per six seconds.
    • Menus at 30 fps with no in-game compiling.
  • Five steps each removed a stop. All five are in the new docs/linux_proton.md section and in docs/running.md:
    1. amdgpu's lockup_timeout defaults to 2000 ms. World frames take seconds, so runs ended in ring gfx timeout with no page fault. It has to be raised (root, reboot).
    2. A native wave64 pack (--wave64-emulate off). Emulated single-wave compute in the round-loop form hung the GPU and drove RADV's compiler past 12 GiB (53 GB uncapped).
    3. The pipeline journal filled with gta6rt --precompile-pipelines. The pipelines stage's pipeline_cache.bin shared 0 of 5,526 pipeline keys with the game, for three reasons:
      • a different shader set;
      • different robustness features;
      • a different set-0 layout and subgroup request.
    4. LEONIDA_RT_AS=off plus LEONIDA_SKIP_COMPUTE, for the 724 library programs of 2 MiB or more (89-167 s each in the driver).
    5. The title's hang watchdog kept kicked (LEONIDA_TITLE_WATCHDOG=0 + LEONIDA_TITLE_WATCHDOG_KICK). The RVAs are measured locally and are not in the repository.
  • Still wrong:
    • frames alternate between white-out, a correct picture and black;
    • some geometry is misplaced;
    • VRAM reached 18.3 of 22.3 GB;
    • the run ended on a title int3 after 12 minutes.

Our commits

  • rdna2spirv: no round-loop fallback for single-wave emulated programs
    • 9f98dcc61's fallback no longer applies to inline_all plans: a single wave can't split at a barrier.
    • 666 main-set compute shaders return to the structured form. Translated and spirv-val counts are unchanged.
    • Tests, a fixture and a docs/design.md contract row.
  • make_game: a CPU Vulkan device does not decide the wave64 emulation
    • auto took the smallest maxSubgroupSize over all devices, so llvmpipe (8) turned emulation on beside native-wave64 GPUs (all 23,841 wave64 shaders).
    • CPU devices now count only when no GPU is listed; the runtime ranks them last anyway.
    • The log names the device that decided and the devices left out. Tests in tests/test_make_game_wave64.py.
  • Address guard, off by default (5 commits):
    • rdna2spirv.py --address-guard checks every heap_base access against a GPU page table.
    • LEONIDA_ADDRESS_GUARD=1 keeps that table current.
    • Refusals carry a module id. Console descriptor heaps outside the arena are entered as backed.
    • In one RX 7900 XTX run it refused 330,250 wild accesses, with no GPU page fault.
    • Docs, a contract row, address_guard_test and a semantic test.
  • Heap mirror: a host-RAM mirror of a console heap's copy for the release sweep (rescans of about 1 s become about 5 ms in the benchmark). Tests console_heap_copy and d3d12_console_heap_mirror.
  • VRAM: geometry copies in system memory (LEONIDA_GEOMETRY_HOST), retired when the title remaps their pages; tests in geometry_views_test and xmem_test.
  • Diagnostics, logging only unless said:
    • LEONIDA_UNKNOWN_TSHARP, LEONIDA_UNBACKED_VSHARP, LEONIDA_UPLOAD_LOG;
    • LEONIDA_UPLOAD_ALIAS (an experiment, changes behaviour);
    • LEONIDA_INPUT_FILE (button presses from a file, for headless runs).
  • dstorage history: fit packed tails against decoded BCPack siblings: refused BC7 streams in the package drop from 60 to 8 of 5,167. Test in tests/test_dstorage_history.py.
  • Docs:
    • docs/linux_proton.md: the AMD section.
    • docs/running.md: new, linked from docs/README.md. One section per platform and GPU (build, shaders, pre-compile, driver settings, environment with reasons, command, what to expect, known problems). Every value is marked measured by us, reported by others (linked) or TBD.
    • The new variables named in docs/d3d12_vulkan.md and docs/gameinput.md.
  • Merge conflicts resolved:
    • #1914 × #1886 in docs/d3d12_vulkan.md;
    • #2162 × the heap mirror (heap.copy.zero);
    • #2129 × the geometry-copy members in d3d12_vulkan_device.cpp.
    • Each merge commit says what it kept.

Includes

Each PR is merged at the head below, which hadn't moved since we tested it. The open ones will be closed in favour of this one, with credit to their authors.

PR Author Head What it contributes
#1914 RT-HEAVY-PIPELINE-CACHE @⁠kawaii-shakal a42bffdc3 a cache of the offline cache's misses, written while the game runs
#2195 RT-XMEM-STARTUP-FASTFAIL @⁠brandostrong eaf0b8d0c the ExecuteCommandLists serial stack kept out of TLS callbacks (the startup 0xC0000409)
#2240 RT-TITLE-TEXTURE-MAP-GEN @⁠zmasi d088ea79b TitleTexture readability synced with title_memory_map between passes (draft PR)
#2044 RT-XAPU-OPUS-DECODE @⁠BubsMcgee 4cfbdfc0b Opus decoding through a Rust sidecar; the first game audio on our machine
#1144 RT-XAPU-CONNECT-LAYOUTS @⁠nicoco23 6ee7ef89b xapu.dll as a command queue with the console's layouts (inside #2044)
#1957 @⁠IlyassRS3 9520db518 a work-aware timeout clock for list value waits; 450 of 464 cross-queue gates met in the world run, 0 of 33 before
#2097 RT-MESH-PSO-CONSERVATIVE-TOPOLOGY @⁠Snooozs b986d274b mesh PSOs with conservative rasterization no longer refused
#2162 RT-CONSOLE-FIX-NEVER-DEFER-BUFFER-VSHARP @⁠abnalstlll-byte 2769c5a73 buffer V#s never deferred past the console-fix budget
#2129 RT-TITLE-WINDOW-WRITE-BACK @⁠star41905453-coder 5fa864e53 a title window's GPU writes copied back to the title's pages
#2124 DSTORAGE-HOLD-PAGE-READS @⁠QemmHD 6b09de493 reads into physical pages wait for the title's Submit
#2144 INPUT-SCRIPT-HOLD @⁠klikso 7bd4cec02 button@seconds:hold in input scripts
#1972 RT-SLOT31-CPU-TWIN-TITLE-PAGES @⁠kurrutako 28fc0262d a slot-31 copy leaves the title's own mappings at the paired CPU range, so the title no longer loses its pages there
  • #1972 is included although its author closed it as incomplete.
    • The open gap: a layer read through the CPU twin can see the title's page where slot 31 mapped a different one.
    • We include it because the world run had it.
  • Open points in the included PRs, not objections:
    • #2129: a reviewer's test with two adjacent placed buffers still lost the lower buffer's writes when the upper was submitted first.
    • #2129 and #2032 (TITLE-GPU-WRITE-BACK) implement the same thing.
    • #2240 is still marked draft.

Tests

Linux 7.3.6, RX 7900 XTX and Ryzen 9 7950X3D iGPU (RDNA2, gfx1036), RADV Mesa 26.3.1, Wine 11.22 (Staging).

  • Translator suite: 500 files, 6,365 tests, 0 failed (scripts/run_semantic_tests.py).
  • Standard-library tests: all 513 files tests/test_*.py with python -I pass, including test_ci_registration, test_text_write_line_endings, test_docs_env_vars and test_tool_stdout_encoding. compileall is clean.
  • check_no_game_data.py on every added or changed file (80): clean.
  • Linux runtime build and ctest on the iGPU: 112 of 112 passed.
  • Windows suite under Wine (clang-cl + xwin, iGPU), compared with main 73516a290 built the same way: no test went from pass to fail.
    • New and passing: address_guard, console_heap_copy, d3d12_console_heap_mirror, d3d12_console_heap_mirror_off, heavy_pipeline_cache, list_value_wait_budget, d3d12_placed_write_back, d3d12_title_window_write_back, xapu_opus.
    • New and failing: d3d12_mesh_heavy_cache (#1914). It runs d3d12_mesh_test, which fails the same way on main under Wine on this iGPU (d3d12_mesh).
    • The 22 failures shared with main are the headless presentation tests and others known under Wine.
  • Game run (world frames): the same eleven PRs on main a73a57e13, on the RX 7900 XTX.
    • The pack was native wave64 (--wave64-emulate off), so the translator fix, which concerns emulated programs only, was not exercised there. Its own measurements are above.
    • Our address guard, heap mirror and diagnostics were not active (all off by default).
    • No game run was made from this exact branch.
  • Not tested: native Windows (MSVC), NVIDIA, Intel, macOS.

Depends on: none (the included PRs are merged here, not depended on).

AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)

**@⁠aslan2142** on GitHub · 2026-11-26 14:38 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2350) `aslan2142:linux-amd-world` → `main` · +7421 −391 · 80 files · 60 commits · merged 2026-11-26 14:41 UTC Claimed in the coordination issue as: [RT-LINUX-AMD-WORLD](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) Everything that got the title's 3D world drawn on Linux with an AMD GPU (RX 7900 XTX, RADV, Wine) on 2026-11-26, as one integration PR, plus a page on how to run the game per platform and GPU. - Eleven runtime PRs, merged with their authors' commits kept (list under **Includes**). Ten are open and will be closed in favour of this one, with credit; #1972 is already closed. - Our own commits: a translator fix, `make_game.py`'s wave64 choice, the address guard, night diagnostics, the BCPack fit fix and docs. - Branch: `aslan2142:linux-amd-world`, on `main` `73516a290`. ## What we measured - **The world is drawn:** opening night street and a sunset street with palms, cars and a character. - Over eight minutes in the world without a GPU hang, about one frame per six seconds. - Menus at 30 fps with no in-game compiling. - **Five steps each removed a stop.** All five are in the new `docs/linux_proton.md` section and in `docs/running.md`: 1. amdgpu's `lockup_timeout` defaults to 2000 ms. World frames take seconds, so runs ended in `ring gfx timeout` with no page fault. It has to be raised (root, reboot). 2. A native wave64 pack (`--wave64-emulate off`). Emulated single-wave compute in the round-loop form hung the GPU and drove RADV's compiler past 12 GiB (53 GB uncapped). 3. The pipeline journal filled with `gta6rt --precompile-pipelines`. The pipelines stage's `pipeline_cache.bin` shared 0 of 5,526 pipeline keys with the game, for three reasons: - a different shader set; - different robustness features; - a different set-0 layout and subgroup request. 4. `LEONIDA_RT_AS=off` plus `LEONIDA_SKIP_COMPUTE`, for the 724 library programs of 2 MiB or more (89-167 s each in the driver). 5. The title's hang watchdog kept kicked (`LEONIDA_TITLE_WATCHDOG=0` + `LEONIDA_TITLE_WATCHDOG_KICK`). The RVAs are measured locally and are not in the repository. - **Still wrong:** - frames alternate between white-out, a correct picture and black; - some geometry is misplaced; - VRAM reached 18.3 of 22.3 GB; - the run ended on a title `int3` after 12 minutes. ## Our commits - `rdna2spirv: no round-loop fallback for single-wave emulated programs` - `9f98dcc61`'s fallback no longer applies to `inline_all` plans: a single wave can't split at a barrier. - 666 main-set compute shaders return to the structured form. Translated and `spirv-val` counts are unchanged. - Tests, a fixture and a `docs/design.md` contract row. - `make_game: a CPU Vulkan device does not decide the wave64 emulation` - `auto` took the smallest `maxSubgroupSize` over all devices, so llvmpipe (8) turned emulation on beside native-wave64 GPUs (all 23,841 wave64 shaders). - CPU devices now count only when no GPU is listed; the runtime ranks them last anyway. - The log names the device that decided and the devices left out. Tests in `tests/test_make_game_wave64.py`. - **Address guard**, off by default (5 commits): - `rdna2spirv.py --address-guard` checks every `heap_base` access against a GPU page table. - `LEONIDA_ADDRESS_GUARD=1` keeps that table current. - Refusals carry a module id. Console descriptor heaps outside the arena are entered as backed. - In one RX 7900 XTX run it refused 330,250 wild accesses, with no GPU page fault. - Docs, a contract row, `address_guard_test` and a semantic test. - **Heap mirror:** a host-RAM mirror of a console heap's copy for the release sweep (rescans of about 1 s become about 5 ms in the benchmark). Tests `console_heap_copy` and `d3d12_console_heap_mirror`. - **VRAM:** geometry copies in system memory (`LEONIDA_GEOMETRY_HOST`), retired when the title remaps their pages; tests in `geometry_views_test` and `xmem_test`. - **Diagnostics**, logging only unless said: - `LEONIDA_UNKNOWN_TSHARP`, `LEONIDA_UNBACKED_VSHARP`, `LEONIDA_UPLOAD_LOG`; - `LEONIDA_UPLOAD_ALIAS` (an experiment, changes behaviour); - `LEONIDA_INPUT_FILE` (button presses from a file, for headless runs). - `dstorage history: fit packed tails against decoded BCPack siblings`: refused BC7 streams in the package drop from 60 to 8 of 5,167. Test in `tests/test_dstorage_history.py`. - **Docs:** - `docs/linux_proton.md`: the AMD section. - `docs/running.md`: new, linked from `docs/README.md`. One section per platform and GPU (build, shaders, pre-compile, driver settings, environment with reasons, command, what to expect, known problems). Every value is marked measured by us, reported by others (linked) or TBD. - The new variables named in `docs/d3d12_vulkan.md` and `docs/gameinput.md`. - **Merge conflicts resolved:** - `#1914` × `#1886` in `docs/d3d12_vulkan.md`; - `#2162` × the heap mirror (`heap.copy.zero`); - `#2129` × the geometry-copy members in `d3d12_vulkan_device.cpp`. - Each merge commit says what it kept. ## Includes Each PR is merged at the head below, which hadn't moved since we tested it. The open ones will be closed in favour of this one, with credit to their authors. | PR | Author | Head | What it contributes | |---|---|---|---| | #1914 RT-HEAVY-PIPELINE-CACHE | @⁠kawaii-shakal | `a42bffdc3` | a cache of the offline cache's misses, written while the game runs | | #2195 RT-XMEM-STARTUP-FASTFAIL | @⁠brandostrong | `eaf0b8d0c` | the `ExecuteCommandLists` serial stack kept out of TLS callbacks (the startup `0xC0000409`) | | #2240 RT-TITLE-TEXTURE-MAP-GEN | @⁠zmasi | `d088ea79b` | `TitleTexture` readability synced with `title_memory_map` between passes (draft PR) | | #2044 RT-XAPU-OPUS-DECODE | @⁠BubsMcgee | `4cfbdfc0b` | Opus decoding through a Rust sidecar; the first game audio on our machine | | #1144 RT-XAPU-CONNECT-LAYOUTS | @⁠nicoco23 | `6ee7ef89b` | `xapu.dll` as a command queue with the console's layouts (inside #2044) | | #1957 | @⁠IlyassRS3 | `9520db518` | a work-aware timeout clock for list value waits; 450 of 464 cross-queue gates met in the world run, 0 of 33 before | | #2097 RT-MESH-PSO-CONSERVATIVE-TOPOLOGY | @⁠Snooozs | `b986d274b` | mesh PSOs with conservative rasterization no longer refused | | #2162 RT-CONSOLE-FIX-NEVER-DEFER-BUFFER-VSHARP | @⁠abnalstlll-byte | `2769c5a73` | buffer V#s never deferred past the console-fix budget | | #2129 RT-TITLE-WINDOW-WRITE-BACK | @⁠star41905453-coder | `5fa864e53` | a title window's GPU writes copied back to the title's pages | | #2124 DSTORAGE-HOLD-PAGE-READS | @⁠QemmHD | `6b09de493` | reads into physical pages wait for the title's `Submit` | | #2144 INPUT-SCRIPT-HOLD | @⁠klikso | `7bd4cec02` | `button@seconds:hold` in input scripts | | #1972 RT-SLOT31-CPU-TWIN-TITLE-PAGES | @⁠kurrutako | `28fc0262d` | a slot-31 copy leaves the title's own mappings at the paired CPU range, so the title no longer loses its pages there | - **#1972 is included although its author closed it as incomplete.** - The open gap: a layer read through the CPU twin can see the title's page where slot 31 mapped a different one. - We include it because the world run had it. - **Open points in the included PRs**, not objections: - #2129: a reviewer's test with two adjacent placed buffers still lost the lower buffer's writes when the upper was submitted first. - #2129 and #2032 (TITLE-GPU-WRITE-BACK) implement the same thing. - #2240 is still marked draft. ## Tests Linux 7.3.6, RX 7900 XTX and Ryzen 9 7950X3D iGPU (RDNA2, gfx1036), RADV Mesa 26.3.1, Wine 11.22 (Staging). - **Translator suite:** 500 files, 6,365 tests, 0 failed (`scripts/run_semantic_tests.py`). - **Standard-library tests:** all 513 files `tests/test_*.py` with `python -I` pass, including `test_ci_registration`, `test_text_write_line_endings`, `test_docs_env_vars` and `test_tool_stdout_encoding`. `compileall` is clean. - **`check_no_game_data.py`** on every added or changed file (80): clean. - **Linux runtime build and `ctest`** on the iGPU: 112 of 112 passed. - **Windows suite under Wine** (clang-cl + xwin, iGPU), compared with `main` `73516a290` built the same way: no test went from pass to fail. - New and passing: `address_guard`, `console_heap_copy`, `d3d12_console_heap_mirror`, `d3d12_console_heap_mirror_off`, `heavy_pipeline_cache`, `list_value_wait_budget`, `d3d12_placed_write_back`, `d3d12_title_window_write_back`, `xapu_opus`. - New and failing: `d3d12_mesh_heavy_cache` (#1914). It runs `d3d12_mesh_test`, which fails the same way on `main` under Wine on this iGPU (`d3d12_mesh`). - The 22 failures shared with `main` are the headless presentation tests and others known under Wine. - **Game run (world frames):** the same eleven PRs on `main` `a73a57e13`, on the RX 7900 XTX. - The pack was native wave64 (`--wave64-emulate off`), so the translator fix, which concerns emulated programs only, was not exercised there. Its own measurements are above. - Our address guard, heap mirror and diagnostics were not active (all off by default). - No game run was made from this exact branch. - **Not tested:** native Windows (MSVC), NVIDIA, Intel, macOS. Depends on: none (the included PRs are merged here, not depended on). AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
xapu.dll moves out of xapu_chad.cpp into xapu.cpp; chad.dll is unchanged.

The signatures, structure layouts, command kinds, option bits and error
codes come from Marvisak/VIctory (GPL-3.0-or-later,
crates/victory-hle/src/modules/apu.rs at ffe310e), which runs the retail
executable through these calls. Only facts are used, no code
(docs/related_projects.md). They settle what the old header left open:
XApuConnect's first argument is an input (processing kind, streams,
commands per stream, memory bytes, frames per output, options), and the
dword the title reads at +0x34 of a result is its output byte count.

- XApuConnect validates the input, allocates the memory the title asks
  for (zeroed) and, with option 0x8, an auto-reset result event; any
  processing kind but Opus decoding is E_NOTIMPL.
- Each accepted command gives one result in command order, with the
  console's error codes; an unknown kind, a stream out of range or a full
  stream is refused with no result.
- A process result carries the frame count of the Opus packet's TOC byte
  (RFC 6716, section 3.1), clipped from first_frame, to frame_count and to
  the output, and zeros in the output. Nothing is decoded.
- xapu_chad_test covers result order, the full queue, the error codes,
  frame counts, silence and the event.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fallback file list in build_runtime.ps1 must match the gta6rt sources
CMake has; xapu.cpp was missing, so test_build_runtime_fallback failed
and a build without CMake would have had no xapu.dll shim.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
main added its own runtime/shims/xapu.cpp: the boot stack's earlier xapu.dll stub, which gta6rt does not link and
xapu_test checks. This branch's xapu.dll command queue moves to runtime/shims/xapu_queue.cpp so both stay: gta6rt,
xapu_chad_test, the cl.exe fallback list in scripts/build_runtime.ps1 and the references in xapu_chad.cpp,
xapu_chad_test.cpp and docs/audio_hal_exe_calls.md name the new file; main's xapu.cpp and xapu_test are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GnGkjYHUWx92TkwvwCnAMe
pipeline_cache.session.bin can't keep what a crashed run compiled: it is written at device teardown only, and
a cache seeded from the multi-GiB corpus returns the whole corpus, over its write limit. So the slow builds
the corpus misses (the pipeline library's compute programs, 3 to 7 s each on an RTX 5070 Ti) are compiled
again on every boot.

Each graphics and compute build now first asks the corpus cache with
VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT. A miss is built against a second cache, seeded from
pipeline_cache.heavy.bin next to pipeline_cache.bin, so that cache holds only the misses.

A build of at least LEONIDA_HEAVY_PIPELINE_CACHE_MS (500 by default) schedules a write. A thread of its own
writes the cache 3 s after the newest slow build and no later than 20 s after the first unwritten one,
through the session cache's staging file and rename. At teardown it writes what is left. 0 turns it off,
and with it pipelineCreationCacheControl unless LEONIDA_PIPELINE_COMPILE=cache-only asks for it.

Measured with vk_pipeline_check on the RTX 5070 Ti (617.42): a cache-only create of four library compute
programs the corpus lacks returns VK_PIPELINE_COMPILE_REQUIRED in under 1 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GetTickCount64 moves in 10-16 ms steps, so a slow build noted during a write in the write's own tick was taken
as written. The schedule now counts notes. And without an offline seed every build goes to the heavy cache:
fast ones never schedule a write, so teardown writes the cache whenever any build went into it, which is what
pipeline_cache.session.bin used to keep.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
copy_page_mappings (queue slot 31, CopyPageMappingsBatchX) mirrors every page
it maps or unmaps at a GPU-only destination onto the paired CPU range
(title_gpu_views::to_cpu). It did so even where the title had mapped that CPU
page itself with XMemMapPhysicalPages or XMemMapPhysicalPagesScatter: a copy
replaced the title's page, and an unmap (kind 2) left the title's CPU page
reserved. The title's next read of it faulted, and the run ended.

The console's CopyPageMappingsBatchX edits only the GPU-only range's page
table, so a CPU page holding a mapping of the title's (physical, scatter or a
slot-31 copy onto that address) is now left as it is. Pages the mirror made
itself, zero plants and pages with no mapping still follow the GPU-only range,
so the D3D12 layer's reads at the CPU view keep working. Each page kept is
counted and the first ones are logged.

The unmaps these paths make are now labelled in the read-fault report
(CopyPageMappingsBatchX unmap / paired CPU page / remap / hole,
XMemMapPhysicalPagesScatter unmap / remap) instead of the default "unmap".

xmem_test: test_copy_page_mappings_cpu_view now checks that a copy onto, and
an unmap of, a GPU-only page whose paired CPU page the title mapped keep the
title's bytes at the CPU page. Both checks fail on the old code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
queue_copy_page_mappings logs once whether CopyPageMappingsBatchX goes to an
installed batch hook or to the default adapter over xmem's range callback
(copy_page_mappings_fn), so a boot's read-fault reports can be matched to the
implementation the tests cover. Nothing in the runtime installs a hook, so a
retail run takes the default adapter.

d3d12_xmem_placed_test gains queue_remap_default_route, for that route: no
hook, a legacy-paired GPU-only destination, and a GPU-only pool backed only
through its CPU alias. The title maps a page of its own at one CPU twin while
the remap waits behind queue work (deferred with list values, waited for with
LEONIDA_LIST_VALUES=0), so ownership is checked when the remap is applied.
After the copy the GPU-only pages hold the pool's bytes, the other twin follows
them and the title's page keeps its bytes; after an unmap the GPU-only pages
and the mirrored twin are reserved and the title's page still holds its bytes.
On the code before this pull request the title's page check fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Builds on #1144 (RT-XAPU-CONNECT-LAYOUTS): the queue and layouts stay there;
fill() decodes each process packet through a Rust C-ABI crate over BSD-3
opus-pure when cargo builds it, and keeps the table-of-contents silence path
otherwise. Adds xapu_opus_test (a generated 440 Hz stereo packet decoded to
960 frames) and the CMake wiring; xapu_chad_test keeps covering the layouts
and the silent path. No game data.
Finding by Undefined3301 in #1608.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A queue with auto-submit on submits itself once the entries enqueued
since the last submit reach half its capacity. A request whose
destination is a physical page list names its pages through
DestinationPageArray, a pointer into the title's own page-number table,
and the worker reads that table only when the request runs
(page_transfer). The title fills the page table just before Submit. So a
read started by the self-submit found page 0 (the entry failed) or the
number the slot held before (the data landed in a page that now belongs
to something else, with no error).

A self-submit now stops at the first read into physical pages. That read
and every entry behind it wait for the title's Submit, in order, so a
status entry, fence or event behind a held read still comes after it. A
full queue submits the held entries too, since the title cannot call
Submit while it waits in an enqueue. Close submits everything, as
before. A hold also ends after LEONIDA_DSTORAGE_HOLD_MS (2000 ms unless
set; 0 means no limit), so a path that never calls Submit cannot stall
for good. LEONIDA_DSTORAGE_HOLD_PAGES=0 restores the old self-submit of
everything.

"[rt] ds-hold" counts self-submits, held reads, full-queue and timed
releases, and destination lists that named page 0 when written. It is
printed at each power of two of the counter that moved
(runtime/src/dstorage_hold.h).

The idea is from Marvisak/VIctory eddde73; it also appears in
fxceless/victory-fork 79cfdd9. Written anew for this queue.

Test: dstorage_test, test_page_reads_wait_for_submit: a list changed
between the self-submit and Submit, a list still empty at the
self-submit, a full queue, the default and an explicit time limit, no
limit, the switch, and the page-0 counter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
A window of the title's memory is a read-side mirror refreshed before every
submission, so a UAV or raw write into one landed in the copy and the title
never saw it. At the world start that is the WRITE_INVALID device loss of
#1537 (QemmHD, 160 s into the load, past the cap): the culling compute writes
through addresses that name title memory, and nothing ever reads the result
back into the pages.

The layer now keeps every title range a submission's bindings reach (the
resolve path, so root views, table V#s and created views alike) and copies
those ranges from the copy to the title's pages at the start of the next
refresh, before the forward copy. A page the title wrote in between takes the
title's newer bytes and its GPU result is dropped; the tracker already knows
those pages (guarded, hot and clean). Caps: 8,192 ranges and 64 MiB a
submission, logged once; LEONIDA_TITLE_WRITEBACK=0 turns it off.

Test: d3d12_title_window_write_back, a dispatch through a root UAV at the
title's pages: the written words reach the pages, hold across two
submissions, and a title write survives the next forward copy. No game files.

Item: RT-TITLE-WINDOW-WRITE-BACK (claimed in #1608)

Wine against llvmpipe.
Review of RT-HEAVY-PIPELINE-CACHE:
- The writer thread marked a generation written even when the save failed, so the
  cache stayed unsaved until teardown. A failed save now keeps the cache dirty and
  is retried after a bounded backoff (5 s, doubling, capped at 2 min), so a write
  that keeps failing does not spin. WriteSchedule::failed() holds that decision and
  heavy_pipeline_cache_test checks it.
- save_heavy_pipeline_cache accepted VK_INCOMPLETE and published the truncated blob
  over a complete file. It now requires VK_SUCCESS, like the session cache, and
  keeps the previous file; the next try queries a fresh size.

Changes made by Claude Code (AI-assisted).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
The first cut copied the reached ranges back at the next refresh whether or not
the submission that wrote them had finished, so a range the GPU was still
filling could be read half done.

A batch is now kept with the retire ticket of the submission that will use it,
and the ranges are copied back only once the context reports that ticket done.
Anything not yet retired stays queued and is copied on a later refresh, still
before that refresh's forward copy, so the ordering that keeps the title's own
newer bytes is unchanged.

The test is unchanged and still passes: it asserts the pages are untouched
until the next submission and then hold exactly what the shader wrote.
main's per-pipeline compute journal (pipeline_cache_journal.h) now persists every compute build and survives a
crash, so the compute build takes main's build_compute_pipeline and the heavy cache keeps graphics pipelines only.
CMake keeps both test sets; docs and the create_pipeline comment say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
In fix_console_slots, when the LEONIDA_CONSOLE_FIX_US budget expires, do not null or defer buffer descriptors (!(w3 >> 30)). Only defer image T# descriptors to retry_console_slots.

Buffer V# descriptors only rebase address offsets and are fast to fix, whereas image T#s perform costly texture lookups and view creation. Compute shaders during world transition (e.g. lib_cs_01144) read loop bounds and record counts from buffer descriptors; nulling them causes infinite loops and device loss.

Tested with console_heap_vsharp_slots_test and vk_console_heap_gpu_test.

AI-assisted (Claude Code).
At world-start frame rates the retail title reads its pad every few seconds,
so a 0.3 s scripted press falls between two reads and never arrives. An
entry may now give its own hold time; without one the press stays 0.3 s.
Holds of 0 or less, over 600 s or that are not a number reject the entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#2098 gave the SDL path its own loop (held 300 ms, then until the title
has read the pads six times, at most 5 s), which ignored button@seconds:hold.
A press now lasts its own hold, then the read latch, and never past 5 s or
its hold if longer. The long-script test checks both: X kept past 300 ms
until six reads, Y kept for its 0.6 s after them. It fails on the old loop.

Found by AndreiKocherzhinskiiA on #1608.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
861bb0546 added geometry_execute_serials() as a function-local
thread_local std::vector. A C++ thread_local with a destructor in
gta6rt.exe adds TLS callbacks to the image, which the loader's TLS
index-0 move must not have (pe_loader.cpp reserve_tls_index0; see
VulkanContext::stage_xdxr_table). With it the title's CRT startup hits
ucrtbase's one-shot _register_thread_local_exe_atexit_callback guard
and terminates: 0xC0000409 (info0=7) at ~1.6 s, before any D3D12 call.

Use a fixed aggregate instead: no destructor, no TLS callbacks, the same
per-thread LIFO, bounded at 32 replays with overflow reported once.

Tested: runtime builds; with LEONIDA_D3D12=vulkan the fix boots past
startup and submits, while 0b11d86bc exits 0xC0000409 at ~1.5 s.
NVIDIA RTX 4090, driver 616.64, Windows 11.

AI-assisted (Claude Code).

Co-Authored-By: Claude Code <[email protected]>
A slot-133 buffer the driver will not import is a shadow of the title's pages,
and the write through it landed in the copy exactly as a window's did. The
mechanism is already the same one - the pages are title memory, the alias of
the buffer resolves through the noter, and the tracker carries the range - but
nothing said so and nothing tested it.

d3d12_placed_write_back: a root UAV over a placed buffer. The pages keep the
title's words until the next submission, then hold the shader's; a write by the
title over the result survives the copy forward.
A fenced batch waits for its submission's retire ticket. On a queue the layer
holds back (console ordering) the ticket is not ours, and in the worst case
nothing retires soon: the pending list would grow for the rest of the run.

Past 64 pending batches the oldest is now copied back without waiting, once
each, and the fact is logged once. Docs say so.
Between periodic refresh_title_textures passes, synchronous slot-70 view creation and the async fill worker checked TextureReadability with a constant generation, missing title_memory_map range changes since the last pass. Track the map generation on TextureReadability and consult title_memory_map::changes_since outside refresh passes so unmapped or decommitted pages defer before hashing and newly mapped pages publish immediately without waiting for a submission.

Also mark mix_words and hash_bytes LEONIDA_GUARDED_NO_BUILTIN using an unaligned 64-bit load so clang-cl cannot emit CRT memcpy calls inside the __try frame, and classify non-title read faults over unmapped title pages in xmem::physical_page_fault as FaultExit::passed_guarded.
Review follow-up (MoonEyes): the InputScript help in boot.ps1 now says
each press is held 300 ms and that button@seconds:hold holds it longer.
The header comment in gameinput_script.h is wrapped at 120 like the rest
of the file. Comments only; no code change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
translate() re-translated every emulated wave64 program whose inline
structured form has an OpControlBarrier under a selection or loop as the
round loop (barriers_under_control_flow), for NVIDIA, which hangs on a
barrier only part of the workgroup reaches. A single-wave workgroup
(plan mode inline_all) is one wave: its barriers sit at the top level or
under %pc-only guards, which every invocation takes alike, so the
fallback only applies to multi-wave plans now.

The round form keeps nearly the whole register file live across the
loop and drove RADV/ACO's spiller past 12 GiB (53 GB uncapped) on large
single-wave programs, and made programs with long loops 10-100 times
slower. 666 main-set compute shaders return to the structured form;
translated and spirv-val counts are unchanged.

Restores the single-wave expectations in test_wave64_emulate_opt.py,
test_loop_ballot_barrier.py and test_loop_iteration_guard.py (its round
scheduler check now uses --dispatch-loop), adds
test_wave64_single_wave_barrier.py with a hand-written fixture, and a
docs/design.md contract row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A diagnostic for the world's missing textures: each distinct base address a title-written T# names with no
texture there is logged once (format, type, the SW_MODE bits, size, mips, layers, and whether it is title
memory), with a summary by shape every 8192 lookups. Off by default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two more diagnostics for the world's missing data: the buffer V#s fix_vsharp writes empty because nothing
backs their base, by distinct base and by 4 GiB range, and the raw words of the first unknown T#s, so the
address bits can be checked against the decoder. Off by default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A console resource heap's translated copy lies in the GPU address arena when the
import of host memory is not used, and the arena prefers DEVICE_LOCAL |
HOST_VISIBLE memory (ReBAR): the filtered release sweep
(LEONIDA_CONSOLE_RELEASE_FILTER=1) read words 0-2 of both V# halves of every
live slot from it, uncached across PCIe, 0.9-1.0 s a rescan in game runs.

ConsoleHeap::copy is now a leonida::ConsoleHeapCopy (src/console_heap_copy.h):
the copy plus an optional host-RAM mirror of the heap's bytes. Every CPU write
goes through write()/zero(), which write both; CPU reads use view(). The raw
pointer is no longer reachable by accident, so a missed write site does not
compile. No mirror for a copy in an import of host memory, for a sampler heap,
with LEONIDA_HEAP_MIRROR=0, or once the LEONIDA_CONSOLE_HEAP_GPU pass writes
the copy (dropped at attach).

LEONIDA_HEAP_MIRROR_CHECK=1 compares the mirror with the copy at every release
sweep and logs the first differing slots and a count per heap log line.

The sweep over 536k live slots of an 18 MiB heap with the mirror: about 5 ms
(console_heap_copy_test, host RAM). Tests: console_heap_copy (portable) and
d3d12_console_heap_mirror (first refresh, title writes and zeroes, a filtered
release sweep; again with LEONIDA_HEAP_MIRROR=0).

AI-assisted (Claude Code, Claude Opus 5.5).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A diagnostic for descriptors that hold pool offsets: each upload chunk (CPU base, device address, size) and
the first 96, then every 8192nd, AllocateUploadMemory result as an offset into its chunk, to match with the
addresses in the title's T#s and V#s. Off by default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An experiment for descriptors the title builds from AllocateUploadMemory pointers (the console's memory is
unified, so the CPU pointer is also its GPU address): each upload chunk's CPU range is entered as an alias
of the chunk's console VA (device address minus heap_base), so the in-place V# rewrite before each
submission reaches the chunk instead of writing an empty V#. Removed with the upload state. Off by default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A local tool for headless runs, whose private display passes no keyboard input to Wine: every line
appended to the file names one button of the script's table and becomes a press at once, held like a
scripted press (300 ms and six readings, at most 5 s), so a run can be driven step by step from the shell
while its screenshots are read. The file is read again at most every 250 ms. Off by default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Geometry copies held 4.4-6 GB of VRAM in world runs and were never evicted: a view retired only when its range was
freed, decommitted or unmapped, and the title streams by remapping the frames of its pools.

- LEONIDA_GEOMETRY_HOST (unset by default): 1 puts the copies in system memory outside VRAM, write-back where the
  device offers a cached host type; 2 write-combined. The memory type is picked among the host-visible types that are
  not device-local (memory_type_order alone would give the BAR first); a device with none keeps its types. Logged once
  and in the geometry buffers line.
- LEONIDA_GEOMETRY_REMAP_RELEASE (on by default, 0 off): XMemMapPhysicalPages with pages, the scatter call and
  CopyPageMappingsBatchX report the pages whose frame changed (or went) as released (xmem's RemapReleases, collected
  under the fault lock, reported after it), so GeometryViews retires the copies over them through #2094's
  drain_released and kAfterExecutes reaping. A page mapped again to its own frame is no change.
- A retired view is copied once more from its pages when they are readable: a list recorded before a remap that took
  the view's address reads the new bytes, as the refresh this replaces would have given it.
- A stream-pool extent backed by a retired copy leaves pool_spans (it was kept for the device's life).
- A full release queue joins touching ranges before it collapses into one covering range.

Tests: geometry_views_test cases 14-16, xmem_test test_remap_releases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TitleBufferWindows::system_memory_types falls back to every allowed type, the BAR included, when its device has no
memory properties; the assert keeps DeviceState from silently losing them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The predictor profile fits a history field only from a stream with a raw or
zlib sibling mip. A BC7 texture whose mip 1 and packed tail share one BCPack
stream has none for the tail, so history fields that only such tails use
stayed unknown and the runtime refused the stream with missing-endpoint
(E_DSTORAGE_DECOMPRESSION_ERROR) on every game run.

fit_decoded_neighbors decodes the nearest BCPack sibling with the profile so
far, also inside a stream the decoder refuses (blocks whose chains start at an
unknown field are left out of the reference), and fits the streams that still
reference missing fields. Only empty fields are filled, never as confirmed.

On the local package the BC7 endpoint fields go from 4228 to 4406 of 6144 and
the runtime decoder refuses 8 of 5167 BC7 streams instead of 60; both request
shapes that failed in game runs decode. BC6H is unchanged (10 of 268).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every Gen.host_addr access (buffer, global_, scalar and BVH loads, stores and atomics) calls one
%guard_fn with its sign-extended 48-bit heap offset, kind and span. Below the arena's size it passes
after a compare; elsewhere the 4 KiB pages of its first and last byte are looked up in a two-level
page table (level 1 by offset bits 47..32, level 2 one bit per page). A refused load reads the zero
area, a refused store or atomic the dump area (an atomic returns 0), and the refusal is counted in
the guard header. Without the header's magic every access passes; without the flag the module is
unchanged byte for byte.

tools/address_guard.py is the Python reference of the table and the check. cs_address_guard is the
fixture of the translator test and of scripts/run_address_guard_gpu_test.py, which runs it on a heap
where every address it touches is real memory, so no run can fault.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The arena keeps [0x70000, 0x80000) for the guard header and its two sinks (in the null region when
LEONIDA_ARENA_NULL_MB makes one). The page table is a host-visible buffer of its own; the header holds
its address minus heap_base, the arena's size and the magic, written last. Before each submission,
after the heap refresh, the windows and the geometry copies, update_address_guard makes the table say
exactly what is backed outside the arena: gpu_backings, the geometry copies' blocks and the separate
window buffers, the same set as the console heap pass's backed table but without its 100 ms limit.
Only changed words are written, level 2 before level 1; a chunk keeps its block for good; past 62
blocks a chunk passes unchecked, which is logged. Refusals the shaders count are logged at most once
a second with the last refused offset.

src/address_guard.h holds the format and the table (address_guard_test); docs/d3d12_vulkan.md 3.3
"Address guard" the design, the cost per access and what is and is not covered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
--address-guard modules now store a module id with each refused access, in the header word that was
reserved (+28): FNV-1a of the translated file's stem, fixed at translation time. The runtime's refusal line
names the last refusing module next to its offset, so refusals can be traced to a program without a GPU
capture. The guard's tests pass unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A console heap whose GPU copy is an import of the title's pages is read at heap_base + shader_va like a
buffer, but no gpu_backing names it, so the guard refused every descriptor-table load from it: a 38 MB
imported heap read past a 2 GiB arena turned one compute program's table loads into tens of millions of
refusals that read 0. update_address_guard now collects each heap's bytes and null guard outside the arena
(under console_heap_mutex, before guard.mutex) and rebuilds the table when those ranges change. With it,
the run that refused them shows no refusals in the same phase.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
--wave64-emulate auto took the smallest maxSubgroupSize over every device
vulkaninfo lists. On a machine with llvmpipe installed beside AMD GPUs
that run wave64 natively (RX 7900 XTX and an RDNA2 iGPU, RADV), the
shaders stage logged "smallest maximum subgroup size is 8" and emulated
all 23,841 wave64 shaders.

The runtime ranks a CPU device below every GPU
(runtime/src/vulkan_device_filter.h, tools/vk_subgroup_info.py
device_rank), so it never runs the shaders there while a GPU exists.
max_subgroup_decider() reads each device's deviceType beside its
deviceName (text and --json output) and leaves CPU devices out unless no
other device is listed. The log names the device that decided and the
devices left out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The five steps that each removed a stop of the 2026-11-26 runs on an RX
7900 XTX with RADV under Wine: amdgpu's 2 s lockup_timeout and how to
raise it; a native wave64 pack; filling the pipeline journal with
gta6rt --precompile-pipelines, and the three reasons the pipelines
stage's pipeline_cache.bin never matches the runtime's driver keys;
LEONIDA_RT_AS=off with LEONIDA_SKIP_COMPUTE for the large ray-tracing
programs; and the watchdog's KICK variable, whose values stay local.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Head a42bffdc3. The conflict in docs/d3d12_vulkan.md keeps main's session-cache cap (#1886) and #1914's heavy cache text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Head eaf0b8d0c.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Head d088ea79b.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Head 4cfbdfc0b, which contains #1144's head 6ee7ef89b.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Head 9520db518.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Head b986d274b.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Head 2769c5a73. The conflict in fix_console_slots keeps #2162's buffer V# exception and the heap mirror's heap.copy.zero().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Head 5fa864e53. The conflict in the title-window members keeps #2129's write-back state and the comment of the geometry copies' retirement.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Head 6b09de493.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Head 7bd4cec02.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
tests/test_docs_env_vars.py requires every variable the code reads to be named in a document; the night's diagnostics were not.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One section per platform and GPU (Linux/Wine with the RX 7900 XTX and
with the RDNA2 iGPU, Linux/Proton with NVIDIA, Windows with NVIDIA and
with AMD, Intel, macOS), each with the same fields: build, shaders,
pipeline pre-compile, driver and OS settings, environment with a reason
per setting, command, what to expect and known problems. Every value is
marked as measured by us, reported by others (linked) or TBD. The title
watchdog's KICK values are measured by each person and never committed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
tests/test_tool_stdout_encoding.py requires it of every program's __main__ block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Head 28fc0262d. Closed by its author as incomplete; merged because world run 41 had it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:40:46 +00:00
github-bot changed target branch from main to gh-pr/2350/base 2026-11-26 14:53:19 +00:00
github manually merged commit 484b21262a into gh-pr/2350/base 2026-11-26 14:53:21 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.