WIP: feat(proc): the renderer in a process of its own, phases 2 to 7 (Linux; Windows unverified; off by default) #3176

Closed
HumanBean wants to merge 86 commits from HumanBean/Longshot:feat/renderer-split-phases2-7 into main
Owner

Summary

Phases 2 to 7 of moving the renderer into a process of its own, on top of #3116 (review that first; this PR's diff includes it until it merges). With LONGSHOT_RENDER_PROCESS=1 on Linux the builder starts the renderer as its own sandboxed process, the window and input move into it, and the game's own sandbox loses the GPU, the display, the shader caches and the add-ons. Off by default (a kill switch while the split is finished; the row says so). With it off, players get the in-process hardening and fixes below.

  • Phase 2, the builder: the renderer-role (Landlock + seccomp profile of its own, no player files, no network), the import self-test before the game starts (fallback in-process before the game, never after), a two-child supervisor, the renderer's crash record and crash window, longshot_render.so in the build, fonts handed to the renderer by the builder (never from the game).
  • Phase 3, the calls: scripts/gen_rp_calls.py generates both proxies from gpu/vk/rp_calls.def, every argument checked on arrival; one-way batches, published values, the GPU lookups and nvn_invalidate_quick answered in the game.
  • Phase 4, window and input: SDL's window in the renderer's process; input to the game through shared pages; Profile::GameSplit narrows the game's Landlock profile.
  • Phase 5, frame time: the hot crossings cut (marks by ring, values in shared memory, the capture scan done by the game).
  • Phase 6, Windows (unverified on real Windows, off): pagefile sections at the fixed addresses, the renderer at low integrity with a restricted token in a job, the window in the renderer, longshot_render.dll.
  • Phase 7, hardening (applies in-process too):
    • the renderer copies recordings and texels before checking them; every retry over shared pages bounded;
    • draw counts and texture descriptions bounded, the layout recomputed (gpu/vk/record_bounds.h);
    • fixed: a texel copy re-reading a size from shared memory (heap overflow), draw_mesh index wrap (out-of-bounds read), a texture size that looped over 128 M pages, a rectangle check overflow;
    • fuzzers for the stream checks, the transport and the shader translator (tests/test_fuzz_checks.py, tests/test_shader_fuzz.py), which found translator bugs fixed here: a local-memory size wrapping an array to length 0, 64 KB of shared memory taking a constant buffer's ArrayStride (invalid without an extension: AMD and Intel allow 64 KB), wrong barrier scope outside compute, missing 1D declarations, zero-vertex mesh programs.
  • Also for everyone: no shared memory in a Linux core dump when the guest window is a memfd (a crash took most of an hour to end with the 512 GB window).

Read first: gpu/proc/rp_role.h, builder/crates/build-core/src/render_proc.rs, gpu/proc/rp_custom.c, host/rp_game.c, gpu/vk/record_bounds.h, docs/dev/reference/sandbox.md.

Testing

Tested: Linux (CachyOS, kernel 7.3), RTX 3090, NVIDIA driver 0x9b118180, headless through the queue:

  • the split's smoke run (dev.py smoke with LONGSHOT_RENDER_PROCESS=1): the renderer in its own process, play reached from kokiri-start, 1,500 frames, the Insert menu opened, 3 of the game's fonts given to the UI, the renderer ends cleanly with the game;
  • the split's smoke run in a window (--window): PASS, the window in the renderer's process;
  • timed A/Bs in the Market, split against in-process, and this PR against main with the split off (below);
  • Linux AMD, RX 580 (RADV POLARIS10, Mesa driver 0x6802006), i7-9700K, at c52a7778: the split's smoke run PASS ("the import self-test passed on AMD Radeon RX 580 Series (RADV POLARIS10): dma-bufs (udmabuf)", the renderer in its own process, no fallback, no crash, 3 of the game's menu fonts given), and the in-process smoke run PASS;
  • a windowed boot hang the change A/B found (hos_key_async calling itself on Linux, c52a7778) fixed, with tests/test_key_async_posix.py.

Game-free: test_rp_marshal (75 checks, ASan, llvm-mingw), test_rp_sides_link, test_rp_input, test_rp_calls, test_rp_transport (172, Wine), test_render_arena, test_stream_bounds, test_record_bounds, test_record_pointers, test_registration_host_copies, test_invalidate_quick, test_rp_font_pack, test_fuzz_checks, test_shader_fuzz, test_core_filter, test_sandbox_linux, test_sandbox_profile, test_switch_table, test_translator_stamp_inputs, test_drawn_page_map, test_doc_anchors; cargo build-core (229), build-compile, synthetic-game render_process (50 runs in a row), crash; check_host_compile Linux. Windows: the role chain end to end under Wine.

Still to test:

  • Linux, by hand: a visible play session with the split on (LONGSHOT_GAMESCOPE=0, LONGSHOT_RENDER_PROCESS=1) on Wayland and X11: keyboard, mouse capture, the Insert menu, text fields and an input method, the clipboard, F11 / Alt+Enter, pause in background, close and Quit, Restart now, MangoHud and the Steam overlay; expecting all as in-process.
  • Windows NVIDIA, AMD, Intel: with the switch on, the renderer at low integrity (Process Explorer), the self-test's import of section memory, DLSS/NGX, RTSS, the Steam overlay and OBS in the renderer, keys and focus into the game (@Beanstalk or by hand).

Measurements

Verdict: with the split off (the default) no change against main; with it on, the same as in-process in the Market (within the spread), on this PC.

Split on against off, the same runtime (Market, windowed, 1080p uncapped, Render resolution 67 %; dev.py ab --env LONGSHOT_RENDER_PROCESS=1 --scene market --runs 2), at 17054a6a:

Before: split off After: split on
fps (run 1 / 2) 126.8 / 126.4 125.4 / 126.0
median frame 7.78 / 7.82 ms 7.84 / 7.79 ms
1% low 104.1 / 104.8 fps 104.8 / 103.3 fps

How it got there (same scene, split on): about 600 round trips a frame at first; then values published in shared memory, one-way bookkeeping, nvn_invalidate_quick and the slow invalidate answered in the game where the renderer has nothing to do (render thread included), the fence table in place, the game's write marks shared (aligned at build-compile, no re-lift), and the renderer's twin threads spinning while their slot is hot (LONGSHOT_RP_HOT_SPIN: on with 8 or more logical CPUs left to the renderer, off below, where any spin measured worse). About 24 crossings a frame remain (slow invalidates the renderer must act on, submits whose capture is taken at the call, presents, waits not met).

Switch off, against main (windowed, Market, dev.py ab --scene market --runs 2), at 17054a6a:

Before: main @ a98cf28a After: this PR @ 17054a6a
fps (run 1 / 2) 127.7 / 127.3 129.8 / 127.6
median frame 7.72 / 7.75 ms 7.58 / 7.73 ms
1% low 105.5 / 105.0 fps 105.5 / 105.6 fps

(dev.py ab wrote no write-up only because the builder's crash-block descriptor number differs between runs, 10 and 11.)

Risks

  • Switch off (the default): the hardening and the translator fixes change what the renderer refuses and some compiled shaders (refused programs are logged); the shader stamp moves, so caches are rebuilt once.
  • Switch on: Linux only in practice; Windows refuses in code paths not yet verified.
  • Turning it off: LONGSHOT_RENDER_PROCESS unset. A revert is enough; nothing persists.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit. (Stacked on #3116.)
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named). (Touched checks pass run directly; the whole suite in CI.)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • MKWVK_API_VERSION bumped (MkwVkHost or MkwVkRenderer in gpu/vk/vk_api.h changed).
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Linux yes; mingw fails only nn_video.c here for want of FFmpeg headers: CI decides.)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h

