WIP: feat(linux): run natively on AArch64 Linux (Apple M5 under Asahi, 16 KB pages, Borealis) #2692

Draft
Kolkka wants to merge 18 commits from Kolkka/Longshot:builder/aarch64-linux into main
First-time contributor

Summary

On AArch64 Linux, clang rejects the x86-64 flags that main passes. This branch builds Longshot for the host CPU and plays it on an Apple M5 under Asahi (16 KB pages, Borealis): Kokiri Forest from the kokiri-start save, played by hand and by 1800-present scripted runs, at about 13 fps with the memory-saving settings under Testing.

  • af4cbcc5 selects the native Linux architecture in builder/crates/build-compile/src/toolchain.rs. It reads Arm CPU features, uses the AArch64 Linux Rust target and searches the AArch64 Vulkan library paths. AArch64 IR units use -fno-global-isel to work around an LLVM 22 crash. A minimal four-instruction reproducer uses no game content, and a test pins the flag.
  • 32c87a16 adds AArch64 host context switches, fault decoding, profiler sampling and spin waits. Start with hos_posix_guest_discard in host/hos_main.c. Whole host pages are discarded and partial pages are zeroed in place. Commit and protection ranges round to host pages.
  • 79b5f2e5 lets memory_init in gpu/vk/vk_memory.cpp start on the Linux dma-buf route without VK_EXT_external_memory_host. It aligns pools to host pages and guards the host-pointer fallback. Shader preparation can start without a guest window. The recorder uses an AArch64 spin pause.
  • b5ca53a4 makes scripts/devtools/build.py select linux-arm64 and use the system clang, lld, Vulkan, SPIR-V and VMA headers, FFmpeg and SDL2 via LONGSHOT_OWN_TOOLS=1. The Arm route installs no locked tools.
  • efced427 makes Automatic run Borealis's mesh shaders on the compute path, as it does RADV's. Its native path lost the device in the first shadow passes (the depth-only 4096×4096 pass filled the tiler's buffer). Borealis is known by its driverInfo, since its driver ID (35) is not in the Vulkan registry. RX_VK_MESH_SHADERS=native still tries it.
  • 23e811aa (test) and e094c238 (fix): the occlusion query ring (kOccPool, gpu/vk/vk_replay.cpp) goes from 65536 to 32768 queries. Borealis gives each query index a counter from one heap of 32768, kept until the pool is destroyed. Past that, a draw's query failed to record (VK_ERROR_OUT_OF_HOST_MEMORY, "Descriptor table not large enough"), and the submission lost the device about 45 s into play, with no kernel message. A full ring only leaves reports "visible" (occ_room), so 32768 changes nothing for other GPUs but how many frames of queries can be in flight.
  • 154185f9: where the compute fallback runs beside native mesh shaders, a mesh program whose native pipeline the driver refuses takes its fallback variant instead of being left out (on the M5, Borealis's compiler refuses one of OoT's mesh-only programs: one draw a frame).
  • 0959a697 replaces efced427's rule: Automatic keeps Borealis's mesh shaders and runs only its task + mesh draws on the compute path (task_mesh_fallback, as for AMD's Navi 2x on Windows). Its native task + mesh path loses the device (in the 4096×4096 shadow pass and in a 128×128 render), its mesh-only draws do not, and every mesh draw on the compute path broke render passes: Kokiri Forest 13.5 → 17 fps, the castle gate 8.2 → 9.7, the market entrance 11.3 → 14.
  • 757a7214 (test) and 249a250b: fewer indirect mesh argument batches (RX_VK_MESH_CONV=2, mesh_conv_at_barrier). The scan stopped at every counter's report, which is written on the CPU as it is replayed and records no GPU write (the batch's copies and the draws that take from it share one command buffer), so the occlusion pass's ~200 reports a frame cut it at each: each indirect mesh draw after one got a batch and a pass end of its own. And after a draw that may write memory dropped the batch, the draws after it converted one by one, a pass end each; they are now batched again right after that draw. Kokiri Forest 25 batches → 10, 134 render passes → 121: 17 → 20.9 fps. This runs on every GPU with native mesh shaders; RX_VK_MESH_CONV=1 still converts at the draw.
  • 6603bc68 makes #2684's float middle path build on AArch64: its empty asm took x86-64's register class ("=x,0"), which clang refuses there, and 174 hot units failed to compile. llvm::Options::aarch64 gives "w"; its text in the units' keys is unchanged on x86-64, so no lift there is redone.
  • 8e630258 builds #2036's native cloth kernels on AArch64: game/cloth_sse_neon.hpp gives the 98 x86 intrinsics they use with NEON, each with Intel's semantics, and game/neon's xmmintrin.h, emmintrin.h, smmintrin.h and immintrin.h lead to it, before the compiler's own, for the game's C++ on AArch64 alone. The kernels themselves are unchanged.
  • Review answers: a5a33ca4 / 9c5abcab (L1, L2) ask for the page size each time instead of caching it on first use. 764ed9b6 / 6e0bd422 (L3) take the dma-buf-only route only where every pool can be imported. 1b103d62 fixes test_sim_turf_settings on 16 KB pages.

Follow-ups for a release builder on Arm are the linux-arm64 packages in tools.lock and the builder's target_system(). Also a follow-up, not in this branch: the renderer submits command buffers without checking vkEndCommandBuffer's result (part_submit, submit_recording), so a driver's recording error reads as a lost device.

See #420 and #966. Mooki's paused macOS port runs natively on Apple silicon. This PR takes no code from it. The overlap is the Arm host and 16 KB pages.

Testing

Tested:

  • Apple M5 (10 cores, 14.5 GB unified memory), Linux 7.3.0 (Asahi-style kernel, 16 KB pages), Aurora Fedora Remix 44, KDE Wayland. Mesa 26.3.0-devel Borealis (git 78d817d933), Vulkan 1.4. Fedora clang 22.1.8 and mise Rust 1.99.1, with system tools via LONGSHOT_OWN_TOOLS=1.
  • In the game, at head 8e630258 on main @ 22d0d200 (dev.py game --quick from my own dump, 924 units, zero failed): boots, intro, title and menu, Kokiri Forest from kokiri-start. Scripted runs through the job queue (headless, A pressed until play, then 1800 presents of play): still running after 1800 presents every time since the occlusion fix (at head: frame 3054, 13.8 fps, 705 draws a frame with HOS_NATIVE_CLOTH=check; frame 3071, 11.8 fps with the cloth's default). I also played it by hand in a window, keyboard input, until I closed it.
  • Settings of these runs: RX_VK_PRECOMPILE=0 (pipelines built at first draw) and memory-saving switches (HOS_OUTPUT_RES=1920x1080 HOS_RES_SCALE=0.5 HOS_DYNRES=0 RX_VK_VRAM_MB=640 RX_VK_TARGET_POOL_MB=64 RX_VK_WORKERS=1 RX_VK_LOAD_WORKERS=1 RX_VK_COMPUTE_SERIAL=1 RX_VK_MIRROR=0 RX_VK_WB_SHADOW_MB=0 RX_VK_FRAMEGEN=0 RX_VK_AUTO_TUNE=0), with 16 GB of swap (8 GB zram, 8 GB file). Without RX_VK_PRECOMPILE=0, building every pipeline at start-up runs out of memory on this PC.
  • The occlusion fix, before and after: at e094c238~2 every scripted run lost the device 40-50 s into play. With MESA_VK_ABORT_ON_DEVICE_LOSS=1 and uprobes on Mesa's __vk_errorf and _vk_queue_set_lost, the cause was hk_ensure_occlusion_query_for_draw returning VK_ERROR_OUT_OF_HOST_MEMORY (counter heap full), then submitted a command buffer recorded with VK_ERROR_OUT_OF_HOST_MEMORY. With RX_VK_OCC_QUERIES=0 the same run played. At e094c238, with the queries on, it plays.
  • The native cloth kernels on NEON, in the game with HOS_NATIVE_CLOTH=check (every call also run lifted and compared): Kokiri Forest, 1800 presents, about 905,000 calls of thirteen kernels compared (cull 181,709; capsule tail 128,189; link 79,884; aabb, anchor, bones, tether, verlet about 62,000 each; bend link 58,263; pm and skin 48,210 each; bend 37,142; capsule 12,375), 0 mismatches. With the kernels at their default (on), the same run played its 1800 presents. Game-free: test_cloth_sse_neon (413 cases against Intel's definitions, written apart from the header, -O0 and -O2) and every cloth test built the same way on AArch64 (test_cloth_kernels, test_cloth_step8, _step9, _step12, test_cloth_loops, test_cloth_sphere, test_oot_cloth, _60, _time): pass.
  • Game-free tests, each failing on the code before its fix and passing after, with g++ and clang++: test_vk_occlusion_queries (102400 queries through the ring: 65536 distinct before, at most 32768 after), test_guest_discard_pages (now also built with ThreadSanitizer: eight threads' first discard and VirtualProtect at once; TSan reported the race before), test_dma_buf_route (new: no sparse binding and a udmabuf limit under the guest window refuses the route), test_sim_turf_settings (aborted on mprotect EINVAL before). test_mesh_mode_switch, test_device_policy, test_import_buffer_binding (updated to cut the udmabuf helpers) and test_udmabuf_limit_unreadable pass.
  • tests/test_lifter_semantics.py passed on AArch64: 126,846 runs over 42,375 words, 2,988 edge states and 4,000 sequences. test_fault_write_aarch64, test_cpu_relax, test_dev_build pass.
  • The whole game-free suite (tests/run_all.py --strict, as mise run test, with LONGSHOT_VULKAN_HEADERS and LONGSHOT_SPIRV_HEADERS set to /usr/include: no locked tools for linux-arm64) at 8e630258 on this AArch64 PC: 863 passed, 20 failed, 10 skipped. All 20 also fail on main (22d0d200) on the same PC, run the same way, and none touches a file this branch changes for them: three need cmake, which this PC lacks (f2i_immediate, global_load_16, native_suatom); test_lifter (clippy's needless_borrow in builder/crates/build-driver/src/play.rs); test_switch_table; and fixtures that miss functions or files the host now has: test_bug_report, test_check_cache, test_control_picture, test_crash_record, test_framegen_hdr, test_framegen_resources, test_guest_holes, test_input_background, test_log_open_failure, test_perf_send, test_pipeline_tour, test_present_source_crop, test_screensaver, test_temporal_present_bandwidth, test_xinput_thread. main also fails test_lifter_semantics here (-mcx16 on AArch64), which this branch fixes, and test_sim_turf_settings, fixed by 1b103d62.
  • mise run lint passes.
  • Reviewed x86-64 for behaviour changes. A test pins the x86 compile flags argument for argument. The Windows code path and 4 KB discards keep their behaviour. The dma-buf-only route needs sparse binding, or a udmabuf limit past the guest window, so a driver without host-pointer import that lacks both still refuses to start, as before.

Still to test:

  • Test Farm: a run on x86-64 Linux and on Windows (Tier 1), Steam Deck included. Build, start and load kokiri-start on each. Expect play with working input and no device loss, and no change in frame times from the 32768-query ring.
  • By hand on the Apple M5: the default settings (pipelines prepared at start-up, no memory-saving switches) once they fit in memory. Expect the title within the start-up budget and play without an out-of-memory kill. Today they don't fit: see Risks.

Measurements

Before: main @ 22d0d200 After: this PR @ 249a250b
Build on the Apple M5 (AArch64 Linux) fails: clang refuses -march=x86-64 and -mcx16 906 units, 0 failed
Kokiri Forest, 1800 presents of play (scripted, settings as in Testing) no game to run plays every run: 12.8-13.8 fps at the end, 13.4 fps steady (last 960 presents)
GPU time a frame, Kokiri Forest (Borealis's mesh shaders: all on the compute path at 8e630258, task + mesh alone at 0959a697; fewer argument batches at 249a250b) — 72 ms, 150 render passes → 57 ms, 134 passes → 46 ms, 121 passes
fps, 1800 presents of play: Kokiri Forest / castle gate / market entrance — 13.5 / 8.2 / 11.3 → 17.0 / 9.7 / 14.0 (0959a697) → 20.9 / 10.3 / 15.4 (249a250b)
The branch before the occlusion fix (e094c238~2), same runs device lost 40-50 s into play, every run plays, every run
test_vk_occlusion_queries: distinct queries out of 102400 65536 (more than Borealis's 32768 counters) 32768

Verdict: it helps. The game builds and plays on AArch64 Linux, where main does not build; on the Apple M5 the device loss is gone (every run plays its 1800 presents, against a loss 40-50 s in before), at 20.9 fps in Kokiri Forest with memory-saving settings (13.5 with every mesh draw on the compute path). On x86-64 the fewer argument batches should help GPUs with native mesh shaders a little or not at all; the Test Farm is to confirm it.

These are --quick builds and scripted runs through the job queue's gpu mode, not timed runs: the queue's timing mode runs without swap, and the game needs swap on this 16 GB PC (a timing-mode run was killed for memory). On x86-64 the compile flags are identical argument for argument (a test pins them), and the changed host and renderer paths keep their x86-64 behaviour. The changes every GPU runs are the 32768-query occlusion ring and the fewer indirect mesh argument batches (native mesh shaders only), for the Test Farm to measure.

Switches: none added. Existing ones this branch reads, at their defaults: RX_MARCH (unset: the PC's own CPU features on AArch64, as on x86-64), RX_VK_NO_DMABUF (off: dma-bufs where udmabuf works), LONGSHOT_PREPARE_ONLY (off: a normal run), LONGSHOT_OWN_TOOLS (set by dev.py on linux-arm64 alone, where tools.lock has no tools) LONGSHOT_NO_CLANG (tests only, unset) and RX_TARGET (unset: the PC's own OS; windows builds the Windows game, whose lifted code is x86-64's, so llvm::Options::aarch64 is set only for a Linux game built on an Arm PC).

Risks

  • Memory on the Apple M5: the guest's memory (~7.7 GB resident in play) plus the driver's leaves little of 14.5 GB. Preparing every pipeline at start-up runs out of memory (RX_VK_PRECOMPILE=0 avoids it), and a cold Mesa shader cache (a new driver build) took the game to 6.4-6.9 GB of anonymous memory at the start of play, once over the edge.
  • The Borealis compiler refuses some vertex shaders with AGX3 binary packer refused iadd ... abs ... neg, and one compute pipeline (texture_sample operand gate); the renderer leaves those pipelines out.
  • The 32768-query ring holds half as many queries in flight. A full ring only leaves reports "visible" (no culling for them), never wrong.
  • RX_NVN_WATCH_* debug watches are coarser on 16 KB pages. Reverting the PR removes the Arm path and restores the old requirement for host-pointer import.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit. Rebased on 22d0d200.
  • 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).
  • 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 check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. Linux built on AArch64. Windows build verification is pending (Test Farm).
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

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

🤖 Generated with Claude Code

https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG

## Summary On AArch64 Linux, clang rejects the x86-64 flags that `main` passes. This branch builds Longshot for the host CPU and plays it on an Apple M5 under Asahi (16 KB pages, Borealis): Kokiri Forest from the `kokiri-start` save, played by hand and by 1800-present scripted runs, at about 13 fps with the memory-saving settings under Testing. - `af4cbcc5` selects the native Linux architecture in `builder/crates/build-compile/src/toolchain.rs`. It reads Arm CPU features, uses the AArch64 Linux Rust target and searches the AArch64 Vulkan library paths. AArch64 IR units use `-fno-global-isel` to work around an LLVM 22 crash. A minimal four-instruction reproducer uses no game content, and a test pins the flag. - `32c87a16` adds AArch64 host context switches, fault decoding, profiler sampling and spin waits. Start with `hos_posix_guest_discard` in `host/hos_main.c`. Whole host pages are discarded and partial pages are zeroed in place. Commit and protection ranges round to host pages. - `79b5f2e5` lets `memory_init` in `gpu/vk/vk_memory.cpp` start on the Linux dma-buf route without `VK_EXT_external_memory_host`. It aligns pools to host pages and guards the host-pointer fallback. Shader preparation can start without a guest window. The recorder uses an AArch64 spin pause. - `b5ca53a4` makes `scripts/devtools/build.py` select `linux-arm64` and use the system clang, lld, Vulkan, SPIR-V and VMA headers, FFmpeg and SDL2 via `LONGSHOT_OWN_TOOLS=1`. The Arm route installs no locked tools. - `efced427` makes Automatic run Borealis's mesh shaders on the compute path, as it does RADV's. Its native path lost the device in the first shadow passes (the depth-only 4096×4096 pass filled the tiler's buffer). Borealis is known by its `driverInfo`, since its driver ID (35) is not in the Vulkan registry. `RX_VK_MESH_SHADERS=native` still tries it. - `23e811aa` (test) and `e094c238` (fix): the occlusion query ring (`kOccPool`, `gpu/vk/vk_replay.cpp`) goes from 65536 to 32768 queries. Borealis gives each query index a counter from one heap of 32768, kept until the pool is destroyed. Past that, a draw's query failed to record (`VK_ERROR_OUT_OF_HOST_MEMORY`, "Descriptor table not large enough"), and the submission lost the device about 45 s into play, with no kernel message. A full ring only leaves reports "visible" (`occ_room`), so 32768 changes nothing for other GPUs but how many frames of queries can be in flight. - `154185f9`: where the compute fallback runs beside native mesh shaders, a mesh program whose native pipeline the driver refuses takes its fallback variant instead of being left out (on the M5, Borealis's compiler refuses one of OoT's mesh-only programs: one draw a frame). - `0959a697` replaces `efced427`'s rule: Automatic keeps Borealis's mesh shaders and runs only its task + mesh draws on the compute path (`task_mesh_fallback`, as for AMD's Navi 2x on Windows). Its native task + mesh path loses the device (in the 4096×4096 shadow pass and in a 128×128 render), its mesh-only draws do not, and every mesh draw on the compute path broke render passes: Kokiri Forest 13.5 → 17 fps, the castle gate 8.2 → 9.7, the market entrance 11.3 → 14. - `757a7214` (test) and `249a250b`: fewer indirect mesh argument batches (`RX_VK_MESH_CONV=2`, `mesh_conv_at_barrier`). The scan stopped at every counter's report, which is written on the CPU as it is replayed and records no GPU write (the batch's copies and the draws that take from it share one command buffer), so the occlusion pass's ~200 reports a frame cut it at each: each indirect mesh draw after one got a batch and a pass end of its own. And after a draw that may write memory dropped the batch, the draws after it converted one by one, a pass end each; they are now batched again right after that draw. Kokiri Forest 25 batches → 10, 134 render passes → 121: 17 → 20.9 fps. This runs on every GPU with native mesh shaders; `RX_VK_MESH_CONV=1` still converts at the draw. - `6603bc68` makes #2684's float middle path build on AArch64: its empty `asm` took x86-64's register class (`"=x,0"`), which clang refuses there, and 174 hot units failed to compile. `llvm::Options::aarch64` gives `"w"`; its text in the units' keys is unchanged on x86-64, so no lift there is redone. - `8e630258` builds #2036's native cloth kernels on AArch64: `game/cloth_sse_neon.hpp` gives the 98 x86 intrinsics they use with NEON, each with Intel's semantics, and `game/neon`'s `xmmintrin.h`, `emmintrin.h`, `smmintrin.h` and `immintrin.h` lead to it, before the compiler's own, for the game's C++ on AArch64 alone. The kernels themselves are unchanged. - Review answers: `a5a33ca4` / `9c5abcab` (L1, L2) ask for the page size each time instead of caching it on first use. `764ed9b6` / `6e0bd422` (L3) take the dma-buf-only route only where every pool can be imported. `1b103d62` fixes `test_sim_turf_settings` on 16 KB pages. Follow-ups for a release builder on Arm are the `linux-arm64` packages in `tools.lock` and the builder's `target_system()`. Also a follow-up, not in this branch: the renderer submits command buffers without checking `vkEndCommandBuffer`'s result (`part_submit`, `submit_recording`), so a driver's recording error reads as a lost device. See #420 and #966. Mooki's paused macOS port runs natively on Apple silicon. This PR takes no code from it. The overlap is the Arm host and 16 KB pages. ## Testing **Tested:** - Apple M5 (10 cores, 14.5 GB unified memory), Linux 7.3.0 (Asahi-style kernel, 16 KB pages), Aurora Fedora Remix 44, KDE Wayland. Mesa 26.3.0-devel Borealis (git `78d817d933`), Vulkan 1.4. Fedora clang 22.1.8 and mise Rust 1.99.1, with system tools via `LONGSHOT_OWN_TOOLS=1`. - In the game, at head `8e630258` on `main` @ `22d0d200` (`dev.py game --quick` from my own dump, 924 units, zero failed): boots, intro, title and menu, Kokiri Forest from `kokiri-start`. Scripted runs through the job queue (headless, A pressed until play, then 1800 presents of play): still running after 1800 presents every time since the occlusion fix (at head: frame 3054, 13.8 fps, 705 draws a frame with `HOS_NATIVE_CLOTH=check`; frame 3071, 11.8 fps with the cloth's default). I also played it by hand in a window, keyboard input, until I closed it. - Settings of these runs: `RX_VK_PRECOMPILE=0` (pipelines built at first draw) and memory-saving switches (`HOS_OUTPUT_RES=1920x1080 HOS_RES_SCALE=0.5 HOS_DYNRES=0 RX_VK_VRAM_MB=640 RX_VK_TARGET_POOL_MB=64 RX_VK_WORKERS=1 RX_VK_LOAD_WORKERS=1 RX_VK_COMPUTE_SERIAL=1 RX_VK_MIRROR=0 RX_VK_WB_SHADOW_MB=0 RX_VK_FRAMEGEN=0 RX_VK_AUTO_TUNE=0`), with 16 GB of swap (8 GB zram, 8 GB file). Without `RX_VK_PRECOMPILE=0`, building every pipeline at start-up runs out of memory on this PC. - The occlusion fix, before and after: at `e094c238~2` every scripted run lost the device 40-50 s into play. With `MESA_VK_ABORT_ON_DEVICE_LOSS=1` and uprobes on Mesa's `__vk_errorf` and `_vk_queue_set_lost`, the cause was `hk_ensure_occlusion_query_for_draw` returning `VK_ERROR_OUT_OF_HOST_MEMORY` (counter heap full), then `submitted a command buffer recorded with VK_ERROR_OUT_OF_HOST_MEMORY`. With `RX_VK_OCC_QUERIES=0` the same run played. At `e094c238`, with the queries on, it plays. - The native cloth kernels on NEON, in the game with `HOS_NATIVE_CLOTH=check` (every call also run lifted and compared): Kokiri Forest, 1800 presents, about 905,000 calls of thirteen kernels compared (cull 181,709; capsule tail 128,189; link 79,884; aabb, anchor, bones, tether, verlet about 62,000 each; bend link 58,263; pm and skin 48,210 each; bend 37,142; capsule 12,375), 0 mismatches. With the kernels at their default (on), the same run played its 1800 presents. Game-free: `test_cloth_sse_neon` (413 cases against Intel's definitions, written apart from the header, -O0 and -O2) and every cloth test built the same way on AArch64 (`test_cloth_kernels`, `test_cloth_step8`, `_step9`, `_step12`, `test_cloth_loops`, `test_cloth_sphere`, `test_oot_cloth`, `_60`, `_time`): pass. - Game-free tests, each failing on the code before its fix and passing after, with g++ and clang++: `test_vk_occlusion_queries` (102400 queries through the ring: 65536 distinct before, at most 32768 after), `test_guest_discard_pages` (now also built with ThreadSanitizer: eight threads' first discard and `VirtualProtect` at once; TSan reported the race before), `test_dma_buf_route` (new: no sparse binding and a udmabuf limit under the guest window refuses the route), `test_sim_turf_settings` (aborted on `mprotect` `EINVAL` before). `test_mesh_mode_switch`, `test_device_policy`, `test_import_buffer_binding` (updated to cut the udmabuf helpers) and `test_udmabuf_limit_unreadable` pass. - `tests/test_lifter_semantics.py` passed on AArch64: 126,846 runs over 42,375 words, 2,988 edge states and 4,000 sequences. `test_fault_write_aarch64`, `test_cpu_relax`, `test_dev_build` pass. - The whole game-free suite (`tests/run_all.py --strict`, as `mise run test`, with `LONGSHOT_VULKAN_HEADERS` and `LONGSHOT_SPIRV_HEADERS` set to `/usr/include`: no locked tools for linux-arm64) at `8e630258` on this AArch64 PC: 863 passed, 20 failed, 10 skipped. All 20 also fail on `main` (`22d0d200`) on the same PC, run the same way, and none touches a file this branch changes for them: three need cmake, which this PC lacks (`f2i_immediate`, `global_load_16`, `native_suatom`); `test_lifter` (clippy's `needless_borrow` in `builder/crates/build-driver/src/play.rs`); `test_switch_table`; and fixtures that miss functions or files the host now has: `test_bug_report`, `test_check_cache`, `test_control_picture`, `test_crash_record`, `test_framegen_hdr`, `test_framegen_resources`, `test_guest_holes`, `test_input_background`, `test_log_open_failure`, `test_perf_send`, `test_pipeline_tour`, `test_present_source_crop`, `test_screensaver`, `test_temporal_present_bandwidth`, `test_xinput_thread`. `main` also fails `test_lifter_semantics` here (`-mcx16` on AArch64), which this branch fixes, and `test_sim_turf_settings`, fixed by `1b103d62`. - `mise run lint` passes. - Reviewed x86-64 for behaviour changes. A test pins the x86 compile flags argument for argument. The Windows code path and 4 KB discards keep their behaviour. The dma-buf-only route needs sparse binding, or a udmabuf limit past the guest window, so a driver without host-pointer import that lacks both still refuses to start, as before. **Still to test:** - Test Farm: a run on x86-64 Linux and on Windows (Tier 1), Steam Deck included. Build, start and load `kokiri-start` on each. Expect play with working input and no device loss, and no change in frame times from the 32768-query ring. - By hand on the Apple M5: the default settings (pipelines prepared at start-up, no memory-saving switches) once they fit in memory. Expect the title within the start-up budget and play without an out-of-memory kill. Today they don't fit: see Risks. ## Measurements | | Before: main @ `22d0d200` | After: this PR @ `249a250b` | |---|---|---| | Build on the Apple M5 (AArch64 Linux) | fails: clang refuses `-march=x86-64` and `-mcx16` | 906 units, 0 failed | | Kokiri Forest, 1800 presents of play (scripted, settings as in Testing) | no game to run | plays every run: 12.8-13.8 fps at the end, 13.4 fps steady (last 960 presents) | | GPU time a frame, Kokiri Forest (Borealis's mesh shaders: all on the compute path at `8e630258`, task + mesh alone at `0959a697`; fewer argument batches at `249a250b`) | — | 72 ms, 150 render passes → 57 ms, 134 passes → 46 ms, 121 passes | | fps, 1800 presents of play: Kokiri Forest / castle gate / market entrance | — | 13.5 / 8.2 / 11.3 → 17.0 / 9.7 / 14.0 (`0959a697`) → 20.9 / 10.3 / 15.4 (`249a250b`) | | The branch before the occlusion fix (`e094c238~2`), same runs | device lost 40-50 s into play, every run | plays, every run | | `test_vk_occlusion_queries`: distinct queries out of 102400 | 65536 (more than Borealis's 32768 counters) | 32768 | Verdict: it helps. The game builds and plays on AArch64 Linux, where `main` does not build; on the Apple M5 the device loss is gone (every run plays its 1800 presents, against a loss 40-50 s in before), at 20.9 fps in Kokiri Forest with memory-saving settings (13.5 with every mesh draw on the compute path). On x86-64 the fewer argument batches should help GPUs with native mesh shaders a little or not at all; the Test Farm is to confirm it. These are `--quick` builds and scripted runs through the job queue's `gpu` mode, not timed runs: the queue's timing mode runs without swap, and the game needs swap on this 16 GB PC (a timing-mode run was killed for memory). On x86-64 the compile flags are identical argument for argument (a test pins them), and the changed host and renderer paths keep their x86-64 behaviour. The changes every GPU runs are the 32768-query occlusion ring and the fewer indirect mesh argument batches (native mesh shaders only), for the Test Farm to measure. Switches: none added. Existing ones this branch reads, at their defaults: `RX_MARCH` (unset: the PC's own CPU features on AArch64, as on x86-64), `RX_VK_NO_DMABUF` (off: dma-bufs where udmabuf works), `LONGSHOT_PREPARE_ONLY` (off: a normal run), `LONGSHOT_OWN_TOOLS` (set by `dev.py` on linux-arm64 alone, where `tools.lock` has no tools) `LONGSHOT_NO_CLANG` (tests only, unset) and `RX_TARGET` (unset: the PC's own OS; `windows` builds the Windows game, whose lifted code is x86-64's, so `llvm::Options::aarch64` is set only for a Linux game built on an Arm PC). ## Risks - Memory on the Apple M5: the guest's memory (~7.7 GB resident in play) plus the driver's leaves little of 14.5 GB. Preparing every pipeline at start-up runs out of memory (`RX_VK_PRECOMPILE=0` avoids it), and a cold Mesa shader cache (a new driver build) took the game to 6.4-6.9 GB of anonymous memory at the start of play, once over the edge. - The Borealis compiler refuses some vertex shaders with `AGX3 binary packer refused iadd ... abs ... neg`, and one compute pipeline (`texture_sample` operand gate); the renderer leaves those pipelines out. - The 32768-query ring holds half as many queries in flight. A full ring only leaves reports "visible" (no culling for them), never wrong. - `RX_NVN_WATCH_*` debug watches are coarser on 16 KB pages. Reverting the PR removes the Arm path and restores the old requirement for host-pointer import. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. Rebased on `22d0d200`. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [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 check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. Linux built on AArch64. Windows build verification is pending (Test Farm). - [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. Test Farm runs are pending. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). Tier 1 runs are pending. - [ ] Approved in review, every comment answered. Review is pending. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. CI, base confirmation and measurements are pending. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
A Linux game is built for the PC's own processor: on an AArch64 PC the
compile no longer passes x86-64's flags, which clang refuses there.

- toolchain.rs: an Arch (x86-64 for every Windows game and an x86-64
  PC's Linux game, AArch64 on an Arm PC). -mcx16 is x86-64's alone
  (Arch::atomics). The AArch64 CPU flags come from /proc/cpuinfo's
  Features (arm_march): clang 22 does not know the newest Apple cores,
  and -march=native gave a generic Armv8-A with two extensions.
- The lift's IR units take -fno-global-isel on AArch64 (Arch::ir_units):
  LLVM 22's GlobalISel, clang's selector at -O0 there (the cold units),
  stops in lowerCopy on a vector lane truncated into an atomic store
  (a guest STLR of a NEON register's value); one cold unit of the game
  crashed clang (exit 133) at every build.
- The game's Rust for aarch64-unknown-linux-gnu (linux-arm64); the
  Vulkan driver search also looks in the aarch64 library folders.
- The lift's and the IR writer's tests, and the lifter semantics check,
  pass -mcx16 only on x86-64.

x86-64's flags are unchanged, argument for argument (a new test pins
them), so no x86-64 player's objects compile again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
The host's x86-64 parts get their AArch64 forms, and memory the guest
frees reads as zero on a PC whose page is larger than the console's.

- Freed guest memory (hos_posix_guest_discard): the guest frees at 4 KB;
  on a 16 KB-page kernel (Apple's chips under Asahi) madvise refused the
  4 KB-aligned range (EINVAL) and the bytes stayed, so the game read old
  data where it expects zeros and wrote through it: a store to guest
  address -1 on the scene thread 3 s in. Now exactly the bytes asked for
  read as zero: whole host pages given back, the parts of the end pages
  zeroed in place. Elsewhere (discard_pages) only whole host pages;
  VirtualAlloc's commit and VirtualProtect round to the host's page.
- setjmp / longjmp (hos_setjmp.c): AAPCS64's callee-saved registers,
  x19-x28, the frame and return address, sp, d8-d15 and FPCR; back with
  RET, so branch protection takes the return address as any return.
- Faults (win32_posix.c): the pc, sp and frame pointer from the signal
  frame; a write is the data abort's WnR bit in the kernel's ESR record.
  The profiler's samples read the pc the same way (prof.c).
- Spin waits: hos_cpu_relax (hos.h), PAUSE on x86-64 and ISB on AArch64
  (YIELD is a NOP on most cores), for the mutex spins (nn_os_sync.c,
  hos_svc.c) that ran only on x86-64, the present poll (hos_thread.c)
  and YieldProcessor (posix/windows.h), which was x86's builtin alone
  and linked as an undefined symbol on AArch64.

Game-free checks: test_guest_discard_pages (fails on main on a 16 KB
kernel: madvise EINVAL), test_fault_write_aarch64, test_cpu_relax.
On x86-64 every range was whole 4 KB pages already: nothing changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
The renderer refused to start without VK_EXT_external_memory_host, also
where every pool goes to the GPU as a dma-buf of the guest window's memfd
(import_dma_buf) and a host pointer is never imported. Borealis, Mesa's
driver for Apple's GPUs under Asahi, has VK_EXT_external_memory_dma_buf
and no host-pointer import, so nothing was drawn.

- memory_init accepts a device without the extension when the dma-buf
  route is there (dma_buf_route: the memfd window, /dev/udmabuf, the
  driver's dma-buf import, not NVIDIA's driver), and a --prepare-shaders
  run, which imports no guest memory. The pools are aligned to the host
  page at least (udmabuf takes only whole ones: 16 KB on those PCs).
- import_pool no longer falls back to a host-pointer import where the
  extension is missing (its function would be a null pointer).
- The recorder's spin pause is ISB on AArch64 (cpu_pause).

With the extension present nothing changes: the same properties chain,
and the alignment is the driver's, at least 4096 as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
feat(dev): dev.py builds with the PC's own tools on an Arm PC
Some checks failed
PR description / Title and description (pull_request_target) Successful in 8s
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
553df5ae8f
tools.lock has no tools for linux-arm64, and installing the x86-64 ones
gives programs an AArch64 PC cannot run. dev.py names the system
linux-arm64 there and builds with LONGSHOT_OWN_TOOLS=1 alone: clang and
lld on the PATH, /usr's Vulkan, SPIR-V and VMA headers, pkg-config's
FFmpeg and the system's SDL2 (docs/dev/setup.md, Linux).

The tests pin the processor (ARM64, as they pin WINDOWS), so they say
the same on every PC; a new one checks the Arm route installs nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
Author
First-time contributor

Tested in game: Apple M5 (10 cores, 14.5 GB unified), Linux 7.3.0 with 16 KB pages, Aurora Fedora Remix 44 (KDE Wayland), Mesa 26.3.0-devel Borealis (git 78d817d933), Vulkan 1.4, through the job queue: the game builds from my own dump (906 units, 0 failed), boots, plays the intro (screenshot of the night opening), title and menu, and loads Kokiri Forest from the repository's kokiri-start save; played by hand with the keyboard, input works, it reaches play with 900-3,700 draws a frame. Then the GPU is lost (VK_ERROR_DEVICE_LOST) in the first frames of play: the kernel's recovery shows the game's own depth-only 4096x4096 pass overflowing the tiler buffer with no growth, reproduced by a scripted run every time; ASAHI_MESA_DEBUG=nomerge does not change it. Being worked on with the driver; this is why the PR is WIP. Pipelines built at first draw (RX_VK_PRECOMPILE=0): building them all before the title does not fit in 14.5 GB on this driver. Not run on x86-64 Linux or Windows (no such hardware here).

Tested in game: Apple M5 (10 cores, 14.5 GB unified), Linux 7.3.0 with 16 KB pages, Aurora Fedora Remix 44 (KDE Wayland), Mesa 26.3.0-devel Borealis (git 78d817d933), Vulkan 1.4, through the job queue: the game builds from my own dump (906 units, 0 failed), boots, plays the intro (screenshot of the night opening), title and menu, and loads Kokiri Forest from the repository's kokiri-start save; played by hand with the keyboard, input works, it reaches play with 900-3,700 draws a frame. Then the GPU is lost (VK_ERROR_DEVICE_LOST) in the first frames of play: the kernel's recovery shows the game's own depth-only 4096x4096 pass overflowing the tiler buffer with no growth, reproduced by a scripted run every time; ASAHI_MESA_DEBUG=nomerge does not change it. Being worked on with the driver; this is why the PR is WIP. Pipelines built at first draw (RX_VK_PRECOMPILE=0): building them all before the title does not fit in 14.5 GB on this driver. Not run on x86-64 Linux or Windows (no such hardware here).
Member

Possibly related, for context:

  • issue #432 Idea: guest-memory fixes from the macOS port on Windows and Linux too, once timed (dirty-page atomics, zeroed pages marked, fatal allocation failures) — Open tracking issue for cross-platform guest-memory fixes, including Linux 16 KiB page behavior.
Possibly related, for context: - issue #432 Idea: guest-memory fixes from the macOS port on Windows and Linux too, once timed (dirty-page atomics, zeroed pages marked, fatal allocation failures) — Open tracking issue for cross-platform guest-memory fixes, including Linux 16 KiB page behavior.
Owner
@review
BeanBot left a comment

Recommendation: Request changes. The new page-size caches have unsynchronized first-use writes, and the dma-buf-only route can accept a device that cannot import pools needed for rendering. The reported Arm run also loses the GPU in the first frames of play.

The change enables native AArch64 Linux builds and fixes partial guest-page discards on larger host pages. It also changes shared host and Vulkan memory paths; the new route needs reliable pool handling and playable hardware validation before merge.

Blocking (1): must change before merging.

  1. L3 gpu/vk/vk_memory.cpp:849: The dma-buf-only startup check accepts devices without ensuring that required pools can be imported. (more on the line) Do: Provide a working fallback or split strategy for these pools, or reject the unsupported configuration before reporting successful initialization. Cover the no-host-pointer, no-sparse, oversized-pool case in a game-free test.

Should fix (2): not blocking, but worth doing before merging.

  • L1 host/hos_main.c:270: The cached page size is initialized with unsynchronized reads and writes from guest threads. (more on the line) Do: Initialize the page size before guest threads start, or publish it with a thread-safe once or atomic initialization.
  • L2 host/posix/win32_posix.c:715: host_page has the same unsynchronized first-use initialization in the POSIX allocation and protection paths. (more on the line) Do: Initialize this value before concurrent use or use a thread-safe once or atomic initialization.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L4: The target Arm configuration has not yet demonstrated playable rendering with the default pipeline preparation path. When: The reported M5 run loses the GPU in the first frames of Kokiri Forest; precompiling pipelines exceeds the reported 14.5 GB memory, and some vertex pipelines fail to compile. Do: After the driver fix or renderer workaround, run a timed build through Kokiri Forest with default settings, check the missing pipelines, and report startup memory and continued play.
  • L5: The shared host and renderer changes have not been exercised in game on the supported Tier 1 systems. When: The author has no x86-64 Linux or Windows game run, so the changed allocation, protection and renderer initialization paths have no reported play validation there. Do: Run the Test Farm build and Kokiri Forest play checks on affected Tier 1 Windows and Linux configurations, including Steam Deck, and report the results.

@fix can do L1, L2 and L3.

Checks: Still running: 10 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven as a playable port: the author reports a 906-unit build, a successful boot and menu, and entry into Kokiri Forest, but device loss in the first frames. The 16 KB discard test reportedly fails on main and passes here.

Other systems: The host page and Vulkan memory changes also run on x86-64 Linux; Windows uses the changed shared host headers and spin-wait callers. The author reports no x86-64 Linux or Windows game run. Tier 1 GPU and Steam Deck coverage remains pending; the Arm run used first-draw pipeline compilation and reported omitted vertex pipelines and excessive precompile memory use.

Switches: No switches added or removed. Existing RX_MARCH now selects the AArch64 architecture when set; otherwise detected Arm features are used. Existing LONGSHOT_OWN_TOOLS is enabled by default for the Arm dev.py toolchain route. Existing dma-buf and background-import switches also affect the new route; their defaults were not changed.

Reviewed: 553df5ae8f against a3591a98c9: Read the available repository rules, PR template, standards, diff and commit messages; examined the changed host, renderer, builder, development tool and test paths and their relevant callers. The recorded runs are the PR description and comment. No generated files or translations were changed. The separate Tooling checkout and docs/review-checklist.md were not available in the supplied review material.; nothing run (a code review).

Checked and fine:

  • All four commits record AI assistance in trailers.
  • No third-party, shader, generated interface or game-derived file appears in the diff.
  • The Arm setjmp buffer has space for the registers added by this change.
  • The reported game-free discard test covers both anonymous and memfd guest mappings.

Testing: Read-only review; no builds, tests or project scripts were run. The author reports 845 game-free checks passed, seven failures also present on main, and 12 skips; CI is still running.

Overlaps and merge order: The description names #420 and #966 and a paused macOS port; no overlapping pull request was established from the supplied material.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The new page-size caches have unsynchronized first-use writes, and the dma-buf-only route can accept a device that cannot import pools needed for rendering. The reported Arm run also loses the GPU in the first frames of play. The change enables native AArch64 Linux builds and fixes partial guest-page discards on larger host pages. It also changes shared host and Vulkan memory paths; the new route needs reliable pool handling and playable hardware validation before merge. **Blocking (1)**: must change before merging. 1. **L3** `gpu/vk/vk_memory.cpp:849`: The dma-buf-only startup check accepts devices without ensuring that required pools can be imported. (more on the line) **Do:** Provide a working fallback or split strategy for these pools, or reject the unsupported configuration before reporting successful initialization. Cover the no-host-pointer, no-sparse, oversized-pool case in a game-free test. **Should fix (2)**: not blocking, but worth doing before merging. - **L1** `host/hos_main.c:270`: The cached page size is initialized with unsynchronized reads and writes from guest threads. (more on the line) **Do:** Initialize the page size before guest threads start, or publish it with a thread-safe once or atomic initialization. - **L2** `host/posix/win32_posix.c:715`: host_page has the same unsynchronized first-use initialization in the POSIX allocation and protection paths. (more on the line) **Do:** Initialize this value before concurrent use or use a thread-safe once or atomic initialization. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L4**: The target Arm configuration has not yet demonstrated playable rendering with the default pipeline preparation path. *When:* The reported M5 run loses the GPU in the first frames of Kokiri Forest; precompiling pipelines exceeds the reported 14.5 GB memory, and some vertex pipelines fail to compile. **Do:** After the driver fix or renderer workaround, run a timed build through Kokiri Forest with default settings, check the missing pipelines, and report startup memory and continued play. - **L5**: The shared host and renderer changes have not been exercised in game on the supported Tier 1 systems. *When:* The author has no x86-64 Linux or Windows game run, so the changed allocation, protection and renderer initialization paths have no reported play validation there. **Do:** Run the Test Farm build and Kokiri Forest play checks on affected Tier 1 Windows and Linux configurations, including Steam Deck, and report the results. `@fix` can do L1, L2 and L3. **Checks:** Still running: 10 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven as a playable port: the author reports a 906-unit build, a successful boot and menu, and entry into Kokiri Forest, but device loss in the first frames. The 16 KB discard test reportedly fails on main and passes here. **Other systems:** The host page and Vulkan memory changes also run on x86-64 Linux; Windows uses the changed shared host headers and spin-wait callers. The author reports no x86-64 Linux or Windows game run. Tier 1 GPU and Steam Deck coverage remains pending; the Arm run used first-draw pipeline compilation and reported omitted vertex pipelines and excessive precompile memory use. **Switches:** No switches added or removed. Existing RX_MARCH now selects the AArch64 architecture when set; otherwise detected Arm features are used. Existing LONGSHOT_OWN_TOOLS is enabled by default for the Arm dev.py toolchain route. Existing dma-buf and background-import switches also affect the new route; their defaults were not changed. **Reviewed:** 553df5ae8f00 against a3591a98c9b2: Read the available repository rules, PR template, standards, diff and commit messages; examined the changed host, renderer, builder, development tool and test paths and their relevant callers. The recorded runs are the PR description and comment. No generated files or translations were changed. The separate Tooling checkout and docs/review-checklist.md were not available in the supplied review material.; nothing run (a code review). **Checked and fine:** - All four commits record AI assistance in trailers. - No third-party, shader, generated interface or game-derived file appears in the diff. - The Arm setjmp buffer has space for the registers added by this change. - The reported game-free discard test covers both anonymous and memfd guest mappings. **Testing:** Read-only review; no builds, tests or project scripts were run. The author reports 845 game-free checks passed, seven failures also present on main, and 12 skips; CI is still running. **Overlaps and merge order:** The description names #420 and #966 and a paused macOS port; no overlapping pull request was established from the supplied material. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -818,0 +846,4 @@
#ifdef __linux__
if (const long s = sysconf(_SC_PAGESIZE); s > 0) host_page = std::max<uint64_t>(host_page, (uint64_t)s);
#endif
if (!dev.external_memory_host) {
Member

L3 (blocking): The dma-buf-only startup check accepts devices without ensuring that required pools can be imported.

When: On a driver without host-pointer import or sparse buffers, a pool larger than udmabuf's piece limit is rejected by import_dma_buf; import_pool then has no fallback and pool lookup returns no buffer. The renderer starts successfully but cannot render work using that pool.

Do: Provide a working fallback or split strategy for these pools, or reject the unsupported configuration before reporting successful initialization. Cover the no-host-pointer, no-sparse, oversized-pool case in a game-free test.

**L3** (blocking): The dma-buf-only startup check accepts devices without ensuring that required pools can be imported. *When:* On a driver without host-pointer import or sparse buffers, a pool larger than udmabuf's piece limit is rejected by import_dma_buf; import_pool then has no fallback and pool lookup returns no buffer. The renderer starts successfully but cannot render work using that pool. **Do:** Provide a working fallback or split strategy for these pools, or reject the unsupported configuration before reporting successful initialization. Cover the no-host-pointer, no-sparse, oversized-pool case in a game-free test.
host/hos_main.c Outdated
@ -265,2 +268,3 @@
back, the parts of the host pages at either end zeroed in place (their other bytes are the guest's live memory) */
int hos_posix_guest_discard(void *p, size_t n) {
return madvise(p, n, hos_guest_memfd >= 0 ? MADV_REMOVE : MADV_DONTNEED);
static uintptr_t page;
Member

L1 (should fix): The cached page size is initialized with unsynchronized reads and writes from guest threads.

When: Two threads freeing guest memory for the first time can enter hos_posix_guest_discard together and race on page. This is a C data race, so the discard calculation has undefined behavior.

Do: Initialize the page size before guest threads start, or publish it with a thread-safe once or atomic initialization.

**L1** (should fix): The cached page size is initialized with unsynchronized reads and writes from guest threads. *When:* Two threads freeing guest memory for the first time can enter hos_posix_guest_discard together and race on page. This is a C data race, so the discard calculation has undefined behavior. **Do:** Initialize the page size before guest threads start, or publish it with a thread-safe once or atomic initialization.
@ -712,1 +712,4 @@
MADV_DONTNEED leaves a shared mapping's pages as they were; MADV_DONTNEED elsewhere */
/* (the host's page: 4 KB on x86-64, 16 KB or 64 KB on some Arm PCs, where mprotect and madvise take only whole ones) */
static uintptr_t host_page(void) {
static uintptr_t page;
Member

L2 (should fix): host_page has the same unsynchronized first-use initialization in the POSIX allocation and protection paths.

When: Concurrent first calls to VirtualAlloc, VirtualProtect or a non-guest discard can read and write page simultaneously, causing a C data race while computing protection or discard ranges.

Do: Initialize this value before concurrent use or use a thread-safe once or atomic initialization.

**L2** (should fix): host_page has the same unsynchronized first-use initialization in the POSIX allocation and protection paths. *When:* Concurrent first calls to VirtualAlloc, VirtualProtect or a non-guest discard can read and write page simultaneously, causing a C data race while computing protection or discard ranges. **Do:** Initialize this value before concurrent use or use a thread-safe once or atomic initialization.
Honeykrisp (Mesa's driver for Apple's GPUs, and Borealis, its fork)
gives each query of an occlusion pool a counter the first time it is
begun, keeps it until the pool is destroyed, and has 32768 for all pools
(AGX_MAX_OCCLUSION_QUERIES). The ring numbers 65536 queries (kOccPool),
so about 45 s into play on an Apple M5 a draw's query failed to record
("Descriptor table not large enough", VK_ERROR_OUT_OF_HOST_MEMORY) and
the next submission lost the device.

The check runs 102400 queries through vk_replay.cpp's ring and counts the
distinct ones it hands out. It fails here: 65536.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
fix(vk): the occlusion query ring holds 32768 queries, as Honeykrisp counts
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
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
3afc6ecf78
Honeykrisp (and Borealis, its fork, on Apple's GPUs under Asahi) keeps a
counter for each query of a pool once begun, until the pool is destroyed,
and has 32768 in all. The 65536-query ring ran out of them about 45 s
into play on an Apple M5: a draw's query failed to record and the
submission lost the device, with nothing in the kernel's log.

32768 still holds a few frames of queries; a full ring only leaves
reports "visible" (occ_room). On the M5, Kokiri Forest now plays 1800
presents with the queries on, where every run lost the device before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
fix(tests): the simulated-turf settings check maps whole pages of the PC's size
Some checks failed
PR description / Title and description (pull_request_target) Successful in 8s
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
9740d8d16c
It made 4 KB at 0x84e42000 of its stand-in guest window writable, which
is not the start of a page where pages are 16 KB (an Apple M5 under
Asahi): mprotect failed (EINVAL) and the check aborted before testing
anything. It now makes the pages around that range writable, whatever
their size; on 4 KB pages that is the same range as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
Review L1/L2 on #2692: hos_posix_guest_discard and win32_posix.c's
host_page() cache the host's page size in a static filled in on first
use, a data race when guest threads make their first calls together.

The discard check also builds its cut functions with ThreadSanitizer
(clang's, or --cc's when it has the runtime; said when none does) and
has eight threads make their first discard and VirtualProtect at once.
It fails here: ThreadSanitizer reports the race in
hos_posix_guest_discard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
hos_posix_guest_discard and win32_posix.c's host_page() kept the page
size in a static filled in on first use: two guest threads making their
first discard, VirtualAlloc or VirtualProtect at once raced on it, a
data race in C (review L1/L2 on #2692). sysconf(_SC_PAGESIZE) answers
from what glibc read at start-up, so it is asked each time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
Review L3 on #2692: a driver with no host-pointer import takes the
dma-buf route (dma_buf_route) without sparse binding too, where a pool
larger than one dma-buf (udmabuf's size_limit_mb, 64 MB unless raised)
is never imported: the renderer starts, and nothing is drawn from it.

The check cuts dma_buf_route out of vk_memory.cpp and runs it against a
stand-in device, /dev/udmabuf and limit file: with no sparse binding it
should refuse the route unless udmabuf's limit holds the whole guest
window. It fails here: the route is taken in all four such cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
fix(vk): no dma-buf-only start where a pool could never be imported
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
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
a824e19184
On a driver with no host-pointer import, the guest memory goes to the
GPU as dma-bufs alone. A pool larger than one dma-buf may be is several,
bound into a sparse buffer; with no sparse binding it was never
imported, though the renderer had started (review L3 on #2692). The
route is now taken only with sparse binding, or where udmabuf's limit
(and RX_VK_DMABUF_PIECE_MB) holds the whole guest window; else start-up
stops and says what is missing. Reading the limit is one function for
both the route and import_dma_buf.

On the Apple M5 nothing changes: Borealis has sparse binding, and the
kernel's size_limit_mb is 2147483647.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
fix(vk): Automatic runs Borealis's mesh shaders on the compute path
Some checks failed
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Title and description (pull_request_target) Successful in 8s
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
5bb26a7863
Borealis (Mesa's Honeykrisp fork for Apple's GPUs under Asahi) offers
task and mesh shaders, and on an Apple M5 (G17G) its native path lost
the device in OoT's first shadow passes: the depth-only 4096x4096 pass
filled the tiler's buffer whatever its size (128 blocks; 256 with the
kernel's floor raised). On the compute fallback the same passes drew and
the game reached play. Automatic now takes the compute path for it, as
it does for RADV, by its driverInfo ("Borealis, derived from
Honeykrisp"): its driver ID (35) is its own, not in the Vulkan registry.
RX_VK_MESH_SHADERS=native still tries the driver's own.

The mesh-mode check covers the rule, the log's note and that Automatic
decides it after asking the driver who it is; device_policy.h's
mesh_mode agrees.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
Author
First-time contributor

Answers to the review of 553df5ae (head now 5bb26a78):

  • L1, L2 (page-size races): 6e5e0cdf (test) and f934d955 (fix). hos_posix_guest_discard and host_page() ask sysconf(_SC_PAGESIZE) each time instead of filling a static on first use; glibc answers from the value it read at start-up. test_guest_discard_pages now also builds the cut functions with ThreadSanitizer and has eight threads make their first discard and VirtualProtect at once: TSan reported the race in hos_posix_guest_discard before the fix, nothing after.
  • L3 (dma-buf-only route): ec7a50d5 (test) and a824e191 (fix). The route is taken only with sparse binding, or where udmabuf's limit (and RX_VK_DMABUF_PIECE_MB) holds the whole guest window; otherwise start-up stops and the log says what is missing. New test_dma_buf_route covers the no-host-pointer, no-sparse, oversized-pool case: the route was taken in all four such cases before the fix. On the Apple M5 nothing changes (Borealis has sparse binding; size_limit_mb is 2147483647).
  • L4 (playable on the target): the device loss is fixed. Two causes: Borealis's native mesh path (5bb26a78: Automatic now uses the compute path there) and the occlusion query ring being larger than Borealis's 32768 counters (f6ee5270 / 3afc6ecf). Kokiri Forest now plays: 1800-present scripted runs every time, and by hand. Default settings still do not fit in 14.5 GB (start-up pipeline preparation runs out of memory), so the runs use RX_VK_PRECOMPILE=0 and memory-saving switches; the description says which, and keeps this under Risks and Still to test.
  • L5 (Tier 1): still pending; it needs a Test Farm run, which I will ask for.

Also new: 9740d8d1 fixes test_sim_turf_settings on 16 KB pages. Full suite on this PC: 847 passed, 9 failed (6 fail on main too, 3 need cmake), as Testing says.

Answers to the review of `553df5ae` (head now `5bb26a78`): - **L1, L2** (page-size races): `6e5e0cdf` (test) and `f934d955` (fix). `hos_posix_guest_discard` and `host_page()` ask `sysconf(_SC_PAGESIZE)` each time instead of filling a static on first use; glibc answers from the value it read at start-up. `test_guest_discard_pages` now also builds the cut functions with ThreadSanitizer and has eight threads make their first discard and `VirtualProtect` at once: TSan reported the race in `hos_posix_guest_discard` before the fix, nothing after. - **L3** (dma-buf-only route): `ec7a50d5` (test) and `a824e191` (fix). The route is taken only with sparse binding, or where udmabuf's limit (and `RX_VK_DMABUF_PIECE_MB`) holds the whole guest window; otherwise start-up stops and the log says what is missing. New `test_dma_buf_route` covers the no-host-pointer, no-sparse, oversized-pool case: the route was taken in all four such cases before the fix. On the Apple M5 nothing changes (Borealis has sparse binding; `size_limit_mb` is 2147483647). - **L4** (playable on the target): the device loss is fixed. Two causes: Borealis's native mesh path (`5bb26a78`: Automatic now uses the compute path there) and the occlusion query ring being larger than Borealis's 32768 counters (`f6ee5270` / `3afc6ecf`). Kokiri Forest now plays: 1800-present scripted runs every time, and by hand. Default settings still do not fit in 14.5 GB (start-up pipeline preparation runs out of memory), so the runs use `RX_VK_PRECOMPILE=0` and memory-saving switches; the description says which, and keeps this under Risks and Still to test. - **L5** (Tier 1): still pending; it needs a Test Farm run, which I will ask for. Also new: `9740d8d1` fixes `test_sim_turf_settings` on 16 KB pages. Full suite on this PC: 847 passed, 9 failed (6 fail on `main` too, 3 need cmake), as Testing says.
Author
First-time contributor

@Beanstalk Please build this PR's head and run it on the Tier 1 machines: x86-64 Linux (an AMD and an NVIDIA GPU if there are both), Windows, and the Steam Deck. On each: start the game with default settings, load the repository save kokiri-start, and play Kokiri Forest for a few minutes. Expect the title and menu, play with working input, and no device loss or crash. Please report each machine's average fps and frame time in Kokiri Forest, and the log lines vk: occlusion queries on and vk: mesh shaders:. This PR shrinks the occlusion query ring from 65536 to 32768 queries on every GPU, and changes host page-size and guest-memory import code that x86-64 also runs.

@Beanstalk Please build this PR's head and run it on the Tier 1 machines: x86-64 Linux (an AMD and an NVIDIA GPU if there are both), Windows, and the Steam Deck. On each: start the game with default settings, load the repository save `kokiri-start`, and play Kokiri Forest for a few minutes. Expect the title and menu, play with working input, and no device loss or crash. Please report each machine's average fps and frame time in Kokiri Forest, and the log lines `vk: occlusion queries on` and `vk: mesh shaders:`. This PR shrinks the occlusion query ring from 65536 to 32768 queries on every GPU, and changes host page-size and guest-memory import code that x86-64 also runs.
Member

@Kolkka only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 5bb26a7, and the PR has changed since (8e63025), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@Kolkka only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `5bb26a7`, and the PR has changed since (`8e63025`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Kolkka force-pushed builder/aarch64-linux from 5bb26a7863
Some checks failed
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Title and description (pull_request_target) Successful in 8s
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
to 8e63025829
Some checks failed
PR description / Title and description (pull_request_target) Successful in 12s
beanstalk/approval waiting for a BigBean's 👍 on the request
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
2026-11-28 18:56:03 +00:00
Compare
Author
First-time contributor

@Beanstalk Please build this PR's head (8e63025, rebased on main @ 22d0d200) and run it on the Tier 1 machines: x86-64 Linux (an AMD and an NVIDIA GPU if there are both), Windows, and the Steam Deck. On each: start the game with default settings, load the repository save kokiri-start, and play Kokiri Forest for a few minutes. Expect the title and menu, play with working input, and no device loss or crash. Please report each machine's average fps and frame time in Kokiri Forest, and the log lines vk: occlusion queries on, vk: mesh shaders: and oot: cloth:. This PR shrinks the occlusion query ring from 65536 to 32768 queries on every GPU, changes host page-size and guest-memory import code that x86-64 also runs, and adds a field to the lift's code-generation options whose key text is meant to stay the same on x86-64 (a build there should reuse its kept lifts, not lift again).

@Beanstalk Please build this PR's head (`8e63025`, rebased on `main` @ `22d0d200`) and run it on the Tier 1 machines: x86-64 Linux (an AMD and an NVIDIA GPU if there are both), Windows, and the Steam Deck. On each: start the game with default settings, load the repository save `kokiri-start`, and play Kokiri Forest for a few minutes. Expect the title and menu, play with working input, and no device loss or crash. Please report each machine's average fps and frame time in Kokiri Forest, and the log lines `vk: occlusion queries on`, `vk: mesh shaders:` and `oot: cloth:`. This PR shrinks the occlusion query ring from 65536 to 32768 queries on every GPU, changes host page-size and guest-memory import code that x86-64 also runs, and adds a field to the lift's code-generation options whose key text is meant to stay the same on x86-64 (a build there should reuse its kept lifts, not lift again).
Member

@Kolkka only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 8e63025, and the PR has changed since (0959a69), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@Kolkka only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `8e63025`, and the PR has changed since (`0959a69`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Where the compute fallback runs beside native mesh shaders
(dev.task_mesh_fallback: AMD's Navi 2x on Windows, and Borealis on
Apple's GPUs with RX_VK_TASK_MESH_FALLBACK=1), a draw whose native mesh
pipeline the driver refused was left out every frame. On an Apple M5,
Borealis's compiler refuses one of OoT's mesh-only programs
(d4abbcb4c2140609, VK_ERROR_UNKNOWN): one draw a frame in Kokiri Forest.

The draw that finds no pipeline marks its program refused, once, with a
log line, and the program's next lookup takes or makes its fallback
variant. Without the fallback beside native mesh shaders nothing
changes. Kokiri Forest on the M5 with native mesh and task + mesh on
the compute path: skipped draws 2 -> 1 a frame (the one the compute
path has too), 17.0 fps, no device loss.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
perf(vk): Automatic draws with Borealis's mesh shaders, its task + mesh draws on the compute path
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
beanstalk/approval waiting for a BigBean's 👍 on the request
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
0959a69737
5bb26a78 ran every mesh draw on Borealis (Apple's GPUs under Asahi) on
the compute path, its native path having lost the device in OoT's
4096x4096 shadow pass. Only its task + mesh draws do: native task + mesh
loses the device there and in a 128x128 render too, whichever passes they
are kept from, while its mesh-only draws run natively. Automatic now
keeps its mesh shaders and runs the task + mesh draws on the compute
path (task_mesh_fallback), as for AMD's Navi 2x on Windows; device_policy.h
agrees, and its mesh_mode takes RADV alone to the compute path again.

On an Apple M5 (Borealis 78d817d933), 1800 presents of play each:
Kokiri Forest 13.5 -> 16.9-17.2 fps (GPU 72 -> 57 ms a frame, 150 -> 134
render passes), the castle gate 8.2 -> 9.7, the market entrance
11.3 -> 14.0-14.1; no device loss. The one mesh-only program its
compiler refuses natively takes the compute fallback (154185f9).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
Author
First-time contributor

@Beanstalk Please build this PR's head (0959a69, on main @ 22d0d200) and run it on the Tier 1 machines: x86-64 Linux (an AMD and an NVIDIA GPU if there are both), Windows, and the Steam Deck. On each: start the game with default settings, load the repository save kokiri-start, and play Kokiri Forest for a few minutes. Expect the title and menu, play with working input, and no device loss or crash. Please report each machine's average fps and frame time in Kokiri Forest, and the log lines vk: occlusion queries on, vk: mesh shaders: and oot: cloth:. This PR shrinks the occlusion query ring from 65536 to 32768 queries on every GPU, changes host page-size and guest-memory import code that x86-64 also runs; on GPUs that run task + mesh draws on the compute path beside native mesh shaders (AMD Navi 2x on Windows), a mesh program whose native pipeline the driver refuses now takes the compute path instead of being left out, so please include one such machine if the farm has it; and the PR adds a field to the lift's code-generation options whose key text is meant to stay the same on x86-64 (a build there should reuse its kept lifts, not lift again).

@Beanstalk Please build this PR's head (`0959a69`, on `main` @ `22d0d200`) and run it on the Tier 1 machines: x86-64 Linux (an AMD and an NVIDIA GPU if there are both), Windows, and the Steam Deck. On each: start the game with default settings, load the repository save `kokiri-start`, and play Kokiri Forest for a few minutes. Expect the title and menu, play with working input, and no device loss or crash. Please report each machine's average fps and frame time in Kokiri Forest, and the log lines `vk: occlusion queries on`, `vk: mesh shaders:` and `oot: cloth:`. This PR shrinks the occlusion query ring from 65536 to 32768 queries on every GPU, changes host page-size and guest-memory import code that x86-64 also runs; on GPUs that run task + mesh draws on the compute path beside native mesh shaders (AMD Navi 2x on Windows), a mesh program whose native pipeline the driver refuses now takes the compute path instead of being left out, so please include one such machine if the farm has it; and the PR adds a field to the lift's code-generation options whose key text is meant to stay the same on x86-64 (a build there should reuse its kept lifts, not lift again).
Member

@Kolkka only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 0959a69, and the PR has changed since (249a250), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@Kolkka only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `0959a69`, and the PR has changed since (`249a250`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
tests/test_mesh_conv.py: the scan passes a counter's report (written on the
CPU as it is replayed, no GPU write), and once a draw that may write memory
drops the batch, the draws after it are batched again right after that draw
(vk_replay.cpp replay(), vk_draw.cpp mesh_batch_drop). The model batches
again after the dropping op; a new must-fail variant, rescan_at_drop, makes
that batch before the draw's write and reads stale arguments. Fails on the
current source: the scan stops at reports, and no batch is made after a drop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
perf(vk): fewer indirect mesh argument batches: past counters' reports, and once after a drop
Some checks are pending
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Title and description (pull_request_target) Successful in 5s
249a250bb1
RX_VK_MESH_CONV=2 converts the indirect mesh draws' arguments at the game's
barrier, up to the next barrier or op that may write memory. Two things cut
those batches short, and each indirect mesh draw then ended its pass:

- The scan stopped at every counter's report. A report is written on the
  CPU as it is replayed and records no GPU write; the batch's copies and the
  draws that take from it are in one command buffer, so both read the same
  memory. Kokiri Forest's occlusion pass has ~200 reports a frame: 25
  batches a frame, 6 with reports passed over.
- A draw that may write memory dropped the batch, and every indirect mesh
  draw after it was converted one by one, a pass end each. The replay now
  batches them again right after that draw: one pass end.

Apple M5, Borealis (native mesh-only draws, task + mesh on the compute
path), 1800 presents each: Kokiri Forest 16.9 -> 20.8 fps (GPU time 57.7 ->
46.5 ms a frame, 134 -> 121 passes), castle gate 9.6 -> 10.4, market
entrance 13.8 -> 15.1; no device loss, the picture unchanged.
RX_VK_MESH_CONV=1 still converts each draw at the draw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHuc6Vpni6h8picLF9VG
Author
First-time contributor

@Beanstalk Please build this PR's head (249a250b, on main @ 22d0d200) and run it on the Tier 1 machines: x86-64 Linux (an AMD and an NVIDIA GPU if there are both), Windows, and the Steam Deck. On each: start the game with default settings, load the repository save kokiri-start, and play Kokiri Forest for a few minutes. Expect the title and menu, play with working input, and no device loss or crash. Please report each machine's average fps and frame time in Kokiri Forest, and the log lines vk: occlusion queries on, vk: mesh shaders: and oot: cloth:. This PR shrinks the occlusion query ring from 65536 to 32768 queries on every GPU, changes host page-size and guest-memory import code that x86-64 also runs; on GPUs that run task + mesh draws on the compute path beside native mesh shaders (AMD Navi 2x on Windows), a mesh program whose native pipeline the driver refuses now takes the compute path instead of being left out, so please include one such machine if the farm has it; on GPUs with native mesh shaders (NVIDIA, RDNA 3 and later, Intel Arc) the indirect mesh draws' arguments are now converted in fewer batches, so please note the log line vk: a frame: indirect mesh draws' arguments with the fps; and the PR adds a field to the lift's code-generation options whose key text is meant to stay the same on x86-64 (a build there should reuse its kept lifts, not lift again).

@Beanstalk Please build this PR's head (`249a250b`, on `main` @ `22d0d200`) and run it on the Tier 1 machines: x86-64 Linux (an AMD and an NVIDIA GPU if there are both), Windows, and the Steam Deck. On each: start the game with default settings, load the repository save `kokiri-start`, and play Kokiri Forest for a few minutes. Expect the title and menu, play with working input, and no device loss or crash. Please report each machine's average fps and frame time in Kokiri Forest, and the log lines `vk: occlusion queries on`, `vk: mesh shaders:` and `oot: cloth:`. This PR shrinks the occlusion query ring from 65536 to 32768 queries on every GPU, changes host page-size and guest-memory import code that x86-64 also runs; on GPUs that run task + mesh draws on the compute path beside native mesh shaders (AMD Navi 2x on Windows), a mesh program whose native pipeline the driver refuses now takes the compute path instead of being left out, so please include one such machine if the farm has it; on GPUs with native mesh shaders (NVIDIA, RDNA 3 and later, Intel Arc) the indirect mesh draws' arguments are now converted in fewer batches, so please note the log line `vk: a frame: indirect mesh draws' arguments` with the fps; and the PR adds a field to the lift's code-generation options whose key text is meant to stay the same on x86-64 (a build there should reuse its kept lifts, not lift again).
Member

@Kolkka only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@Kolkka only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Some checks are pending
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Title and description (pull_request_target) Successful in 5s
This pull request has changes conflicting with the target branch.
  • builder/crates/build-compile/src/toolchain.rs
  • gpu/vk/vk_shader.cpp
  • host/posix/prof.c
  • tests/sim_turf_settings_test.cpp
Some workflows are waiting to be reviewed.
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'builder/aarch64-linux:Kolkka-builder/aarch64-linux'
git switch 'Kolkka-builder/aarch64-linux'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 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!2692
No description provided.