feat(mods)!: texture packs and mods of game files load while the game runs #3151
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!3151
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:feat/mods-live-files"
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
Follows #3105. Two more kinds of mod are added, switched and removed while the game runs, and the map reload is kept to mod development.
1. Texture packs (
textures/). Packs are read again off the game's threads, and textures already loaded are looked up again over a few frames. Folder packs reload as their images change. Packs with arecipe.jsonstill wait for the next start.2. Mods of game files (
romfs/,patches/, including emulator-layout mods with onlyromfs/). The file layers are rebuilt, and a file is served anew from the next time the game loads it. A mod with a file the running game has no room for stays out whole until the next start, with the restart offered. Mods with code, their own saves, a game language, a content module, or moved in the list still wait.3. The map reload is dev mode only. "Reload the map to see the change" enters the map through its destination's entrance, which started a story cutscene in a run (#3148). Players now see "Parts of this change may need a restart to show", for edited and switched mods alike, until the next start.
4. The layers are rebuilt off the game's thread (
lsmod-layers), one rebuild at a time. The main thread takes what the build reads, runs a changed content module's stage and takes the outcome in at a later frame.Read first:
gpu/vk/vk_texture.cpp(the table swap and the sweep),game/crates/longshot-game/src/textures.rs,game/crates/api/src/loader/hot.rs,game/crates/api/src/services/reload.rs.MKWVK_API_VERSIONis 93.Known gaps:
modcache/.Testing
Tested: headless game runs on Linux, NVIDIA RTX 3090, from a repository save (
kokiri-start).On the head,
ee31b40215ec(runtime built from it), driver 620.70.06, sandbox off:rebuilt off the game's thread in N ms, M ms of work on it: N from 0 to 84 ms, M 1 ms the first time and 0 ms after (the log's own count, not frame times);1 changed path is loaded in this map, later ones2, and the Mods tab showed Parts of this change may need a restart to show;On
9d0d0605, before the rebuild moved off the game's thread: the first switch of that mod logged200 changed paths are loaded in this map, its rebuild took 150 ms on the main thread, and the Mods tab still showed its line after teleporting to Hyrule Field and back (not looked at again on the head).Earlier, on
fdc17832(before the rebases and the review fixes): mods of game files (made-up files the area does not load) were switched on, overlapped, switched off and removed with the paths the log named, the oversized one was held with Restart now offered, and an emulator-layout one was switched on and removed.Three runs on earlier builds of this branch (before the last rebase and the final wording):
Checks, Linux, no full suite: see the comments below.
A second agent reviewed changes 1 and 2, and BeanBot reviewed the whole pull request; the fixes to both have not been reviewed again, and nobody has reviewed change 4.
Still to test:
mod run) (by hand).Measurements
Nothing to measure: no change aims at speed.
Risks
HOS_MODS_WATCH=0; reverting is enough.Checklist
Ready for review
main; the title is a Conventional Commit. (Three related changes in one on purpose.)mise run testpasses. (Not run on this branch.)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.MKWVK_API_VERSIONbumped (MkwVkHostorMkwVkRendereringpu/vk/vk_api.hchanged).vk_texture.cpp.)mainand here, for a change that shows on screen. (Not taken.)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e1rSeTzGtqzZNG1YZH
Tested in game: Linux, NVIDIA RTX 3090, headless, kokiri-start repository save, on earlier builds of this branch (before the last rebase and the final wording), not on this head. Texture packs added, edited, switched and removed in play showed on screen. Mods of game files: the log matched the bookkeeping, but no visible change was seen. Outside dev mode no map reload happened.
Checks on
fdc17832(Linux, no full suite): the runtime builds;cargo testofapi(573),content(260) andlongshot-game(223) passes;test_texture_pack,test_program_hooks,i18n_completeandtest_menu_ini_keyspass;vk_texture.cpppasses an llvm-mingw syntax check with-Wno-c++11-narrowing(without it, it stops at a line that is the same onmain).rx_backend.cwas not checked for Windows.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e1rSeTzGtqzZNG1YZH
@rebase
I rebased this pull request onto
main(1c8c2634c7): the new head ise1a23bcbf8.Conflicts resolved
Nothing was built or run: read the resolution before merging.
Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
fdc1783206e1a23bcbf8Recommendation: Request changes. The texture sweep can match a replacement against bytes that no longer belong to the uploaded texture, producing the wrong image. A failed decoder-thread start also leaves the pack unavailable for the rest of that generation.
This adds live texture-pack and game-file changes and restricts map reloads to development mode. Texture changes have been seen on screen, but file changes have not yet produced a visible result, and the frame-time cost of rebuilding layers and sweeping textures is unmeasured.
Blocking (2): must change before merging.
gpu/vk/vk_texture.cpp:3099: The sweep identifies an already uploaded texture by reading its guest storage again, rather than by the bytes used for its upload. (more on the line) Do: Retain the signature and full hash of the bytes used for each upload and use those saved values when a pack change sweeps an existing texture.@​fixor@​rebasetry first). (for the author)Should fix (2): not blocking, but worth doing before merging.
gpu/vk/vk_texture.cpp:2752: The generation is marked seen before the decoder thread has successfully started. (more on the line) Do: Only advance pack_seen after the thread has started and the table can be published, or otherwise arrange a retry after the failure.game/crates/api/src/services/reload.rs:244: Starting any map load clears the restart notice even when the changed resource remains held by the game. (more on the line) Do: Keep the notice until restart, or clear it only when the affected resources are known to have been reloaded.Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)
game/crates/api/src/loader/hot.rs:164: The synchronous layer rebuild can interrupt a frame, and its cost with real mods has not been measured. (more on the line) Do: Measure frame times while adding, switching and removing representative large file mods, including on Steam Deck, and compare with the base. (@fixdoes its part first: Move or prepare the layer rebuild off the frame thread and publish the completed table at a safe point.)gpu/vk/vk_texture.cpp:3077: The live texture path has not been measured for frame pacing or checked across the supported Tier 1 systems. (more on the line) Do: Compare base and head frame times with packs absent and while switching a large pack, and exercise visible replacement and removal on Windows, AMD and Steam Deck. (@fixdoes its part first: Incrementally build the sweep and use saved upload hashes so a single lookup does not reread and hash texture storage.)@fixcan do L1, L2, L3, L4 and L5.Checks: Still running:
PR description / Title and description (pull_request_target).More: does it help, other systems, switches, what was read
Does it help: Unproven for file mods: the reported runs served changed paths but showed no visible change. Texture packs were seen changing on Linux with an RTX 3090; no comparable frame-time measurements against the base were reported.
Other systems: The renderer sweep can affect all GPUs and both supported OSes; only Linux/NVIDIA was exercised. File-layer rebuilding and map reload affect game loading independently of GPU. Windows, AMD, Steam Deck, a visible file mod, development-mode reload, and the new restart notice remain untested according to the PR.
Switches: No switch added or removed. HOS_MODS_WATCH defaults to watching and now also controls live file and texture changes; RX_VK_TEX_PACKS retains its existing default.
Reviewed:
e1a23bcbf8against1c8c2634c7: Read repository rules, standards, the PR template, commit log, loader hot-rebuild and arrival code, texture publication and reload code, and the renderer sweep and lookup paths. Reviewed the diffs for the remaining files; translations, documentation, tests, schemas and generated-facing changes were skimmed. The full contents and all callers of every changed code file were not read.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run for this review. The author reports partial Linux checks and game runs; the full suite and the runs listed above remain outstanding.
Overlaps and merge order: The PR identifies #3137 as overlapping the loader; its merge order was not established from the available checkout.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.
@ -75,0 +161,4 @@}if !done {self.files_from = kept;let left = if removed {L4 (should fix): The synchronous layer rebuild can interrupt a frame, and its cost with real mods has not been measured.
When: Switching a large file mod rebuilds and fits the layers on the main thread before the frame can complete; the reported runs do not include frame times for that operation.
Do: Measure frame times while adding, switching and removing representative large file mods, including on Steam Deck, and compare with the base.
@ -223,6 +241,7 @@ impl MapReload {/// A map load begins: the paths opened from now are the new map's (`layers`' notes forgotten).pub fn map_loading(&self, layers: &content::layers::Layers) {layers.opens_new_map();lock(&self.shared).later = false;L3 (should fix): Starting any map load clears the restart notice even when the changed resource remains held by the game.
When: A player changes a file that was already loaded, sees the notice, and travels to another map. map_loading clears later even if the game retains that resource across the transition, so the Mods tab no longer explains why the change has not appeared.
Do: Keep the notice until restart, or clear it only when the affected resources are known to have been reloaded.
@ -2720,1 +2749,4 @@}pack_seen.store(listed, std::memory_order_release);if (!table->empty() && !decoding) {try {L2 (should fix): The generation is marked seen before the decoder thread has successfully started.
When: If creating the decoder thread throws, pack_load returns without publishing the table, but subsequent frames see the same generation in pack_seen and never retry. The enabled pack therefore remains absent until another pack change or restart.
Do: Only advance pack_seen after the thread has started and the table can be published, or otherwise arrange a retry after the failure.
@ -3027,0 +3074,4 @@pack_sweep.clear();pack_failed_stale = true;for (const auto& [key, tex] : textures)if (tex->pack) pack_sweep.push_back(key);L5 (should fix): The live texture path has not been measured for frame pacing or checked across the supported Tier 1 systems.
When: A pack change scans the texture collection and then hashes uploaded textures over subsequent frames; the 1 ms loop limit excludes the initial scan and cannot bound one large lookup.
Do: Compare base and head frame times with packs absent and while switching a large pack, and exercise visible replacement and removal on Windows, AMD and Steam Deck.
@ -3027,0 +3096,4 @@Texture& tex = *it->second;PackImage* const had = tex.pack;if (tex.uploaded || had) pack_reupload(tex, tex.guest_size);came |= tex.pack && tex.pack != had;L1 (blocking): The sweep identifies an already uploaded texture by reading its guest storage again, rather than by the bytes used for its upload.
When: If the game has reused or rewritten the texture's guest address after the upload, pack_reupload calls pack_lookup and guest_bytes on the current storage. The shadow only covers captured pages, so the sweep can attach the replacement for those newer bytes to the still-existing GPU image, or remove the correct replacement.
Do: Retain the signature and full hash of the bytes used for each upload and use those saved values when a pack change sweeps an existing texture.
e1a23bcbf89d0d0605eaPushed
9d0d0605eae7: rebased onto currentmain(after #3137 and #3095) with the review fixes folded into their commits. The head before wase1a23bcbf8de.Also: the test #3137 added for moving a mod failed after the rebase, as it skipped publishing the file layers, which the game does after every start. It now does that.
Checks, Linux, no full suite:
cargo testofapi(579),content(260) andlongshot-game(223),cargo clippy -D warningsandcargo fmt --check;test_program_hooks,test_i18n_complete,test_menu_ini_keys.test_texture_pack,schema-gen --check, an llvm-mingw syntax check ofvk_texture.cpp.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e1rSeTzGtqzZNG1YZH
Tested in game on
9d0d0605eae7: Linux, NVIDIA RTX 3090, driver 620.70.06, headless,kokiri-start.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e1rSeTzGtqzZNG1YZH
Pushed
ee31b40215econ top of9d0d0605eae7, for L4: the file layers are now built, checked against the size table and published on their own thread. The main thread only takes a snapshot, runs content stages and takes the outcome in.Checks, Linux:
cargo test --releaseofapi(581, with 2 new threaded tests),content(260) andlongshot-game(223);clippy -D warningsofapiandlongshot-game;cargo fmt --check;test_sandbox_linux,test_sandbox_save_folders.Not done: the runtime was not built and the game was not run on this commit, and nobody has reviewed it.
🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e1rSeTzGtqzZNG1YZH
Tested in game on
ee31b40215ec(headless, Linux, NVIDIA RTX 3090, driver 620.70.06,kokiri-start, sandbox off), for L4:9d0d0605, the first switch took 150 ms on the main thread. These are the log's own counts; frame times and Steam Deck are still unmeasured, so L4's "Do" is only partly met.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e1rSeTzGtqzZNG1YZH
@review
Recommendation: Approve. The code is ready: only testing is left. Texture pack switching has been shown working, and moving file-layer rebuilding off the game thread reduced the logged main-thread work in one run. The visible file-mod behavior, frame pacing, supported-system coverage, and mergeability still need confirmation. Recommend approval; not approved on the forge.
Texture packs and eligible file mods can change during play, while automatic map reloads are limited to development mode. The threaded rebuild reduces the observed main-thread work but adds concurrency and platform-specific paths that need further validation.
Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)
game/crates/api/src/loader/hot.rs:164: The threaded rebuild's effect on frame pacing remains unmeasured. When: A large file mod is switched during play; the log reports worker and main-thread durations but does not show whether a frame hitches. Do: Measure frame times during repeated switches of a real mod, including on Steam Deck. (@fixdoes its part first: Move or prepare the layer rebuild off the frame thread and publish the completed table at a safe point.)gpu/vk/vk_texture.cpp:3077: The live texture path has not been measured for frame pacing or checked across the supported Tier 1 systems. When: A pack change scans the texture collection and then hashes uploaded textures over subsequent frames; the 1 ms loop limit excludes the initial scan and cannot bound one large lookup. Do: Compare base and head frame times with packs absent and while switching a large pack, and exercise visible replacement and removal on Windows, AMD and Steam Deck. (@fixdoes its part first: Incrementally build the sweep and use saved upload hashes so a single lookup does not reread and hash texture storage.)@fixcan do L4 and L5.Since the last review (on
e1a23bcbf8)Resolved: L1 (The sweep identifies an already uploaded texture by reading its guest storage again, rathe…); L2 (The generation is marked seen before the decoder thread has successfully started.); L3 (Starting any map load clears the restart notice even when the changed resource remains hel…); L7 (It conflicts with its base branch: bring it up to date (
@​fixor@​rebasetry first).)Still open: L4 (The threaded rebuild's effect on frame pacing remains unmeasured.); L5 (The live texture path has not been measured for frame pacing or checked across the support…); L6 (The file-mod feature and the final map-reload behavior have not yet been demonstrated with…)
Checks: Still running: 9 checks.
Also noticed (2; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven for file mods: no visible game change has been demonstrated. Texture pack add, edit, switch, and removal worked on Linux with an NVIDIA RTX 3090. For a 237-file mod, the head logged 0–84 ms off-thread and 0–1 ms of main-thread work, versus 150 ms on the main thread before threading; these are log counts, not comparable frame-time measurements against main.
Other systems: The renderer and file-layer paths can affect Windows, Linux, other GPU vendors, Steam Deck, sandboxed file access, and game file loads. The supplied runs cover Linux and NVIDIA with the sandbox off; the other systems and a switch during a rebuild remain untested.
Switches: No switch was added or changed. The existing HOS_MODS_WATCH=0 disables watching.
Reviewed:
ee31b40215againstd6e819e084: Read AGENTS.md, CONTRIBUTING.md, the pull request template, loader/hot.rs and services/reload.rs; inspected the threaded rebuild diff and relevant texture sweep excerpts. The remaining changed code, documentation, generated files and tests were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run the project were executed. The supplied head run covers texture packs and repeated file-mod switches on Linux/NVIDIA; CI is still running.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
WIP: feat(mods)!: texture packs and mods of game files load while the game runsto feat(mods)!: texture packs and mods of game files load while the game runs