## Summary Phases 2 to 7 of moving the renderer into a process of its own, on top of #3116 (review that first; this PR's diff includes it until it merges). With `LONGSHOT_RENDER_PROCESS=1` on Linux the builder starts the renderer as its own sandboxed process, the window and input move into it, and the game's own sandbox loses the GPU, the display, the shader caches and the add-ons. **Off by default** (a kill switch while the split is finished; the row says so). With it off, players get the in-process hardening and fixes below. - **Phase 2, the builder:** the `renderer-role` (Landlock + seccomp profile of its own, no player files, no network), the import self-test before the game starts (fallback in-process before the game, never after), a two-child supervisor, the renderer's crash record and crash window, `longshot_render.so` in the build, fonts handed to the renderer by the builder (never from the game). - **Phase 3, the calls:** `scripts/gen_rp_calls.py` generates both proxies from `gpu/vk/rp_calls.def`, every argument checked on arrival; one-way batches, published values, the GPU lookups and `nvn_invalidate_quick` answered in the game. - **Phase 4, window and input:** SDL's window in the renderer's process; input to the game through shared pages; `Profile::GameSplit` narrows the game's Landlock profile. - **Phase 5, frame time:** the hot crossings cut (marks by ring, values in shared memory, the capture scan done by the game). - **Phase 6, Windows (unverified on real Windows, off):** pagefile sections at the fixed addresses, the renderer at low integrity with a restricted token in a job, the window in the renderer, `longshot_render.dll`. - **Phase 7, hardening (applies in-process too):** - the renderer copies recordings and texels before checking them; every retry over shared pages bounded; - draw counts and texture descriptions bounded, the layout recomputed (`gpu/vk/record_bounds.h`); - fixed: a texel copy re-reading a size from shared memory (heap overflow), `draw_mesh` index wrap (out-of-bounds read), a texture size that looped over 128 M pages, a rectangle check overflow; - fuzzers for the stream checks, the transport and the shader translator (`tests/test_fuzz_checks.py`, `tests/test_shader_fuzz.py`), which found translator bugs fixed here: a local-memory size wrapping an array to length 0, 64 KB of shared memory taking a constant buffer's ArrayStride (invalid without an extension: AMD and Intel allow 64 KB), wrong barrier scope outside compute, missing 1D declarations, zero-vertex mesh programs. - **Also for everyone:** no shared memory in a Linux core dump when the guest window is a memfd (a crash took most of an hour to end with the 512 GB window). Read first: `gpu/proc/rp_role.h`, `builder/crates/build-core/src/render_proc.rs`, `gpu/proc/rp_custom.c`, `host/rp_game.c`, `gpu/vk/record_bounds.h`, `docs/dev/reference/sandbox.md`. ## Testing **Tested:** Linux (CachyOS, kernel 7.3), RTX 3090, NVIDIA driver 0x9b118180, headless through the queue: - the split's smoke run (`dev.py smoke` with `LONGSHOT_RENDER_PROCESS=1`): the renderer in its own process, play reached from kokiri-start, 1,500 frames, the Insert menu opened, 3 of the game's fonts given to the UI, the renderer ends cleanly with the game; - the split's smoke run in a window (`--window`): PASS, the window in the renderer's process; - timed A/Bs in the Market, split against in-process, and this PR against main with the split off (below); - Linux AMD, RX 580 (RADV POLARIS10, Mesa driver 0x6802006), i7-9700K, at c52a7778: the split's smoke run PASS ("the import self-test passed on AMD Radeon RX 580 Series (RADV POLARIS10): dma-bufs (udmabuf)", the renderer in its own process, no fallback, no crash, 3 of the game's menu fonts given), and the in-process smoke run PASS; - a windowed boot hang the change A/B found (`hos_key_async` calling itself on Linux, c52a7778) fixed, with `tests/test_key_async_posix.py`. Game-free: test_rp_marshal (75 checks, ASan, llvm-mingw), test_rp_sides_link, test_rp_input, test_rp_calls, test_rp_transport (172, Wine), test_render_arena, test_stream_bounds, test_record_bounds, test_record_pointers, test_registration_host_copies, test_invalidate_quick, test_rp_font_pack, test_fuzz_checks, test_shader_fuzz, test_core_filter, test_sandbox_linux, test_sandbox_profile, test_switch_table, test_translator_stamp_inputs, test_drawn_page_map, test_doc_anchors; cargo build-core (229), build-compile, synthetic-game render_process (50 runs in a row), crash; check_host_compile Linux. Windows: the role chain end to end under Wine. **Still to test:** - Linux, by hand: a visible play session with the split on (`LONGSHOT_GAMESCOPE=0`, `LONGSHOT_RENDER_PROCESS=1`) on Wayland and X11: keyboard, mouse capture, the Insert menu, text fields and an input method, the clipboard, F11 / Alt+Enter, pause in background, close and Quit, Restart now, MangoHud and the Steam overlay; expecting all as in-process. - Windows NVIDIA, AMD, Intel: with the switch on, the renderer at low integrity (Process Explorer), the self-test's import of section memory, DLSS/NGX, RTSS, the Steam overlay and OBS in the renderer, keys and focus into the game (@Beanstalk or by hand). ## Measurements **Verdict:** with the split off (the default) no change against main; with it on, the same as in-process in the Market (within the spread), on this PC. Split on against off, the same runtime (Market, windowed, 1080p uncapped, Render resolution 67 %; `dev.py ab --env LONGSHOT_RENDER_PROCESS=1 --scene market --runs 2`), at 17054a6a: | | Before: split off | After: split on | |---|---|---| | fps (run 1 / 2) | 126.8 / 126.4 | 125.4 / 126.0 | | median frame | 7.78 / 7.82 ms | 7.84 / 7.79 ms | | 1% low | 104.1 / 104.8 fps | 104.8 / 103.3 fps | How it got there (same scene, split on): about 600 round trips a frame at first; then values published in shared memory, one-way bookkeeping, `nvn_invalidate_quick` and the slow invalidate answered in the game where the renderer has nothing to do (render thread included), the fence table in place, the game's write marks shared (aligned at build-compile, no re-lift), and the renderer's twin threads spinning while their slot is hot (`LONGSHOT_RP_HOT_SPIN`: on with 8 or more logical CPUs left to the renderer, off below, where any spin measured worse). About 24 crossings a frame remain (slow invalidates the renderer must act on, submits whose capture is taken at the call, presents, waits not met). Switch off, against main (windowed, Market, `dev.py ab --scene market --runs 2`), at 17054a6a: | | Before: main @ a98cf28a | After: this PR @ 17054a6a | |---|---|---| | fps (run 1 / 2) | 127.7 / 127.3 | 129.8 / 127.6 | | median frame | 7.72 / 7.75 ms | 7.58 / 7.73 ms | | 1% low | 105.5 / 105.0 fps | 105.5 / 105.6 fps | (`dev.py ab` wrote no write-up only because the builder's crash-block descriptor number differs between runs, 10 and 11.) ## Risks - Switch off (the default): the hardening and the translator fixes change what the renderer refuses and some compiled shaders (refused programs are logged); the shader stamp moves, so caches are rebuilt once. - Switch on: Linux only in practice; Windows refuses in code paths not yet verified. - Turning it off: `LONGSHOT_RENDER_PROCESS` unset. A revert is enough; nothing persists. ## Checklist ### Ready for review - [ ] One topic, on current `main`; the title is a Conventional Commit. (Stacked on #3116.) - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). (Touched checks pass run directly; the whole suite in CI.) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] `MKWVK_API_VERSION` bumped (`MkwVkHost` or `MkwVkRenderer` in `gpu/vk/vk_api.h` changed). - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Linux yes; mingw fails only `nn_video.c` here for want of FFmpeg headers: CI decides.) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A negative first in NOP_VIEWPORTS or NOP_BIND_VBUF wrote before the state's arrays, and a handle count over 32 in
NOP_BIND_TEX/SAMP/IMG copied past the record's payload. The first step of the renderer's own validation of the op stream.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
MKWVK_API_VERSION 90. rx_stats had no caller, the renderer's texture pool size was an empty
function, and the renderer only checked audio_output_state was set: none crosses the
renderer-process boundary (render-process plan, phase 0b).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The renderer marks the pages it wrote again as guest page numbers, one call a batch
(the collection's captured pages under collect_mu, a write-back swap's pages), not a host
pointer and length a call: what crosses a process boundary as one message
(render-process plan, phase 0b).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
host/nn_hid.c hos_sprint_layout lays Sprint's controls out (on: Shift and the left
stick's press where they are the defaults'; off: back) under input_bind_lock from the
first read to Sprint set, where the renderer made a dozen bind calls between
HOS_BIND_SPRINT_BEGIN and HOS_BIND_SPRINT_ON holding the host's lock across calls: a
sequence no process boundary can carry. HOS_BIND_SPRINT_BEGIN is HOS_BIND_RESERVED_4,
which hos_bind ignores. tests/test_sprint.py runs the host's layout itself and checks it
holds the lock throughout (render-process plan, phase 0b).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
MkwVkHost.ab_value answers by the switch name's text (hos_ab_value_text), not by
hos_ab_value's table of addresses, which a name copied into one buffer for each call
(another process's) would fool; tests/test_hos_ab.py checks a reused buffer. And
rx_renderer_status fills the NFC Scan row's state and name itself, where the renderer
called nfc_scan back from inside renderer_status (render-process plan, phase 0b).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
host/nvn_layout.c is pure arithmetic: the renderer now compiles the same file as its own
(hidden) copy and calls nvn_tex_level_offset, nvn_fmt_bpb, nvn_tex_level_tiles and
nvn_tex_linear_stride directly, so MkwVkHost loses its four tex_* members. The file loses
its compound literals so it is C and C++ alike (render-process plan, phase 0b).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The guest window's memfd (guest_memfd), the game's executable path (game_path, host/hos_paths.h's
rule), the builder's file broker (builder_file_fd) and its message box (builder_message_box) are
table members now, where the renderer found them by dlsym(RTLD_DEFAULT) or weak symbols. The
renderer's copy of win32_posix.c builds with HOS_POSIX_RENDERER (no weak hos_sdl_audio_*: it
plays no sound), and dev.py vk fails when longshot_vk.so has an undefined symbol only the
executable can give (render-process plan, phase 0b).

