perf(vk): the shader store keeps its SPIR-V zstd-compressed #3023
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3023
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:perf/spirv-store-zstd"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The shared shader store keeps every program's SPIR-V once, but uncompressed: 3.7 GB for one translator's shaders, and 5 to 7 GB on a PC that has been updated a few times. SPIR-V compresses well, so each blob is now one zstd frame (level 1), or the words as they are where that would not be smaller. The same shaders take 0.99 GB.
On top of
mod-api(#2822). See #1649 (its "compress each stage", applied to the store from #1809).Read first:
gpu/vk/spirv_pack.h(format,put,read_words, compaction), thenkProgramCacheFormatandopen_recordedingpu/vk/vk_progcache.cpp, andstore_boundsinbuilder/crates/build-driver/src/shader_cache.rs.spirv.zpackandspirv.zidx, format 2. An older build takes a head of another version for damage and makes the store again, so the old names are left to the builds that read them.kProgramCacheFormat3 → 4, so a program cache naming an old store starts over.scripts/validate_spirv.pyread the new format.Related: #2153 changes
Store::read's file handles. Whichever lands second needs a small rebase.Testing
On the current head (
08ca00bc, rebased ontomod-api582b6a1awith no conflicts): the renderer builds on Linux (dev.py vk).mise run test: 824 passed, 35 failed, 12 skipped. The same 35 all fail on untouchedmod-api582b6a1a:test_astc_upload_chunking,test_async_astc_upload_chunks,test_bind_memo,test_blocks_at_start,test_direct_buffer_writes,test_drawn_page_map,test_draw_stream_visibility,test_early_split_before_draw,test_flat_map,test_fsr_image_retirement,test_fsr_uniform_ownership,test_image_reaper_threads,test_import_reach,test_late_fix_build,test_lifter,test_menu_i18n,test_mirror_bookkeeping,test_pass_barrier,test_present_acquire_ahead,test_present_image_free,test_readback_timeout_reuse,test_recorder_sync,test_recording_admission,test_report_words,test_staging_burst,test_target_retention,test_tex_desc_memo,test_text_keyboard_policy,test_ub_snapshot_default,test_ub_snapshot_gpu_writes,test_vk_wb_cpu_words_fast,test_vram_compact,test_wb_diff_stale_shadow,test_wb_pending_capture,test_wrote_regions.cargo test -p build-driver: 239 pass in the library tests, anda_copy_links_the_builders_files_clones_the_rest_and_refreshes_in_placefails withgame_folder_busy, as it does on that base. The game runs below were made before the rebases and not repeated.Tested: Linux, RTX 3090, NVIDIA 620.70.06. (before the rebases)
dev.py rtover based193d12d: the shader preparation filled the new store, 39,173 noted pipelines built, 0 not made.dev.py smoketwice: PASS both times (in play fromkokiri-start, 900 frames, menu opened). In both, the confined dev game could not reach the builder's store and used a fallback program cache with the player's default store (an earlier smoke log from 29 November, without this change, shows the same). The second run loaded the 544 programs the first had written there (56.6 MB of SPIR-V read from compressed blobs), with no read failures.mise run test: 836 passed, 10 failed, 12 skipped. The same 10 fail onmod-apiatf53e1c42:test_blocks_at_start,test_draw_stream_visibility,test_fsr_uniform_ownership,test_image_reaper_threads,test_lifter,test_readback_timeout_reuse,test_recording_admission,test_target_retention,test_tex_desc_memo,test_vram_compact.cargo test -p build-driver(244 passed in the library tests),cargo clippy -p build-driver --all-targets -D warnings,cargo fmt --check, pre-commit.tests/spirv_pack_test.cpphas new cases: a frame is smaller and read back by another start; a damaged frame is refused and written again; format 1's files are untouched; compaction keeps a frame readable.Still to test:
LONGSHOT_SHADER_STORE): programs load with no "did not read" lines (by hand).Measurements
Verdict: the same shaders take 3.7x less disk. Load time and fps were not measured.
Setup: Linux, RTX 3090. The store a preparation of this PR wrote (50,898 blobs); the sizes are the word counts and stored bytes in its index.
mainwas not run: its store (format 1, the samespirv_pack.hasmod-api's before this PR) keeps these words uncompressed, so the first column is their size. Measured on the head before the rebases, which did not change the format.dec32f72a18747beCost, from a one-thread Python and libzstd microbenchmark over 3,061 sampled blobs (rough, not a timed run): decompression about 67 µs for an average shader (91 KB) at about 1.35 GB/s, compression about 550 MB/s. LZ4 on the same sample decompressed about 3.5x faster but stored 1.7x as much.
Risks
spirv.packandspirv.idxstay for older builds until the player deletes them.shaders/<translator>/<driver>/folder is not keyed bykProgramCacheFormat, so a player who alternates an older build and this one with the same translator has each start replace the other's program cache (as with earlier format bumps). The store itself is not affected.scripts/validate_spirv.pyreads the new store only: a format-3 cache's stages inspirv.packneed that tree's script.Checklist
This PR's base is
mod-api: readmainbelow as the base.Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.🤖 Generated with Claude Code
feat(modapi): nav.closest, the closest point on the game's navmesh, made after its navmesh update ## Summary A first `longshot/nav` module: `nav.closest(position, { radius })` settles with the point on the game's own navmesh closest to a position (and its distance), or null. A mod can now put a spawned actor where a character could stand, check that a spot is walkable, or snap a marker to the ground, as the game's AI does (its `QueryGetClosestNavMeshPoint`). It is the first of the navmesh calls: paths, line of sight along the navmesh and a mod's own cuts come next, on the same site (`docs/dev/reference/nav.md`, "What comes next"). - **`game-core`**: - `nav` (new) asks the game's closest-point call (`nav.closest`, `f_80542dc0`). The request is built on the guest stack, as the game's callers build it (`layout::nav`), for the map's first character type, with the default filter and no navmesh object of the asker's own. - The manager comes from its variable (`nav.manager`, `0x84eaedb0`); 0 means no navmesh now. - Fixed slots hand queries over without a lock, as `rays` does. - **One site**: `nav.updated`, the return of the navmesh manager's update job (`f_80781b00`, which holds the manager's lock exclusively while it steps the Havok AI world). Queries are made there, on that job's thread, once every lock is released. - This is the reason the main thread never asks itself: the call takes the same lock shared, and the update may wait on jobs the main thread runs, which is the reason `world.ray` is cast after the physics step. - The site is off while nothing is asked. - **`api`**: `services::nav` (new). It allows at most 64 queries a frame for a mod, and nulls a query that has waited 4 frames (a pause, a load). Answers settle at the next serial point. It needs `state.read`. - The feature is `has("nav.closest")`. - Schema: `nav.toml`, plus `NavPoint` and `NavOptions` in `types.toml`. - **Docs**: - `docs/modding/nav.md`, the guide. - `docs/dev/reference/nav.md`: what was read of the game, the request's layout, the threading, and the run. - The generated reference. Read first: `game/crates/game-core/src/nav.rs`, the `nav.updated` site in `game/sites/sites.toml`, and `game/crates/api/src/services/nav.rs`. ## Testing **Tested:** Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24, build `e0f3ccfa`. **Game-free tests:** - `game-core` `nav`: 6 new tests, run with `host_sys::fake`. - Asked, made and taken. - Cancelled. - Every slot taken. - The request in guest memory, byte for byte as the game builds it, against a fake call. - Nothing near, no manager, a bad ask. - The feature needs the call, the manager and the site. - `api` `services::nav`: 2 new tests (a point read as a `NavPoint` with its distance, and the radius rules). The settling and the limit are covered by the in-game run. - `game-core` (all), `game-sites`, and the builder's `sites` (the new site's owner line) pass. - `schema-gen --check`, `tests/test_doc_anchors.py`, and `cargo check --workspace` are clean. **In the game:** a probe mod's in-game test, `dev.py game-tests`, sandboxed and headless. Link starts in Kokiri Forest at (-46.09, 118.44, 15.39). - `has("nav.closest")` is true. - From Link: the point 0.05 m below his feet. - From 1.5 m above him (radius 3): the ground below, 1.55 m away. - From 30 m above (radius 2): null. - 40 queries in one frame along a 20 m line, 1 m up (radius 4): all settled, 34 points and 6 null, where the line left the walkable ground. - 70 asked in one frame: 64 asked, the other 6 thrown as a `LimitError` at the call. - The test: `ok - test/nav.test.ts: the closest navmesh point is under Link, found from above, and none 30 m up`, 1 passed, exit 0. - Run again on this branch's head, rebased on the squashed `mod-api` (`eaf4a48b9`), with the builder confining the game: the same numbers, and the test passed (exit 0). It was merged locally with #2726 and #2747, which a sandboxed test run on the new `mod-api` needs; that merge was not pushed. The first runs were on the earlier `mod-api`, before the rebase and BeanBot's batch-bounding commit. **Still to test:** - @Beanstalk: Linux, in the game: `dev.py game-tests` of a mod calling `nav.closest` at Link in Kokiri Forest. - By hand: Hyrule Field's tiled navmesh, and a map with none. - By hand: a query across a load, which should be null after 4 frames. <details><summary>The 118 checks that fail on Windows on mod-api (`eaf4a48b9`) too</summary> `test_antilag.py`, `test_astc_decoder_gpu.py`, `test_async_safe_frees.py`, `test_audio_output_devices.py`, `test_audio_source_load.py`, `test_auto_handheld.py`, `test_bc_copy_layer_pitch.py`, `test_builder_channel.py`, `test_builtin_compute_unoptimized.py`, `test_capture_dimensions.py`, `test_capture_readback_visibility.py`, `test_capture_resources.py`, `test_coopmat_probe_failures.py`, `test_crash_record.py`, `test_desc_counts.py`, `test_dev_ab.py`, `test_dev_build.py`, `test_dev_migrate.py`, `test_dev_packs.py`, `test_dev_update.py`, `test_device_policy.py`, `test_draw_binds.py`, `test_draw_stream_visibility.py`, `test_drs.py`, `test_dummy_views.py`, `test_dump_readback.py`, `test_fallback_pipeline_state.py`, `test_float_add_subgroup.py`, `test_framegen_resources.py`, `test_framelog_sink.py`, `test_fsr3_release_frees.py`, `test_fsr3fi_hud_mask.py`, `test_fsr4_bind_dispatch.py`, `test_fsr4_tune.py`, `test_fsr_image_retirement.py`, `test_fsr_uniform_ownership.py`, `test_game_menu_mouse_buttons.py`, `test_gcn_mesh_shared_warp.py`, `test_image_view_retry.py`, `test_import_buffer_binding.py`, `test_import_log.py`, `test_import_reach.py`, `test_inline_write_order.py`, `test_input_background.py`, `test_input_movie.py`, `test_job_queue.py`, `test_lifter.py`, `test_linux_pressure.py`, `test_loaded_modules_drop.py`, `test_longshot_builder.py`, `test_longshot_ctl.py`, `test_lost_wait_said.py`, `test_low_vram_texture_mips.py`, `test_menu_hooks.py`, `test_mesh_fallback_strict_fmul.py`, `test_mesh_first_types.py`, `test_pads_after_menu.py`, `test_parity_gates.py`, `test_pass_barrier.py`, `test_pass_hazard.py`, `test_pcache_header_read.py`, `test_pipeline_key_values.py`, `test_pipeline_state_portable.py`, `test_pipeline_states.py`, `test_present_probe.py`, `test_present_queue_default.py`, `test_present_sites.py`, `test_present_source_crop.py`, `test_program_answer_domains.py`, `test_program_cache_cleanup.py`, `test_program_cache_one_variant.py`, `test_push_state.py`, `test_queue_priority.py`, `test_recorder_own_idle.py`, `test_recorder_parts.py`, `test_recorder_sync.py`, `test_recording_admission.py`, `test_replay_write_order.py`, `test_reshade_fx.py`, `test_run_all_mingw.py`, `test_same_draw.py`, `test_same_dyn.py`, `test_sampler_admission.py`, `test_seed_reader.py`, `test_shader_store.py`, `test_sparse_bind_failure.py`, `test_sparse_bind_ranges.py`, `test_split_ub_flush.py`, `test_staging_burst.py`, `test_taau_typed_dispatch.py`, `test_table_track.py`, `test_target_layouts.py`, `test_target_reuse_memory.py`, `test_temporal_present_bandwidth.py`, `test_texel_buffer_ownership.py`, `test_texture_init_barrier.py`, `test_texture_staging_publication.py`, `test_ub_snapshot_default.py`, `test_ub_update_batch.py`, `test_ui_record.py`, `test_ui_texture_upload.py`, `test_vcore_video_acquire.py`, `test_vendor_fixes.py`, `test_vertex_bind.py`, `test_vertex_bind_range.py`, `test_video_catchup.py`, `test_video_hold_early.py`, `test_video_input_limit.py`, `test_vk_occlusion_queries.py`, `test_vulkan_clear_mip.py`, `test_vulkan_copy_span.py`, `test_vulkan_copy_span_gpu_compile.py`, `test_wb_diff_observations_gpu.py`, `test_widen_alpha.py`, `test_windows_on_linux.py`, `test_windows_stop.py`, `test_wmma16_zero_c_kchain.py`, `test_xinput_thread.py` </details> ## Measurements Nothing to measure: the site is off while no mod asks, and a query is one call of the game's own on its navmesh job's thread. ## Risks - **Safety of the call.** It is made on the navmesh job's thread once the job has released its locks, while the game's own readers take the same lock shared from their threads. The call is a reader too. - **Wrong answers.** If the game changed its request layout, a query would answer wrong, not crash: the request is the game's own, fully written and zeroed. The site's signature pins the build. - **Reverting** is enough: nothing is written to saves. ## Checklist ### Ready for review - [x] One topic, on current `mod-api`; the title is a Conventional Commit. - [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): Windows, this branch: 669 passed, 120 failed, 47 skipped. The same 118 fail on mod-api; the other two (`test_host_alloc_wait`, `test_mesh_args_cleanup`) pass on rerun, flaky under the full run. - [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 check under `tests/` that reads changed source is updated, not weakened. - [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) Co-authored-by: BeanBot <[email protected]> Reviewed-on: #2745 Reviewed-by: HumanBean <[email protected]>## Summary A mod can now add a **game language**: a new choice on the Game language row (Gameplay tab), beside the game's 16, with the game's own text translated. The ask came from the USenRT retranslation (an "English (Retranslation)" next to ordinary English), but nothing here is specific to it. ```toml [[gameLanguages]] id = "en-US-x-retold" # a language code none of the game's has: what the settings keep name = "English (Retold)" # the row's choice base = "en-US" # the game's language it is played in ``` The texts are `languages/<id>/<message file>.json`, one JSON object of texts by label (the shape of `longshot/i18n`'s `strings/<lang>.json`), tags written as `content.text` writes them. No code and no permission. Chosen, the next start: - tells the game the base (`host/nn_applet.c` asks the game side, `hos_mod_language`); - serves the base's text archive with the mod's texts in it: the language folder becomes texts patches made in memory, `"replace": true` (a label the game's file lacks is skipped and logged, never added), applied by the existing merged-file step and cached in `modcache/`. Every other language, the base included, stays the game's. The settings keep the id, so an update keeps the choice. If the mod is off, the game falls back to the id's first part when that is one of the game's (`en-US-x-retold`: English (US)), else English (US). The setting is kept, so turning the mod back on brings the language back. **For a launcher:** `Longshot.exe --profile P --output json mod languages` lists the row's choices: the game's 16, then the languages the profile's mods add. The launcher change that uses it is a separate PR. A launcher that never asks still shows the 16, as now. Read first: - `game/crates/api/src/game_languages.rs`: the list, the code rule, the run's languages; - `game/crates/api/src/loader/language.rs`: the folder made into patches; - the `game_init` change in `game/crates/longshot-game/src/lib.rs`: the languages published after the scan, and the settings opened after them; - `host/nn_applet.c`; - `docs/modding/i18n.md#game-languages`. ## Testing **Tested:** Linux, RTX 3090, a pack on this PC's shared base, three headless runs from `kokiri-start`, with a local pack of the USenRT retranslation (2,109 texts in 384 message files; it stays on this PC): - **The mod's language chosen:** - the log shows `oe: language en-US-x-usenrt, a mod's, played in en-US` and the mod's 384 texts patches; - the merged `Mals/USen.Product.110.sarc.zs` matches, message by message, the archive the retranslation's own repacker builds from the same game files, on 21,137 of 21,138 messages; - the one difference is the microphone hint, which Longshot rewords for the PC (the merge starts from that wording, as every texts patch does). - **English (US) chosen, mod on:** `oe: language en-US`; no texts patches applied. - **The mod's language chosen, mod absent:** `... is not one the game has, nor one a mod on adds: en-US`; the setting is left as it is. - **Checks:** `cargo test` for content, api, modtool, longshot-game and build-driver; clippy and fmt; schema regenerated; `tests/test_game_language.py`, with new cases for a mod's language, its fallback, `HOS_LANGUAGE` and the renderer's Auto. `nn_applet.c` syntax-checks with llvm-mingw and Linux clang. **Still to test:** - Any PC: open the Insert menu with the language chosen, expecting the Game language row to show its name. The control bridge's `option get game_language` reads 0 here for every language, a stock `ja` too, so it couldn't settle this (by hand). - Windows: one start with a mod's language chosen, expecting the same log lines (`@Beanstalk`). - A dialogue the retranslation changes, read in game (by hand). ## Measurements Nothing to measure for a player without a mod's language: no new work runs. With one chosen, the cost is the merged-file step's existing work for one text archive (about 2.4 MB) at the first start, then the cached file. Not timed here. ## Risks - **Mod-api only:** the manifest field, `"replace"` on texts patches and `mod languages` are new API, so nothing shipped changes. - **Settings order:** the settings are opened slightly later in `game_init` (after the mod scan, still before the renderer loads). The host reads its language line from its own early copy, so it's unaffected. - **A launcher with its own fixed list** shows a mod language's id rather than its name until it asks `mod languages`. - **To undo:** a revert is enough. ## Checklist ### Ready for review - [ ] One topic, on current `main`; the title is a Conventional Commit. (On `mod-api`, where the mod API lives.) - [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). (Only the touched crates' tests and `test_game_language.py` ran.) - [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 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; Windows syntax-checked only.) - [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_016o1k1QvyUwMcv8kvCNXuco Reviewed-on: #2881mod init --testwrites a starter test; players' mods page covers sources (#2868) 0ac2b11bc8## Summary The development builds had two incremental build systems. The Rust builder is incremental by content: its object store, the lifts by key, the game's Rust by key, and a shared shader cache. Over it, `scripts/devtools/packs.py` (1,328 lines) and `build.py` kept a second one: a base, packs made of the files that differ from it, and runtimes assembled from both. To do that, the Python guessed at the builder's insides: - the link lists, the sources that carry the version, and which paths reach a link; - `kProgramCacheFormat`, read with a regex; - the renderer's cache file names, kept as a copied list. `shadercache.py` was a second shared shader cache, with a key of its own. On mod-api nearly every change reaches the game's Rust, so a pack was the whole module anyway. This replaces both with one builder command and keeps only the policy in Python. - **`longshot-builder dev runtime <dir>`** (new, `build-driver/src/dev_runtime.rs`) has four modes: - **With `--game` (a build):** it is `dev build`. Every file whose bytes are the base's (`--base`) is a hard link of the base's file. The install still stages each file and renames it in, so nothing ever writes through a link. - **Without `--game` (a copy):** a copy of the base. The builder's files are linked, the rest cloned, and the play state is left out. It is refreshed in place, and the runtime's settings and env file are kept. - **`--prepare-only`:** the shaders prepared, only when the caches it has are not known to be this translator's, program-cache format's and shader list's. - **`--give-back`:** what a run added to the runtime's caches goes into the base and the PC's shared cache. - **The caches:** - Seeded as copy-on-write clones from the base and from the builder's own shared shader cache (`<cache>/shaders/<translator>f<format>/<drivers>/`). - Shared by name from an allowlist, checked against the renderer's source by a test, never its per-folder fault list or play markers. - Recorded per folder (`cache/longshot_runtime_caches.txt`). - Published back only when a preparation got to its end, never shrinking a file, under the renderer's locks. - **The build** writes `program_cache_format=` into `longshot_version.txt`. - **`longshot-builder info`** lists a new capability, `dev_runtime`. - **`dev.py`:** - `rt`: this checkout over the nearest base, in its own warm work folder. Two queue jobs under the base's lock: the build (`build` mode), then `--prepare-only` (`shared` mode, the GPU). - `pack` is gone, folded into `rt`. - `rt --empty` is a copy of the base. - `ab` keeps a runtime that is current. - `check`'s builds and its cache harvest use the same steps. - **`dev.py packs base|pack|rt|warm`** keep the Test Farm's command lines and files: - `base.json` (`commit`, `game_source`, `upscalers`); - `pack.json` (`generated`, `deleted`); - `dev_packs.busy`, and the work folders' `build_times.json`. A pack is now a game folder of its own over the base. `packs base` still refuses a tree with uncommitted sources. - **`dev.py builder -- ARGS`** replaces `packs run`; `mise run build` and `build-dev` run it. `packs head`, which nothing ran, is gone. - **New `dev.py smoke`:** one headless queue run of a runtime. It plays from a save, presents 900 frames, opens the Insert menu, takes a screenshot and checks the log, then says PASS or FAIL. Every agent here kept its own script for this. - **New `dev.py disk [--prune]`:** what the development data uses on the disk, and what is safe to remove: never a store, never a runtime a process uses. It replaces `dev.py bases --prune`. - **New `dev.py tools`**, which `mise run tools` now runs: tools.lock's build tools installed once in the PC's shared tools-store, with the checkout's `tools/` a link to them. Before, every checkout unpacked its own. - **Removed:** `shadercache.py` and its test, and about 700 lines of packs.py. packs.py went from 1,328 lines to 629. Read first: - `builder/crates/build-driver/src/dev_runtime.rs`; - `folder::install`'s `base` argument; - `scripts/devtools/packs.py`; - `build.py`'s `cmd_rt`; - docs/dev/reference/build.md, "A runtime for development". ## Testing **Tested:** Linux (CachyOS), RTX 3090. - **One build job:** - this branch's builder compiled; - `tests/run_all.py`; - the old flow (mod-api's `dev.py pack --own-work` + `rt`) against the new (`dev.py rt`): a first build, a small C change (`host/hos_main.c`) and a small Rust change (`game/crates/longshot-game/src/cheats.rs`), over the shared base462919343e, with the same builder program. In the new flow, 46 of the runtime's 54 files were hard links of the base's. A C change then put 2 files in and kept 52, and a Rust change put 1 file in. - **Then one shared job:** - `dev runtime --prepare-only` prepared the new runtime in 97 s and published 7 cache files into the shared cache; - `dev.py smoke` on it: **PASS**. In play from kokiri-start, 900 frames, the Insert menu opened with its page, no FATAL line. - **Checks:** - `cargo test -p build-driver -p longshot-builder` passes (queue); - clippy `-D warnings` is clean; - `cargo fmt -p` is clean for both crates. - **`tests/run_all.py`:** - 734 passed, 2 failed, 114 skipped. - `test_lifter.py` fails on `cargo fmt --all --check` of `game/crates/api/src/services/mod.rs` and `game/crates/game-core/src/nav.rs`. Those are mod-api's own (#2745), not touched here, and they fail on mod-api too. - `test_dev_packs.py` failed because the job's `LONGSHOT_BUILD` leaked into one test. That is fixed here, and the test passes with `LONGSHOT_BUILD` set. - **The light checks:** test_dev_packs, build, ab, check, disk, smoke, game_tests, update, migrate, mise_build, job_queue, doc_commands and doc_anchors pass; pre-commit is clean on every changed file. - **The review's fixes (2d99edab..2006d19c)**, one build job: `cargo fmt --check` and clippy `-D warnings` of build-core and build-driver clean; `cargo test` of `dev_runtime` 11 passed (new: a unit taken whole and never to shrink a cache, a give-back skipping a unit a running game holds); test_dev_smoke, test_dev_disk, test_dev_packs, test_doc_anchors and test_doc_commands pass. - No host, renderer or other C/C++ file changed, so no llvm-mingw compile was needed. **Still to test:** - **Test Farm** (it runs main's `packs.py`): a run on this branch once it has a base. Expecting `packs base`, `pack pr` and `rt` to work as before, with `base.json` and `pack.json` read as before (`@Beanstalk` after the Farm's changes in Risks). - **Windows** (`dev.py rt`, `rt --empty`): expecting the hard links, the CoW-or-copy clones and `dev.py tools`' junction to work (by hand). - **This PC** (`dev.py disk`): a real dry run over the development folder. Expecting a listing with sizes and nothing removed (by hand). - **Any GPU** (`dev.py packs warm` and `dev.py check`): expecting `--give-back` to copy grown caches back (by hand). ## Measurements **Verdict:** the tools' own cost per change went from minutes to seconds. A runtime takes no disk beyond its own files, and the old flow's 1.5 GB per checkout is gone. Setup: - this PC; one queue build job; - the same builder program on both sides, `LONGSHOT_NO_PREPARE=1`; - each side run in its own new checkout over the same base; - each step's wall time, from its log's timestamps; - disk as btrfs exclusive bytes (`btrfs filesystem du`). | | Before: mod-api @cb37f5ab(`dev.py pack --own-work` + `rt`) | After: this PR @dbc97d8b(`dev.py rt`) | |---|---|---| | First build in a new checkout | 211 s for the pack (the change over the base), plus rt | 27 s | | Small C change | 118 s (pack 32 s, then rt about 86 s) | 8 s | | Small Rust change | 94 s (pack 40 s, then rt about 54 s) | 9 s | | Disk of the change's own folders | 1,534 MB (pack-work.d 1,378, rt 156, the pack 0) | 1,151 MB (the work folder; the runtime 0) | **Caveat:** the new side ran second. It took the objects and the game's Rust for the very same edits from the shared store, which the old side had just compiled; the old pack's compile was its "done in" (0 to 1 min). So the like-for-like number is the tooling's cost outside the compile: old rt about 54 to 86 s plus pack overhead, against new about 8 s in all. A second run with distinct edits per side was not made, to keep to one queue job. **Switches:** no new switch. `LONGSHOT_JOBS` (the builder's compilers at once) is not changed here and ships at its default, unset: one compiler per CPU thread but one, so the PC stays usable while it builds (the launcher's Automatic does the same). `LONGSHOT_BUILD` (a ready-made `longshot-builder` for dev.py, already on mod-api) is a development tool's variable, unset by default: each step uses the tree's own builder. Neither is read by the renderer or the host, so neither has a `gpu/vk/switches.def` row. **The review's fixes (2d99edab..2006d19c)** change no timing: give-back and publish choose and lock differently, smoke and disk judge differently. Nothing there to measure. ## Risks - **The Test Farm, which must change three things:** 1. It starts `<runtime>/longshot` directly. On mod-api the game is `longshot-game`, and only the builder starts it. 2. Main's `packs.py` will need each side's builder to have `dev runtime`. A PR builder from before it exits 2 with "older than this dev.py". Check for `dev_runtime` in `longshot-builder info`'s `capabilities.builder`, and use an older tree's `packs.py` for such a builder. 3. A pack is now a whole game folder, `packs/<name>/game`, whose unchanged files are hard links of the base's; there are no loose files over the base any more. `pack.json`'s `generated` and `deleted` are always empty. - **Existing runtimes and bases on this PC keep working** (copy and build mode accept folders the old Python made). But they hold no `program_cache_format=` line and no caches note, so: - each runtime prepares once, incrementally over its caches, after this lands; - an old base gives its runtimes no caches until it is built again with this builder. - **Removed commands:** `dev.py pack`, `packs run` (now `dev.py builder`), `packs head` and `bases --prune` (now `dev.py disk --prune`). Scripts calling them get an argparse error. - **`dev.py ab`'s "current" check** does not notice a change to `tools.lock` or the build tools alone. - **Players:** the only player-visible change is the build's new `program_cache_format=` line in `longshot_version.txt`. A revert is enough. ## Checklist ### Ready for review - [x] One topic, on current `mod-api`; the title is a Conventional Commit. - [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). Run as `tests/run_all.py`; its one failure, `test_lifter`'s `cargo fmt --all --check` of `game/crates/api/src/services/mod.rs` and `game/crates/game-core/src/nav.rs`, is mod-api's own (#2745) and fails there too, as Testing says. - [x] Measured against `main`, or Measurements says why there is nothing to measure (against `mod-api`, this PR's base). - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc Reviewed-on: #2869The missing mod APIs that need no new hook site (docs: Longshot-notes/missing-mod-apis-plan.md, the non-RE split). - camera: a rig's `roll` (setRoll, angles().roll), turned where the view site writes an override's matrix, and an off-centre `lens` ({ zoom, x, y } or { tile: { grid, col, row } }, setLens), put on the gameplay projection's rows in the registers at the jitter sites, before the jitter, so the game culls with its whole view; its window is kept inside the picture. Features camera.override.roll and .lens (Preview). The fake game's view shows both. - gfx.screenshot({ name? }) (new permission gfx.capture, low): the next frame shown, at the picture's own size, as a PNG under <user>/screenshots/<publisher>/<name>/, the Promise settling with its path. Renderer: shot_full (MKWVK 86) on the control bridge's shot path, sized per shot, a .part of its own; host: hos_mod_screenshot and a ticket ring. - gfx.effect({ ..., inputs: ["depth"] }) at beforeUpscale: the scene's depth at binding 1, at render size, moved to read-only as the upscalers sample it, and a renderer-filled depthModel param with linearDepth in the template (gpu/vk/fx_depth.h, vk_effects.cpp, vk_temporal.cpp; GAME_OUT_FROM_DEPTH, GAME_FILL_DEPTH_MODEL). Preview. - items: each grant belongs to the save slot it was asked in and is given only there; slots deleted, made anew or copied hand their grants on; an older journal's keys are known in every slot; nothing is given between a reload and storage seeing its slot. - stats.modTime() (no permission) and stats.mods() (mods.inspect): each mod's script time, as the inspector shows it. - actors.spawn: 64 a mod, 32 asked in 60 frames, 128 for all mods. - builder: the user folder's screenshots/ is one the game writes (USER_SUBDIRS), so gfx.screenshot works in the sandbox. - audio: a game run showed the game's music has no sub mix of its own (every voice goes through splitters into the master's input mix); recorded in docs/dev/reference/mods-audio.md, setGroupVolume/duck stay absent. - Examples: photo-mode rolls, shoots and takes 2 x 2 tiles; a colour-filter kit over gfx.outputEffect. - Docs: camera (tiled photos), gfx (screenshots, the scene's depth, a colour filter), the sandbox's folders, actors (re-attaching after a load or a map change), items, system-mods, the dev references; generated reference, permissions, scripting, .d.ts, game.h, ffi.rs and the served mod schema. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8WucMods read an actor's skeleton and pose its bones, and hold an actor still: - `pose(actor)` (actors.read): the bones of the actor's model, each its name, index, parent and local transform. - `poseBone(actor, { bone | index, rotation?, translation?, scale?, mode? })` and `clearPose(actor)` under a new permission, `actors.pose` (low: only the picture changes): a standing override written every frame, on top of the game's animation (`add`) or in its place (`set`), until cleared, the actor gone or the mod stopped. One mod poses an actor at once; Link may be posed. - `setPose(actor, list<BonePose>)`: a whole pose in one call, taken in one frame. The schema and its bindings take a list of options records as a parameter now (schema-gen, the thunks, the script side's conversion, the .d.ts). - Link's main bones have stable aliases of the API's own (`head`, `neck`, `spine`, `hips`, `armL/R`, `forearmL/R`, `handL/R`, `weaponL`, `weapon`, `thighL/R`, `shinL/R`, `footL/R`, `toeL/R`), all read back in a game run, which the pose calls take and `pose` reads as each bone's `alias`. - `freeze(actor, frozen)` (actors.write): the game skips the actor's whole update from its next frame, while it is still drawn in its last pose. Not Link; several mods' holds stand together. Hot inline table rules (game/sites/sites.toml): `actors.pose` and its four siblings at the entry of each skeleton step method that makes its bones' world matrices from their local transforms (`skeleton_pose`), and `actors.hold` in GameActor's per-frame method right after it rebuilds the frame flags, before it tests the flag that skips the update (`actor_hold`). With nothing posed, read or held, each is one relaxed load. The main thread publishes the tables `actors.poses` (keyed by the model's world matrices, the pointer that ties a skeleton to its actor) and `actors.holds` (game_core::pose); the sites write on the actor's own thread. An added pose starts from the transform found under the site's last write when the game did not write the bone again, so it never adds up; a cleared bone is put back. Confirmed in game runs: setPose of three bones by alias in one frame (screenshot); (kokiri-start): Link's 309 bones read by name, his head turned and scaled and his arm raised in the screenshot, put back on clearPose; a rolling rock held for 2 s kept its place and rolled on when let go, and Navi held for 2 s stayed drawn in one place and wing pose. The step has five sibling methods (one per kind of skeleton: Navi's and the plants' go through another than Link's); the same rule is on each. The fake game gives every actor a three-bone skeleton (`game.bones(key)`), and the example mod `statues` freezes the enemies near Link and tilts his head. Docs: docs/modding/actors.md (Posing, Holding an actor still), docs/dev/reference/actors.md, hooks.md's rules. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8WucTested in game: Linux, NVIDIA RTX 3090, driver 620.70.06, headless dev.py smoke from kokiri-start twice (PASS): in play, 900 frames, menu opened. The shader preparation before them filled the new store (39,173 noted pipelines, 0 not made). The second run loaded 544 programs from compressed blobs in the fallback store with no read failures.
a18747bedc6e73af1d836e73af1d8308ca00bc04WIP: perf(vk): the shader store keeps its SPIR-V zstd-compressedto perf(vk): the shader store keeps its SPIR-V zstd-compressedRecommendation: Approve. The recorded store is about 2.7 GB smaller for the sampled shader set, but the effect on preparation and loading time is unknown. Windows and the launcher’s prepared-store play path still need testing, and the launcher cleanup change must land before release. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
Stores each shader stage as a zstd frame when that saves space, preserving separate files for older builds. This saves substantial disk space at the cost of compression during preparation and decompression during reads.
Should fix (2): not blocking, but worth doing before merging.
tests/test_spirv_pack.py:80: The format-bump check still accepts any program-cache format of 2 or higher, so it does not protect this change’s required bump from 3 to 4. (more on the line) Do: Add a compatibility test that starts with a format-3 cache and verifies that this build rejects or replaces it; ensure reverting the bump makes the test fail.tests/test_validate_spirv.py:78: The only validator test for compressed frames silently skips when zstandard is unavailable. (more on the line) Do: Declare zstandard as a test dependency and require the compressed-frame case to run, or use a checked-in synthetic frame that needs no package to create.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/spirv_pack.h:260: Compression and decompression change preparation and cache-loading work, but their player-facing cost has not been measured. (more on the line) Do: Compare repeated base and head runs for shader preparation and cold and warm startup, including cache size and memory, on the same machine and build; report the spread and frame pacing during play.gpu/vk/spirv_pack.h:432: The supported Windows and builder-prepared-store paths have not been exercised in a game run on this head. (more on the line) Do: Build and run on Windows, and launch a game through the launcher after preparation using LONGSHOT_SHADER_STORE; verify that prepared programs load without read failures. Cover affected Tier 1 systems, including AMD and Steam Deck, as required by the repository.@fixcan do L1 and L2.Checks: Still running:
PR description / Title and description (pull_request_target).More: does it help, other systems, switches, what was read
Does it help: Yes for store size: the PR reports 3.706 GB of words stored in 0.993 GB for 50,898 blobs, using the new store’s index counts. Overall player impact is unproven: preparation, cold and warm load times, frame pacing, and memory were not measured against the base.
Other systems: The store is shared by preparation and play across drivers and game folders; its reads also occur during program-cache loading and compaction. Linux NVIDIA smoke runs read the fallback store, but did not exercise play from the builder-prepared store. Windows, AMD and Steam Deck behavior and timing remain unmeasured. The launcher’s cleanup needs LongshotLauncher #397 to count and remove the new files.
Switches: No switches added, changed or removed. LONGSHOT_SHADER_STORE retains its existing default and semantics; its files now use the compressed format. RX_VK_PROGRAM_CACHE_ZSTD remains a separate cache mode.
Reviewed:
08ca00bc04against582b6a1abf: Read the repository rules, standards and PR template; the diff and commit; spirv_pack.h, the changed validator and its tests, and the changed store tests. Read the relevant program-cache initialization and builder store-selection and receipt paths; skimmed the remainder of the large builder and program-cache files and the mechanical test and documentation changes. No recorded run artifacts or translations were included in the diff. docs/review-checklist.md and the adjacent Tooling AGENTS.md were unavailable.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no commands from the project, builds or tests were run. The author reports Linux build and smoke results and names failures also observed on the base.
Overlaps and merge order: LongshotLauncher #397 is needed before release for cleanup of the new files. Longshot #2153 also changes store read handles; whichever lands second needs a rebase. This PR is based on mod-api #2822.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as HumanBean took it out of WIP. Nothing was run; a maintainer decides.
@ -229,0 +257,4 @@const void* bytes = w;size_t stored = n * 4;#ifndef SPIRV_PACK_NO_ZSTDstd::vector<uint8_t> frame(ZSTD_compressBound(n * 4));L3 (should fix): Compression and decompression change preparation and cache-loading work, but their player-facing cost has not been measured.
When: A fresh preparation compresses every new stage and a warm start decompresses stages as they are read; the reported one-thread microbenchmark does not show the resulting build or load time.
Do: Compare repeated base and head runs for shader preparation and cold and warm startup, including cache size and memory, on the same machine and build; report the spread and frame pacing during play.
@ -378,0 +429,4 @@bool whole = true;if (stored < plain) {#ifndef SPIRV_PACK_NO_ZSTDconst size_t got = ZSTD_decompress(out, plain, packed.data(), stored);L4 (should fix): The supported Windows and builder-prepared-store paths have not been exercised in a game run on this head.
When: The reported Linux smoke runs used a fallback store; they do not cover the launcher’s Play path reading the store filled by preparation, and Windows has not been started with the new format.
Do: Build and run on Windows, and launch a game through the launcher after preparation using LONGSHOT_SHADER_STORE; verify that prepared programs load without read failures. Cover affected Tier 1 systems, including AMD and Steam Deck, as required by the repository.
@ -76,1 +77,4 @@zbic = ROOT / "third_party/zbic"zstd = folder / "zstd.o"subprocess.run([args.cxx, "-x", "c", "-O1", "-I" + str(zbic), "-c", str(zbic / "zstd.c"), "-o", str(zstd)], check=True, cwd=folder)subprocess.run([args.cxx, "-std=c++20", "-O1", "-g", "-Wall", "-Wextra", "-Werror", "-D_CRT_SECURE_NO_WARNINGS",L1 (should fix): The format-bump check still accepts any program-cache format of 2 or higher, so it does not protect this change’s required bump from 3 to 4.
When: If kProgramCacheFormat is reverted to 3, the store tests still accept it, while a format-3 cache can be accepted with offsets into the old store.
Do: Add a compatibility test that starts with a format-3 cache and verifies that this build rejects or replaces it; ensure reverting the bump makes the test fail.
@ -75,2 +75,4 @@store.f.close()# (a blob kept as a zstd frame, where the package is there to make one)try:L2 (should fix): The only validator test for compressed frames silently skips when zstandard is unavailable.
When: A test environment without that package reports success even if compressed-store reading is broken, although compressed frames are the normal new format.
Do: Declare zstandard as a test dependency and require the compressed-frame case to run, or use a checked-in synthetic frame that needs no package to create.
Open question after merge: an fps gap in an A/B on AMD, not yet explained.
RX 580 (RADV), i7-9700K, Linux, Hyrule Field, 1920x1080 at 67 %, uncapped, headless, 45 s a run, three interleaved runs each (
dev.py ab, two runtimes):582b6a1aGPU time was the same (14.2-14.3 ms) and both sides read their prepared stores with no failed reads. CPU time was about 25 % higher with this PR in phases it does not touch (draw, command recording, memory sync, the game's main thread), so a build or machine effect is possible, but not shown. (
dev.py abwrote no verdict only because the two builds' versions differ.)A control is queued on the same PC: this PR's runtime with the baseline's game executable. I will post what it shows.
🤖 Generated with Claude Code
Follow-up on the fps gap above: the control does not show it coming from this PR.
Same PC. Control: this PR's runtime (its renderer and its compressed caches) with the baseline's game executable, against the baseline, three interleaved runs each:
582b6a1aThe control is not slower. The baseline itself moved from 55.7-57.4 fps in the first session to 50.3-53.7 here, so this PC's spread between sessions is larger than the first gap. Why the first session's two builds differed is not established (their game executables are not byte-identical; nor was a plain effect of the machine ruled out).
Load time, with the shader store and program caches evicted from the OS cache before each launch (hard drive), same game executable on both sides:
The runs overlap: no load-time difference shown either way at three runs each. All launches read the prepared store, with no failed reads.
🤖 Generated with Claude Code