Still looked up by name in the renderer's win32_posix.c, for the window phase: hos_posix_keys,
hos_posix_window, hos_posix_bridge_held, hos_posix_post_message, hos_posix_guest_discard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One row for each MkwVkRenderer call (RP_CALL) and MkwVkHost callback (RP_CALLBACK): name, return
type and arguments as vk_api.h has them, whether the caller may wait in it, and the calling thread.
No runtime code reads it yet; tests/test_rp_calls.py fails when a member is added, removed,
renamed, moved or retyped without its row (render-process plan, phase 0d).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gpu/proc/rp_shared.h (the control arena's layout and its hash), gpu/proc/rp_transport.{h,c}: slots, twin threads
with nesting, futex/event wake-ups, peer death and clean shutdown, hostile-peer checks (copy, check, use), with a
per-op check hook for the checks rp_calls.def will generate. tests/test_rp_transport.py drives
tests/rp_transport_test.c: two processes, gcc and clang, ASan fuzzer, llvm-mingw under Wine.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The replay's walks stepped by each op header's size and stopped only at NOP_END: a size of 0 never ended, one under 8 read
the next header from inside this one, and one past the copy read past it. submit_q now checks each recording against its
copy's prefix (gpu/vk/stream_check.h) and replays none that fails, said in the log.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A range reserved at RENDER_ARENA_BASE (A64_HOST_BASE + 512 GB, 64 GB, pages made as reached:
mmap MAP_FIXED_NOREPLACE | MAP_NORESERVE on Linux, VirtualAlloc reserve then commit in 4 MB steps on Windows),
gpu/render/render_arena.h and host/render_arena.c. The recording copies and command buffer segments
(nvn_native.c pool_get / pool_put: the same lock and pop as before), the texture copies (pins) and the
registrations kept before the renderer starts (rx_backend.c) allocate from it, so every host pointer a record
holds lies in the guest window or the arena.

The virtual pools' maps are a fixed table in the arena's head, read without the host's lock under a generation
(seqlock); lookups check the entry's arrays lie in the arena and answer only guest-window pages.

Tests: tests/test_render_arena.py (allocator, bounds, table under a writer and with junk in it).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fails here: NOP_SET_RT keeps any pointer, and NOP_BIND_PROGRAM, the copies and NOP_CLEAR_TEX read through
an address no memory is at (the renderer process plan's section 9, row 2).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
NOP_BIND_PROGRAM's program must lie wholly in the guest window, every texture of NOP_SET_RT, the copies and
NOP_CLEAR_TEX wholly in the render arena, 8-aligned (stream_check.h rec_guest_obj, rec_tex); any other is none,
and a copy or clear naming one is skipped. The renderer process plan's section 9, row 2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fails here: descriptor_ok accepts any committed readable memory, the host's heap included, and asks
VirtualQuery about the arena (the renderer process plan's section 9, row 8). The old cases of a host copy
on the heap go: the host keeps its early registrations in the arena now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
descriptor_ok accepted any committed readable memory (VirtualQuery), the host's heap included, for the
registrations host/rx_backend.c kept before the renderer started. Those copies are in the render arena now,
so it accepts the guest window and the arena (render_arena_holds) only. The renderer process plan's
section 9, row 8.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The queue already ordered high before normal before low, but every ticket it wrote was normal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(sandbox): LONGSHOT_SANDBOX_PROGRAMDATA has its row in the switch table
Some checks failed
beanstalk/approval not approved yet
PR description / Title and description (pull_request_target) Successful in 5s
CI / What the change needs (pull_request) Successful in 6s
CI / Third-party parts and guide screenshots (pull_request) Successful in 10s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
0b77577081
#3086 read it without one, so tests/test_switch_table.py failed on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Phase 2 of the renderer-process plan, Linux. With LONGSHOT_RENDER_PROCESS=1 the builder makes the guest window's
memfd, the render arena's (game read-write, renderer read-only) and the control arena's, a control channel and a
second crash block, and starts itself as renderer-role on a thread that waits for it (PR_SET_PDEATHSIG), confined by a
second Landlock profile from the same rules (no sound, udmabuf, its caches and logs written, no player folder).
The role maps the memory at its fixed addresses and runs longshot_render.so (gpu/proc/rp_main.c): the game's seccomp
filter, hello, start, an import self-test of a 64 KB guest page (host pointer, then udmabuf; a GPU copy compared),
ready or refuse. Only on ready does the game start with the split's handles (host/hos_main.c and host/render_arena.c
map the builder's memfds); a refusal, silence or the role's end starts it in-process, the reason logged. The two
children end together as the plan's 8.5 says. No renderer stands behind the process yet (phase 3): the game still
renders in-process. Windows refuses the split for now (phase 6).

Tests: cargo test -p synthetic-game --test render_process (stand-ins, every death; --ignored: the self-test on the
GPU), build-core's unit tests, tests/test_sandbox_linux.py, test_sandbox_profile.py, test_switch_table.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The kernel dumps a memfd's shared mapping whole under the default filter (0x33): every page of the 512 GB window read
for the dump. Measured here: a crash with an 8 GB shared memfd took 42 s to end, 0.3 s with the filter, so a game crash
with its memfd window (udmabuf PCs, and every split run) would be held for most of an hour. hos_main.c applies 0x31 on
both memfd paths; the renderer's role already does. tests/test_core_filter.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- build-compile: link_render_process builds longshot_render.so beside longshot_vk.so (Linux), with
  host/hos_crash_record.c and hos_report_run.c; render_process_symbols holds its exports to longshot_render_main and
  its imports to resolved ones (tests/link_guards.rs). build-driver puts it in the game folder.
- rp_main.c: its crash handler fills its own crash block (the builder reads it while it stops); the self-test picks
  the device as gpu/vk pick_device does (RX_VK_DEVICE, else the best scored).
- crash: Run.renderer; the record says process: renderer, Record.renderer parses it, Cause::Renderer says the renderer
  crashed. after_renderer in the builder.
- render_proc: start's cpus is the builder's affinity (cpu_ranges); Split::running.
- Tests: the renderer's crash block read, and the builder's death ending both children (synthetic-game
  render_process); the renderer's crash record (crash after_run).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gpu/render/render_arena_lookup.h holds the readers of the render arena's
virtual pools' table (nvn_gpu_guest's and nvn_gpu_contiguous' walk, its
checks), with the guest window's bounds as arguments. host/nvn_native.c
uses it unchanged in behaviour; the renderer's own process compiles the
same code to answer MkwVkHost.gpu_guest, gpu_ptr, gpu_read and gpu_write
without a call (the render-process plan, 6.5).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
scripts/gen_rp_calls.py writes gpu/proc/rp_calls_gen.{h,c} from
gpu/vk/rp_calls.def (checked in; tests/test_rp_marshal.py fails when
they are not current): the game's proxy MkwVkRenderer and the
renderer's proxy MkwVkHost, each member written into the transport and
its answer read back; the ops each side serves, whose decoder is also
the transport's per-op check (copy, then check, then use; every length
bounded); the blobs for the game side's lists (UI frames, world layer
models and draws, effects, program hooks, settings rows, texture
replacements, renderer actions), packed in one canonical order and
rebuilt with every region checked to be the next and every count
bounded; RP_CALLS_HASH, so two builds whose calls differ refuse each
other.

rp_calls.def gets a crossing column (T, S, L, I, R: the plan's 4.1 and
4.2 'First') and its blocking and thread columns corrected. Pointers into
the guest window or the render arena pass as their address and are
range-checked where they arrive; anything else is copied. Payloads past
a slot's 64 KB go in pieces (gpu/proc/rp_marshal.c). The S counters
(fence, replayed, the maps generation) live in the control arena's state
page; nvn_wait is answered from replayed when it can be.
gpu/proc/rp_custom.c writes by hand what no shape says: function
pointers as tickets (shot's done, the trial's apply, nested on the
caller), texels, page lists, RomFS files, pack pictures, translations
by identity, and the R members (GPU address lookups over the render
arena, the clocks).

The game (host/rp_game.c): reserve_guest and the render arena map the
builder's memfds when given; rx_start takes the split's renderer when
the control arena is in the environment and the run is headless, else
loads longshot_vk here as before. The renderer (gpu/proc/rp_stub.c):
rp_render_serve, rp_role.h's contract, loads longshot_vk and runs
mkwvk_init with the proxy host when the game asks.

Tests: tests/test_rp_marshal.py runs a game and a renderer process over
one control arena with the real generated proxies, a fake renderer and
a fake host: every generated call and callback round-trips (a
conformance suite written from the generator's shapes), nested and
from a renderer thread; the hand-written members; the blobs; hostile
payloads refused. gcc, clang, ASan and UBSan; the Windows build
compiled with llvm-mingw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- build-compile links gpu/proc/rp_stub.c into longshot_render.so (with
  the transport and the marshalling it includes, -ldl -pthread);
  RENDER_PROCESS_SOURCES names its sources for the build and for
  link_guards, whose symbol check still holds it to longshot_render_main.
- The builder's mirror of rp_layout_hash (render_proc.rs) counts the
  control arena's state page, as rp_shared.h does.
- mkwvk_texture_decode is reachable in the split: RP_OP_TEXTURE_DECODE,
  the level's bytes in and the RGBA out, run by the renderer's process
  (hos_texture_decode's decoder when rx_start took the split's renderer).
- A shot's picture is written in the renderer's own cache folder (or its
  logs) and sent back with done; the game writes it where it was asked,
  so the game's sandbox decides where pictures go, as in one process.
  The renderer's input is held to write its cache/, logs/ and log folder.
- The fence: the values nvn_fence and nvn_pushed answer move only inside
  the game's calls (vk_replay.cpp's q_values at the take, pushed in
  run_submit on the submitting thread), and the stub publishes them
  before it answers, so the game never reads one lower than in one
  process. Said where it is published.
- The blobs' keep depth audited against gpu/vk's callers (effects,
  hooks, the world layer copy on a generation change; a UI frame lives
  to the next ui_present; rows and names are read in the call). Said
  where it is defined.

Tests: test_rp_marshal (the decoder, the shot written where asked);
build-core's renderer input; link_guards, synthetic-game render_process,
test_core_filter, the sandbox tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The first split run's renderer process died with nothing said: at the end
of INIT the stub published its counters by asking the real renderer's
nvn_replayed, which nothing asks before the renderer's start in one
process, and NVIDIA's driver faulted in it (reproduced without the game:
the real longshot_vk.so behind the stub, a fake game). The counters are
published only once the renderer's start said yes (its start wrapped).
test_rp_marshal's fake renderer fails a counter asked before its start.

What the renderer's process says goes to its stderr, which the builder
tees, as render: lines: a crash (rp_main.c's handler, before its record),
mkwvk_init with no renderer, a start that failed, the end of serving,
the library not loading.

Once the builder gave the game the split's handles the run is the split's:
a split that cannot start (no window yet, the memory not shared, INIT
refused, the renderer's process gone) ends the run with the reason
(hos_fatal), never a renderer in the game's process the builder would
then kill. A call that finds the renderer gone says the run ends; the
builder ends it and names the renderer. The fallback to one process is
the builder's, before the game starts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Once the game is gone the renderer's process exits (_exit 0) on the
  first call that finds it so, or when serving ends: run 2's renderer
  went on compiling a shader and calling back into a peer that was no
  more, then faulted on its way out.
- What each side says of the other is its own: the renderer says the
  game is gone; the game says the renderer's process is gone and the
  run ends.
- Every 5 s each side logs the calls it made the most since the last
  report (rp: calls made in 5 s ...; the renderer's as render: lines):
  run 2's replay times show texture lookups and uploads at 300 ms a
  frame where one process has a few, and the next run says which round
  trip it is. rp_calls_gen gains the ops' names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Run 3 counted, per 5 s at peak, renderer to game: mark_written 70,022,
screen_size 28,090, take_key_press 2-6k, scene_rgba16f 3,330,
keyboard_counts 1,776, ab_frame 1,306; game to renderer:
nvn_register_texture 16,896, nvn_texture_created 5,375,
nvn_texture_released 5,332, option_set ~1,100.

- mark_written: the pages go into a ring in the control arena's state
  page (now 16 pages: the counters, the ring of 15360 marks, the key
  presses), which the game takes before it collects (collect_written,
  collect_written_in), so a page the renderer wrote before its call is
  marked by then. A full ring sends the rest by call. Pages outside the
  guest window are refused.
- screen_size, scene_rgba16f, prompts_live, keyboard_counts, binding and
  mic_name are kept 50 ms in the renderer's process (a rebind or a
  Sprint layout change forgets the bindings); ab_frame is answered
  there when no A/B is planned; take_key_press reads the presses the
  game notes in the state page. rp_calls_gen keeps the proxies, the
  table takes the wrappers (WRAPPED).
- A new crossing, A: register_texture, register_sampler,
  texture_created, texture_released, program_released, pool_created
  and option_set are queued in the game's order, their structs copied
  as they are at the call, and sent as one batch (RP_OP_BATCH) before
  the game's next call from any thread: whatever the game did before a
  call reaches the renderer before it. A batch is checked whole before
  any of it runs; its copies are trusted by descriptor_ok for that
  thread while it runs (longshot_vk's mkwvk_trust_copies).
- The control arena's layout changed: the builder's mirror follows.

Not changed: nvn_invalidate (it waits for the write-backs) and
nvn_invalidate_quick (its answer needs the renderer's page tables in the
state page: next), renderer_effects (an answer the game reads).

Tests (test_rp_marshal): 16000 marks past the ring's room all marked by
a collect; values asked once in 50 ms and a rebind forgetting; key
presses through the state page; a one-way call reaching the renderer
before another thread's later call; a batch with a bad entry or a
two-way call refused whole, none of it run; the copies trusted only
while a batch runs; the conformance suite's one-way calls arriving as
copies. test_key_press_queue gets the new hook's stand-in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
invalidate_quick (vk_replay.cpp) keeps the game thread's virtual core when
nothing in the range waits: no live texture's storage (tex_pages), no page
ever written back, no texture the GPU wrote ever listed; and the note it
makes of a kept range (memory_note_cpu_read) is nothing when no binding
write-back learning follows is there. Run 3 made ~5,800 of them a 5 s, each
a round trip.

- The renderer's three marks (wb_ever, wb_followed_ever, vw_ever:
  page_marks.h) get a flat copy, a bit a page below 512 GB, set with the
  same release as the mark itself, so the game reading it is ordered as a
  reader in one process is. The copies are a region appended to the
  control arena (3 x 16 MB, sparse: RP_QMARKS_OFF); longshot_vk's new
  export mkwvk_marks_mirror points the marks at it (before the first mark)
  and says whether the game may answer (invalidate_quick on, and the note
  decided by the followed marks); the stub publishes that as
  rp_state.quick_local, a field appended to the state.
- The game keeps tex_pages itself from its own texture_created and
  texture_released (as the renderer does, by the same rule), and answers
  invalidate_quick from it and the copies; whenever it cannot say
  "nothing there", or the renderer did not allow it, it asks, as before.
- The control arena's layout hash changes once (the field and the
  region, both appended); the builder's mirror follows.

Tests: test_rp_marshal (answered here with nothing there, asked for a
live texture's storage, a GPU-written texture's page, a page written
back, a followed binding's, a range past 512 GB, and while the renderer
withdraws it; the renderer's count of asks checked); test_invalidate_quick
(the flat copy: every mark at its page's bit, marks made before it
copied, chunks under a word, of a word and of many words; its source
checks follow invalidate_quick_on); test_registration_host_copies cuts
descriptor_ok with the batch copies' trust it now reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Vulkan back end's copy of host/posix/win32_posix.c found the window's state (hos_posix_keys, hos_posix_window,
hos_posix_bridge_held, hos_posix_post_message, hos_posix_guest_discard) with dlsym(RTLD_DEFAULT): a renderer in its own
process has no such symbols. Whoever owns the window now hands them over (mkwvk_window_link, looked up by name as
mkwvk_close_asked is): the executable in one process (host/rx_backend.c), the renderer's process's window module in the
split. The Insert menu's text queue, composition, place and clipboard move whole out of rx_backend.c into
host/text_queue.c, so the renderer's process can build them beside its window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
longshot_render builds the window module a second time (gpu/proc/rp_window.c includes host/posix/display_sdl.c, with
hos_sdl.c, fullscreen_monitor.c, text_queue.c and its own win32_posix.c): SDL, the window, the swapchain and the
overlays are one process's, the window's loop on its main thread, the game's calls served on another. The window is
made when the game's start reaches the renderer (rp_window_hwnd), its MkwVkWindow given in place of the game's NULL.

What the game read of the window it now reads in the control arena's input pages (gpu/proc/rp_input.h, 16 pages after
the shared state, in the layout's hash and the builder's copy): the keys held, focus, screen, fullscreen, the bridge's
held key, the captured mouse (added there, taken here), the monitors; and on a ring, in order, what the window called
in the game: focus changes, the game's own single presses (the menu's stay in the state page), toggles let go, a
dropped key's note, Restart now, the close. The game's main thread (host/posix/display_split.h) copies them into the
arrays its readers read and runs them; the control bridge's keys and pointer and the first frame go the other way.
Text, the input method, the clipboard, the cursor, the menu's pointer and the monitors' rows are answered beside the
window (rp_window_host); longshot_vk reaches the window through MkwVkWindowLink. host/rp_game.c no longer refuses a
windowed run.

With the split's handles in its command the game is confined by Profile::GameSplit (the render-process plan's 8.2): no
GPU node, udmabuf, Wayland or X11 socket or cookie, /dev/shm, driver cache, Vulkan layer, add-on place, DLSS runtime or
.drirc, and no shader store or LONGSHOT_SHADER_CACHE served.

Tests: tests/test_rp_input.py (a fake window and the game's real side in two processes: state, ordered events, presses,
the mouse, text under the game's policy, requests, the close; hostile rings and bounds; the wiring), the builder's
the_split_game_s_rules_have_no_gpu_and_no_display and the_split_game_is_served_no_shader_cache, test_sandbox_linux.py's
source checks, link_guards' longshot_render symbols with the window's module.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The game's queued one-way calls go in front of its next call's own bytes (arg[6] their length, arg[7] their
  number), not as a call of their own. The renderer runs the batches in their numbers' order, and a call waits for
  every batch numbered before it was made. Calls nested in a callback carry none and wait for none, as the old flush
  skipped them.
- The renderer publishes renderer_status (every 1 ms) and capabilities (every 10 ms), once the game has asked for
  them, under a sequence lock after the marks (RP_PUB_OFF). The game reads them in place and asks only before the
  first publish, on a torn copy, or when the shape is wrong.
- Before each nvn_present the game publishes slept_ns, main_thread_times (once asked) and the generations of
  game_post_passes, game_world_draws and game_program_hooks. The renderer reads them in place and lets a list cross
  only when its generation moved.
- Layout: rp_state fields appended, RP_PUB_OFF/RP_PUB_BYTES added, one layout-hash change, Rust mirror updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- nvn_invalidate_quick: when the game's own view gives a definite reason (a live texture's storage, a page written
  back, a texture the GPU wrote, a followed binding's note, past 512 GB), it answers 0 itself, so rx_backend goes
  straight to nvn_invalidate. Its marks only grow and its texture pages are as new as the renderer's. It asks only
  with the marks withdrawn or no guest address.
- keyboard_counts: the mouse's buttons count without asking; every other key shares one kept answer (the policy is
  not per key), so there is no 50 ms entry per key.
- take_text: a repeated no-field ask is skipped while nothing was typed or composed (rp_state text_seq, bumped by
  host/text_queue.c through hos_text_note).
- mic_test: while no test runs, its answer is kept for 50 ms.
- mods_state: published by the game before each present.
- startup_view and jitter_sample: published by the renderer beside renderer_status (pub_want bits 2 and 3,
  RP_PUB_VIEW, RP_PUB_JITTER).
- Layout: rp_state fields appended (mods_prompt, mods_changed, text_seq, view_ret), one hash change, Rust mirror
  updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- rp_marshal_test: take_text off asked once, again after the game's text note, and always with a field focused or
  right after one. mic_test off kept while the gain stays, asked on another gain, a running test and the off after it.
  startup_view and jitter_sample asked once, then read in place 100 times without crossing.
- The state page's sequence-lock readers retried only 4 times and fell back to a crossing while the publisher was in
  its copy (a flake under gcc). They now try up to 4096 times with a CPU pause, which covers a copy of a few KB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
the_renderer_s_death_notice_ends_the_game started its 20 s clock before run(), which waits on ONE_AT_A_TIME behind
the other tests' runs (a hang test holds it ten seconds and more). With the whole file in parallel it failed about
one run in three. Run now carries the run's own time (took), measured after the lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
The waiter drains the channel after the renderer's end, looking for a death notice. During the handshake it raced
the handshake for the same channel: it took a refusal the handshake was waiting for, and the handshake then read
the channel as closed. a_refusal_a_death_or_silence_before_ready_falls_back failed in about 1 of 20 to 50 runs, on
selftest:refuse ("closed its channel before ready") and once on start:crash ("did not answer ready"). Watch.talking
is set until the handshake ends; the waiter drains only after it (the handshake handles a death notice itself).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
The guest window and the render arena are SEC_RESERVE pagefile sections the builder makes, mapped with
MapViewOfFileEx at A64_HOST_BASE / RENDER_ARENA_BASE in the game and the renderer (the renderer's arena read-only);
commits stay VirtualAlloc(MEM_COMMIT) on the view, and while the window is a section the game's frees zero the
committed pages instead of decommitting (hos_guest_zero_free). The transport's wake-ups are 258 inherited
auto-reset events (LONGSHOT_RP_WAKE), the peer a SYNCHRONIZE handle (LONGSHOT_RP_PEER, or handle= in game), the
control channel two pipes with length-prefixed messages. build_core::render_proc's Windows half starts the role
with a restricted token (administrators deny-only, no privilege but change-notify) at low integrity, in a job (one
process, kill on close), a child-process policy, low labels on its write folders, its stderr relayed and a crash
block of its own; the two-child supervision as on Linux. rp_main.c's Windows path: the pipes, the self-test on a
committed page of the section view (VK_EXT_external_memory_host), hello/ready/refuse; rp_stub.c serves headless.

The renderer's window is not built for Windows: ready says window=0 and the builder starts the game in-process.
Run under Wine only (no integrity levels there); nothing verified on real Windows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
gpu/proc/rp_window_win.c builds host/display.c a second time into longshot_render.dll (LONGSHOT_RENDER_PROCESS), as
rp_window.c does display_sdl.c on Linux: the window is made when the game's start reaches the renderer, its captured
mouse is the input pages', a publisher thread writes the keys held (GetAsyncKeyState while the window is in front),
the focus, the screen and fullscreen every 2 ms, and its procedure's calls into the game (focus, presses, Restart
now, the close) go as ordered events. The game makes no window when split (host/display_split_win.h): a thread copies
the pages and runs the events, and its readers go through hos_key_async and hos_foreground_ours (hos.h) in place of
GetAsyncKeyState and GetForegroundWindow (nn_hid.c, game_host.c, background_pause.c, nn_audio.c; Linux and the
in-process run unchanged). The role's ready says window=1 when the module is linked; rp_custom.c's window hooks are
not weak on Windows (RP_NO_WINDOW: rp_main.c's stand-ins).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
- build-compile links longshot_render.dll on Windows (both routes' flags), its exports held to longshot_render_main
  (link::pe_exports reads a PE32+ export table); build-driver copies it beside the game.
- The renderer's job is limited to the PC's physical memory (a runaway or hijacked renderer, not a budget); the start
  message gives clock_base (QueryPerformanceCounter, ns) and the builder's CPUs; the renderer's standard output goes to
  the builder's (the launcher's game_ready).
- In split mode the game's AppContainer no longer gets the shader store or LONGSHOT_SHADER_CACHE (as Linux's GameSplit).
- NGX's ProgramData folder: not relabelled or served; why is in render_proc_windows.rs low_folders.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
- Windows, split: hos_mouse_game_menu, _gone, hos_mouse_wheel_take and hos_mouse_game_pointer ask the renderer's window
  (new input-ring requests), which answers in the pages: the menus' pointer under a sequence (its presses and wheel taken
  once), the wheel's notches added, whether a game menu has the mouse; hos_mouse_left_held reads the pages' button.
  (Linux has no game-menu mouse: nothing to route there.)
- The renderer publishes what is in front: none, its own window, or another's and whether that one is a tool or
  no-activate window (an overlay); hos_foreground_ours reads it, so Pause in background, the sound and the pads keep the
  overlay rule when split.
- The split game's AppContainer is given no shader store or LONGSHOT_SHADER_CACHE: shader_places, with a unit test.
- LONGSHOT_RP_HEADLESS_OK is gone: a role without a window module is accepted only when the program calls
  render_proc::accept_no_window (the stand-in), never from an environment.
- Tests: rp_input_test.c (the menus' pointer, the requests, the front, hostile values), test_rp_input.py's wiring.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
The game side sends each recording as its offset in the render arena; the renderer range-checks it, reads the copy's
prefix once, copies the recording into its own memory with that prefix and hands the replay only the copy, which
stream_check then walks. A copy is let go once the replay has passed the values handed out at its submit, as the host
lets its own go. In one process nothing changes: the replay takes the host's copies as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
A generation left odd for good hung the renderer's lookups (ra_read_begin spun without end); a ring's head the other
process keeps moving held a post. Both now give up after a bound.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
ra_read_begin and the lookups' retries give up after RA_TRIES and set ra_gave_up for good; the renderer's side then
breaks its endpoint (rp_endpoint_break) as for a broken message. The input ring's post, the marks ring's head and the
window loop's take of the game's requests each stop after a bound too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
The region was read in the game's memory for the reach of the padded buffer, then again by the copy: a game growing it
in between wrote past the renderer's buffer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
gpu/vk/record_bounds.h: draw() refuses a negative count, first vertex or base instance (Vulkan's unsigned made them ~4
billion), an index type past NVN's three, an indirect draw's negative count or stride, or a stride not a multiple of 4 or
past 64 KB. A texture's sides, levels and samples within NVN's limits and its storage under 4 GB, and its layout built
from its description (the renderer's copy of host/nvn_layout.c), never the host's nvn_tex.L: in create(),
texture_read_texels (which also refuses a level past the texture's), texture_released and tex_pages_add, whose page
loop a hostile size ran over 128 million pages. In one process the layout is the same arithmetic the host did.
tests/test_record_bounds.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
romfs_read brought the renderer the game's menu fonts, which vk_paint.cpp and vk_ui.cpp unpack (zstd, SARC) and parse
with stb_truetype, written for trusted fonts, from bytes a hijacked game answers. Split, romfs_read answers none in the
renderer and asks the game nothing: the menu draws with Libertinus, compiled in. In one process nothing changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
A mesh batch whose first index sits near 2^32 wrapped first + i round and read far past the indices (ASan: SEGV in
draw_mesh); a dirty rect at the end of int's range overflowed x + w; a page or image of any size was made.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
draw_mesh sums the batch's first and its step in 64 bits, user_texture_update the rect's ends, and paint makes no
texture past 16384 a side. The rest of the game side's structured data was found bounded where it is read: clips,
quads, batches and roots in vk_ui.cpp, the world layer's meshes in world_models.h (bad_mesh), the effects' passes in
fx_list.h and fx_spirv_check, texture replacements' sides and bytes in rp_custom.c.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Found by the transport's fuzzer: submit_serve sized its offsets' buffer before it had refused the count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
tests/fuzz/stream_fuzz.cpp: a hostile recording in a render arena, copied by the renderer's process, checked and walked
with the replay's own indexed binds against a guarded state. tests/fuzz/transport_fuzz.c: every op and callback's check
and decoder on hostile payloads. libFuzzer under ASan and UBSan, else a standalone loop; tests/test_fuzz_checks.py runs
each 5 s (--seconds for longer). The transport's fuzzer found submit_serve's unbounded allocation (fixed before this).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
695e0671 named mkwvk_marks_mirror's parameter texture_written, which the check took for a writer it cannot read (it failed
on cee8ff3c already); renamed texture_marks. Its fixture now has the description texture_released builds the layout from
(record_bounds.h tex_layout_of, e241305e).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Two of the seeds show the translator handing the driver invalid SPIR-V: a BAR in a vertex program became a workgroup
OpControlBarrier, which Vulkan allows only in compute, task and mesh stages; a 1D storage image's type without the
Image1D capability.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
A BAR in a vertex or fragment program is a subgroup barrier there (Vulkan allows the workgroup one only in compute, task and
mesh); a 1D image or texture type declares Image1D or Sampled1D where it is made. Found by the shader fuzzer's spirv-val.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
The control section's +0x58 sides and +0x64 shared bytes went to the translator and the pipeline as the game wrote them;
record_bounds.h compute_caps caps each side, their product and the shared memory, and says so once. tests/test_record_bounds.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
The builder packs the RomFS's Font2/Scalable fonts and Pack/ZsDic.pack.zs (render_proc.rs font_pack, the game folder's
index read by longshot-builder's renderer_fonts) into a sealed memfd and passes it read-only with the start message; the
role maps it (rp_role_start.fonts) and the stub's romfs_read answers from it (gpu/proc/rp_font_pack.h, every length
bounded), never asking the game. The menu keeps the game's font in the split, and no byte the game's process chose
reaches the renderer's font parsers. No pack: Libertinus, as before. tests/test_rp_font_pack.py, test_rp_marshal.py,
render_proc's unit test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
sandbox.md: what the renderer's process copies, bounds and never waits on without end, the fonts from the builder, what
stays, and the Windows box as planned (no split there yet). architecture.md: the recordings' copies, romfs_read from the
builder's pack, record_bounds.h. threads.md: the twin threads, the publisher and the window's loop in the renderer's
process, every shared reader bounded. crash-window.md: the renderer's crash and its record. build.md: longshot_render.
switches.md: LONGSHOT_RENDER_PROCESS and LONGSHOT_RP_LIB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Found by the shader fuzzer's 60-minute run with spirv-val: OutputVertices or OutputPrimitivesEXT 0, and arrays of length 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
- rp_custom.c: on Windows the window module's functions are always linked, so 'if (rp_window_hwnd)' was an address
  that is always true (clang -Werror, the llvm-mingw build of test_rp_marshal). RP_WINDOW_HAS is 1 there and a null
  test of the weak symbol on Linux. tests/test_rp_input.py's source check follows.
- record_bounds.h (compute_caps, included by vk_shader.cpp) changes a translated compute program: shader_stamp.rs
  FILES stamps it, and the stamp's tests list it. tests/test_translator_stamp_inputs.py lists ../render/rx_nvn.h,
  which record_bounds.h includes for the replay's checks, as unstamped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
The integration left them in the renderer-only part of rp_custom.c, so the game did not link (rpg_nvn_submit undefined).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
test_rp_marshal builds both halves into one program, so a function one side calls but only the other side's section of
rp_custom.c defines linked there and failed only in the real build: rpg_nvn_submit and rpg_nvn_submit_q in the
RP_GEN_RENDER section, fixed by 88893abe. tests/test_rp_sides_link.py compiles host/rp_game.c (the game's unit) and
gpu/proc/rp_stub.c (the renderer's) alone, then links each with --no-undefined against generated stand-ins for every
outside symbol but the split's own names (rp_, rpx_, rpg_, rpr_, rpw_, rpd_, rps_, rpk_, rpb_). A missing one fails
and is named. The renderer's rp_window_* are checked against gpu/proc/rp_window.c instead. On 88893abe's parent it
fails naming the two.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
A vertex program whose local memory size wrapped DivCeil to an array of length 0; a workgroup whose product overflows; 64 KB
of shared memory typed as a constant buffer's u32[16384], ArrayStride and all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
A header's local memory near 2^32 wrapped DivCeil to an array of length 0; a workgroup's product past 2^32 wrapped to a zero
or small LocalSize. 64 KB of shared memory was typed u32[16384] with Const(u32), the type a constant buffer's array is,
ArrayStride and all: a Workgroup variable with an explicit layout, invalid without VK_KHR_workgroup_memory_explicit_layout,
which the renderer never enables (support_explicit_workgroup_layout is never set). Its length is a signed constant now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Byte 1's 0x80 leaves them raw, so TranslateProgram's own refusal is fuzzed too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
renderer_fonts opened longshot_romfs.idx in the game folder itself. A built (organized) game folder keeps it in
data/, so a split run handed the renderer no fonts: "romfs_read Pack/ZsDic.pack.zs: not among the builder's fonts:
none given" and "0 of the game's menu fonts given to the UI". It now reads game_layout::data(game)'s index first.
It moves to game_files::fonts (not romfs.rs: the index's recipe hashes that file). is_font_file also takes the
.bfttf.zs fonts vk_game_font.h's read_script tries for other scripts' letters.

Tests: every path vk_game_font.h reads (its read_file literals, each Font2 extension it tries) is a font file; an
organized game folder's index gives the renderer all of them, and the pack holds the dictionary's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
collect_written_in ran nested inside each submit (about 4000 crossings in 5 s in the Market), the game's submitting
thread blocked on the round trip. The renderer now publishes the captured ranges its submit's capture last asked for
(rp_state cap_ranges under cap_seq, cap_gen). The game scans them itself before each submit (precollect) and sends the
pages one-way, carried on the submit's own message (RP_OP_PAGES). The capture takes them when they are for those very
ranges, else it asks as before.

Safety, as one process's collect_mu gave it:
- The renderer's collection of the written pages (collect_written) sets rp_state collect_seq odd. It is even again
  only once the pages it took in the captured ranges are marked again: vk_memory.cpp now calls mark_written(NULL, 0)
  at the collection's end, a no-op in one process.
- The game's scan does not start while it is odd. When it moved during the scan, the pages are sent as unsure, and
  the capture asks as well and takes both.
- The game's own scans and the ones it serves are one at a time (scan_lock). Pages a submit sent that no capture took
  go to the next collection.

Layout: rp_state collect_seq, cap_seq, cap_gen, cap_n, cap_ranges[RP_CAP_RANGES] appended, one hash change, Rust
mirror updated. Test: the second submit's capture asks the game nothing and gets the game's pages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
- The generated rp_op_names and rp_cb_names were positional. RP_OP_PAGES, added to the enum and not to the names,
  shifted every game-side name by one in the calls-made lines: "nvn_pool_created 13087" was nvn_invalidate's count.
  Both tables now use designated initializers ([RP_OP_...] = "..."). The counts lines and rpx_post's message take a
  missing name as "?". Nothing else indexes by a stale number: the async decoders and the op tables are designated
  already.
- The capture path asked the game on every submit (4,243 in 5 s). Each capture asks for its own pools' ranges, which
  differ from one submit to the next, while the game scanned only the last ranges asked and the capture took the
  pages only for those very ranges. The renderer now publishes the union of the ranges captures asked for (joined
  where they touch, the closest joined past 64). The game sends the ranges it scanned with the pages, and a capture
  whose ranges lie inside them takes its own pages. The rest of the scanned pages go to the next collection, as
  before.
- Once-a-reason lines on both sides say why a capture still asks: none published, torn or too many, a collection
  running, nothing sent with the submit, ranges outside those scanned, unsure.

Tests: a capture of a subset of the scanned ranges asks nothing and gets its pages; every op and callback has its name
at its own index (nvn_invalidate, pages, collect_written_in checked by name).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Found by the 20-minute shader fuzz run on the fixed translator.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
fix(vk): the translator refuses shared memory past 1 MiB
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
6cc33f7fed
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Author
Owner

Tested in game: Linux (CachyOS, kernel 7.3), RTX 3090, NVIDIA driver 0x9b118180, headless through the queue: with LONGSHOT_RENDER_PROCESS=1 the renderer ran in its own process, smoke run PASS (play from kokiri-start, 1500 frames, Insert menu, game fonts given to the UI, clean end); timed A/B in the Market split vs in-process: 121.8/123.1 vs 127.4/129.6 fps. Switch off: the same runs' in-process sides; change A/B against main running.

Tested in game: Linux (CachyOS, kernel 7.3), RTX 3090, NVIDIA driver 0x9b118180, headless through the queue: with LONGSHOT_RENDER_PROCESS=1 the renderer ran in its own process, smoke run PASS (play from kokiri-start, 1500 frames, Insert menu, game fonts given to the UI, clean end); timed A/B in the Market split vs in-process: 121.8/123.1 vs 127.4/129.6 fps. Switch off: the same runs' in-process sides; change A/B against main running.
Member

Possibly related, for context:

  • issue #1493 Renderer rewrite — Broader renderer rewrite plan includes the process-separation direction
Possibly related, for context: - issue #1493 Renderer rewrite — Broader renderer rewrite plan includes the process-separation direction
Author
Owner

Blocker found by the change A/B against main (Market, windowed, split off): this PR's build hangs at boot in a window (no frame, the control bridge never answers); main runs at 127.9/128.2 fps. Headless in-process and split runs are fine. Being fixed; the PR stays WIP until a windowed run passes.

Blocker found by the change A/B against main (Market, windowed, split off): this PR's build hangs at boot in a window (no frame, the control bridge never answers); main runs at 127.9/128.2 fps. Headless in-process and split runs are fine. Being fixed; the PR stays WIP until a windowed run passes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
fix(host): the game's held keys on Linux read the window's keyboard again; the windowed boot no longer hangs
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
c52a7778e8
5470810334dd's hos_key_async (host/game_host.c, Linux) called itself instead of GetAsyncKeyState: at -O2 an endless loop
on the game's thread at its first key read (hos_key_down, hos_key_held), so a windowed run, in-process or split, made no
frame and its control bridge never answered. Headless runs read no key while no window is in front, so they passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Author
Owner

Fixed in c52a7778: hos_key_async (Linux) called itself, so the first key read in a window looped forever. Windowed change A/B against main with the split off: 127.3/128.4 (main) vs 128.1/127.7 fps (this PR), no change. The split's smoke run in a window passes.

Fixed in c52a7778: `hos_key_async` (Linux) called itself, so the first key read in a window looped forever. Windowed change A/B against main with the split off: 127.3/128.4 (main) vs 128.1/127.7 fps (this PR), no change. The split's smoke run in a window passes.
In the split each invalidate that invalidate_quick could not keep crossed to the renderer (about 2,450 a second in the
Market), most of them to do nothing but note the CPU's read: a page written back whose write-back is done, or a
texture's storage with no queue stopped. The game now decides that itself, from state the renderer shares in the
control arena (gpu/proc/rp_inval.h, RP_INV_OFF):
- ok: the renderer allows it (invalidate_quick on, the submitting thread's replay, no readback diagnostics or A/B
  switches);
- blocked: the stopped queues, stored by update_blocked;
- completed: the GPU's completed value, the largest read (completed(), and the stub's publisher every 0.5 ms through
  mkwvk_inval_tick);
- wb: each page's newest write-back value, stored by wb_pages_note under its lock (an open-addressed table that only
  grows; a page it does not hold is asked for).

It answers here when vk_replay.cpp invalidate would neither wait nor act: no texture the GPU ever wrote in the range,
no stopped queue where a texture's storage or a written-back page is, and every written-back page's value at most the
completed one. Its two notes (the read where a binding is followed, memory_note_cpu_read; the readback where a page
was written back, memory_note_readback) go into a ring before it returns, so before the CPU's answer. The ring is
written under one game lock, so a note is complete before any later one is. The renderer takes the notes in order
(memory_inv_drain) before anything reads what they note: memory_rb_refresh, so the replay still refreshes the page
from guest memory after the CPU's answer (the exposure flashes' ordering), and wb_leave_out. A note outside the
guest window, or a readback past 16 KB, is refused, so a hostile game hurts only its own picture.

Everything else asks the renderer as before. A line once a reason says why (no table entry, write-back pending, queue
stopped, a texture the GPU wrote, ring full). In one process nothing changes: no state is shared, and every hook is a
null test.

Layout: RP_INV_OFF/RP_INV_BYTES (2 MB) appended, one hash change, Rust mirror updated; rp_render_start.inval_share and
inval_tick, looked up by the stub on Linux and Windows.

Tests (rp_marshal, two processes):
- answered here when done and nothing is stopped, with its read and readback notes;
- asked for a page the table lacks, a write-back pending, a queue stopped, a texture's storage with a queue stopped,
  and a texture the GPU wrote;
- two game threads invalidating while the renderer takes notes: all taken, each thread's in order;
- a hostile head refused.
invalidate_quick_test stubs the shared state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
perf(proc): the slow invalidate answered in the game with the render thread too; pad_raw and aspect_ratio read in place
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
fafa8d7c2d
- The local answer was off with Threaded rendering (on by Auto for most players). With the render thread, invalidate
  forces nothing for a page written back: the game is a frame ahead by design and reads what has been written back so
  far, and only the work already recorded has write-back values to wait for. So the answer there is the same: done
  when every page's newest value is at most the completed one, whatever is queued. Only a texture's storage waits
  for the replay when it is behind (wait_queue_empty). replay_behind on that thread is a job handed over and not
  done, or a queue stopped: the renderer now stores its q_handed and q_done (rp_inval.h, in the old padding: the
  layout of rp_inval is unchanged) where enqueue and the job's end move them, within the call that hands the job
  over. rp_inval.ok says which replay runs (RP_INV_ASYNC), and the game decides as invalidate does for it.
- Windowed runs asked pad_raw and aspect_ratio every frame (1,232 and 616 in 5 s). The game publishes both with the
  present's values (present_seq); the renderer reads them in place, a frame old at most. A NaN aspect reads as none.
  ui_present stays a call: it hands back the frame the renderer draws.

Layout: rp_state pad_raw, aspect_bits appended, one hash change, Rust mirror updated. Tests:
- the render thread's answers: here for a written-back page with a job behind or a queue stopped;
- asked for a texture's storage until the jobs are done, and for a pending write-back;
- their notes;
- pad_raw and aspect_ratio read in place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
- nvn_fence_q (1,872 in 5 s): the renderer stores fence() as each value is handed out (q_values_next, within the
  submit or present that takes it), and each queue's last submission's value where q_last is set (sync_order_mu, its
  one writer) in rp_inval.h's fq table. The game reads them by fence_q's own rule (fence_mode: the render thread's
  fence(); the submitting thread's per-queue value, fence() for a queue with none). It asks when the table left a
  queue out, or the mode is neither (dump_on).
- nvn_wait: answered 1 when the completed value the renderer last read covers it. That is wait's first test, and the
  value only grows. Otherwise it crosses: what wait does then (the stopped work forced, the gate, the parts' waits)
  is the renderer's, so a futex on a counter cannot stand in for it.
- nvn_event_signal (1,248): one-way, carried on the game's next call from any thread and run before it, when the
  submitting thread's replay has no queue stopped. The signal is then only kept for the submits after it
  (event_signal_queued), each of which is a call that carries it first. A queue stopped (which the signal may let
  on, sync_watch's), or the render thread (which captures at a signal a stopped wait meets, on the game's thread),
  asks as before. A wait or poll that is not met crosses, and so carries the signal on.
- rp_game_flush publishes the shared state first, as any call does (rp_game_before_call).

Layout: rp_inval grows (fence_mode, fence_now, fq_full, fq[256]), one hash change, Rust mirror updated. Tests:
- fence_q read in place for a queue in the table, one not in it, and queue 0;
- fence_q asked in mode 0;
- an event signal not crossing with nothing stopped, and arriving before the next call;
- an event signal crossing with a queue stopped.
The test's signals to its fake renderer flush the one-way queue (sig).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
The collection of the pages the guest wrote crossed to the game twice per submit: collect_written on the replay
thread (3,744 in 5 s), and the capture's collect_written_in. The marks themselves (builder/rt a64_dirty, a byte a
guest page) now live in the control arena (RP_DIRTY_OFF, 128 MB, sparse):
- the game maps them over its module's own table at the module's load (host/game_module.c take, rp_game_map_dirty:
  MAP_FIXED over the array), before any guest code runs; the guest's stores and hos_mark_written mark them there as
  before;
- the game publishes its GPU-mapped guest ranges (hos_gpu_guest_ranges) in rp_ranges at each call whose maps
  generation moved, so before any submit that follows a mapping;
- the renderer collects (collect_written: every published range) and captures (collect_written_in: the capture's
  own) by the host's own walk: a mark read relaxed and taken by an acquire exchange, 32 and 8 a load while none is
  set. It marks pages again (mark_written) with a release store, as hos_mark_written does, all under its own
  collect_mu as in one process. No ring, no call, no scan by the game before a submit: precollect stands down, and
  it stays only for a module whose table is not page-aligned.

builder/rt a64_rt.c aligns a64_dirty to a page (_Alignas(4096)). A module built before that, unaligned, keeps the
crossing collection. Ranges past the guest window and marks past it are refused, so a hostile game hides or shows
only its own pages. Windows keeps the crossing collection for now.

Layout: rp_state.dirty_shared, rp_ranges (RP_RANGES_OFF) and RP_DIRTY_OFF appended, one hash change, Rust mirror
updated. Tests (rp_marshal, two processes):
- the shared collection takes the marked pages in the published ranges and leaves one outside and one past the
  window;
- a page marked again is taken by the next capture;
- nothing is asked of the game;
- a guest thread marking while the renderer collects: every page taken.
game_module_test stubs rp_game_map_dirty.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
A guest thread writes each of a range's 256 pages over 400 rounds: the round's number at the page's start, then the
mark, a release store, as a guest store does. Meanwhile the renderer collects without pause, reads each page it
takes, and marks every seventh again, as a capture does with a page written after it. In the end every page's last
round must have been read by a collection after it was written; a mark lost leaves a page at an older round. With
the walk made to drop one page, it fails naming that page. It replaces the earlier smoke test. It runs under ASan in
test_rp_marshal's sanitizer build (two processes, so TSan, per process, would see only one side).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
builder/rt/a64_rt.c's alignment is reverted: rt is in the lifter's key (LIFTER_SOURCES), so aligning the table made
every player's lift run again. The game now maps from the control arena only the whole pages inside its module's
table. Byte i of the table is at RP_DIRTY_OFF + dirty_delta + i, the region a page larger (RP_DIRTY_REGION), so
those pages map at offsets that are pages. The partial pages at its two ends stay the module's own: marks of guest
pages below 16 MB at the start, where nothing of the GPU's is, and of the window's last 16 MB at the end. The game
publishes the table's delta and the shared span [dirty_lo, dirty_hi) (rp_state). The renderer walks the span in
place and asks the game by call (collect_written_in, the game's own walk, once-logged) for any part of a range
reaching outside it; it marks pages outside it again through the ring, as before.

Layout: rp_state dirty_delta, dirty_lo, dirty_hi, RP_DIRTY_REGION, one hash change, Rust mirror updated. Tests:
- the shared collection takes the two in-span pages in place and asks once for the window's last page, a partial
  end page's;
- a capture whose range touches the end page asks once for the end and takes the rest in place;
- the race test unchanged, passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
build(compile): the game module's write marks start on a page, without touching builder/rt
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
b3af2a6a1f
5b7dc18c left the table's partial end pages the game's. The GPU's pools live at 496-512 GB, so every collection
reached the end page and asked the game (collect_written_in rose to ~8,100 in 5 s). builder/rt is in the lifter's key,
so the table is placed by build-compile instead. On Linux a64_rt.c is compiled with -fcommon (its a64_dirty a common
symbol), and a new unit, host/a64_dirty_align.c, defines the same common symbol aligned to a page. The linker merges
commons at the larger alignment, so the module's one table starts on a page and the renderer's process shares it
whole (no end pages: rp_game_map_dirty's span is then the whole table). The end-page fallback stays for a module
where it is not aligned.

What rebuilds for a player: build-compile's keys hold each unit's flags and source, so a64_rt.c's object (a new flag)
and the new unit are compiled and the module linked again. No lifted unit's flags or text change, and the lifter's key
does not move.

Tests:
- tests/test_dirty_align.py compiles a64_rt.c, a64_module.c and the placement unit with the module's flags, links them
  with lld as the module is, and reads a64_dirty's address with readelf: on a page (0x100f000), where without the
  unit it is not (0x100e8a0);
- build-compile's plan test checks the flag and the unit's place in the module.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
perf(proc): a waiter spins long only while its peer is on a CPU
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
0de65417c9
The transport's bench under load (busy threads on 20 or 22 of this PC's 24 cores) showed the default spin, 50 us, at
108 us a round trip (median at 22, p90 at 20), against 6 us with no spin. A caller spinning for an answer holds a
CPU that the peer, just woken from its futex, needs on a busy machine. Each slot now carries each side's awake flag
(rp_slot.awake, in its padding): 0 while that side's thread sleeps on the futex, 1 once it is back on a CPU. A
waiter whose peer is asleep spins only 12 us, the time a wake-up takes on an idle core, then sleeps; a peer awake
keeps the full spin.

Bench, median / p90 in us, gaps of 200 and 2000 us between calls:
- idle: 2.6/3.4 and 5.1/18.8, unchanged;
- 12 busy: 2.8/3.3 and 5.7/6.1, unchanged;
- 20 busy: 3.0/32 and 5.1/33, from 4.8/108 and 5.2/109;
- 22 busy: 32/33 and 33/56, from 108/109 and 109/111.
Back-to-back calls are unchanged (0.4-0.8 us). The layout is unchanged: the flags are in the slot's padding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
perf(proc): hot twins spin, a 1 ms publisher and a wider mark walk
Some checks failed
beanstalk/approval not approved yet
CI / What the change needs (pull_request) Successful in 9s
CI / Third-party parts and guide screenshots (pull_request) Successful in 13s
PR description / Title and description (pull_request_target) Successful in 8s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 23s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m22s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 9m2s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Failing after 12m59s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Failing after 13m20s
CI / Website build and checks (pull_request) Failing after 1m13s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 47m44s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 1h0m5s
17054a6aed
A twin whose slot had a message within the last 2 ms spins LONGSHOT_RP_HOT_SPIN us (default 1000 with 8 or more
logical CPUs left after the game's reserved ones, else 0) for the next call. The renderer's publisher ticks every
1 ms, as on Windows. The shared-mark walk skips 256 clear marks a test. The bench gains the hot-twin case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e45R4CfYVK3VeGVd2h
Author
Owner

Folded into #3116 (one PR for the whole split), same commits.

Folded into #3116 (one PR for the whole split), same commits.
HumanBean closed this pull request 2026-12-04 15:55:07 +00:00
Some checks failed
beanstalk/approval not approved yet
CI / What the change needs (pull_request) Successful in 9s
CI / Third-party parts and guide screenshots (pull_request) Successful in 13s
PR description / Title and description (pull_request_target) Successful in 8s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 23s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m22s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 9m2s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Failing after 12m59s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Failing after 13m20s
CI / Website build and checks (pull_request) Failing after 1m13s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 47m44s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 1h0m5s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!3176
No description provided.