Repository navigation
fix: an update that makes startup shaders compiles their libraries, and update_runtime.py --shader-libs completes them - #2297
Merged
Conversation
…nd update_runtime.py --shader-libs completes them A TotK 1.4.3 app kept the libraries of its old translation chain after its seed was made again: it had libraries for 1,890 of the 17,884 shaders its warm-up loads, and compiled the rest from source at every cold start. The only path that leaves a new seed with the old libraries is step_shader_libs returning when metal_compiler() finds nothing (one line, then the update went on); the command line tools xcode-select pointed at have no metal. That run's log is gone. - step_shader_libs(required=True): no compiler is an error naming the toolchain and DEVELOPER_DIR. update_runtime.py --seed and --shader-libs check it before the work folder or the app is touched. A full build still goes on, with a WARNING line; the express update's new list shaders too. - update_runtime.py --shader-libs: the app's own startup seed and libraries are cloned into the work folder, only the shaders without a library are compiled, and the shader data bundle is made again. No RomFS or modules needed; the seed must be of the runtime's chain. --seed also takes the app's libraries first (as the list path already did). - mac_pipelines: the library set is in the archive's input stamp, so a new set checks the archive against the libraries the game loads (TOTK_PAR_RECHECK). Without libraries the stamp is unchanged. - docs/install: the fast update and --shader-libs need Xcode's Metal toolchain; when to use --shader-libs. Tests: test_update_shader_libs (adopting the seed, no compiler stops --seed / --shader-libs first, which steps run), test_variant_libs NoMetalCompiler, test_mac_pipelines MacPipelinesStamp; test_shader_update follows main()'s lines. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01NnHGEHeQzgBps2MXvnkJC9
ly05010419
added a commit
that referenced
this pull request
Nov 19, 2026
…es itself, and --seed goes on without a compiler (after PR #2297) PR #2297 made --seed stop without a Metal compiler. But update_runtime.py --plan still answered "fast" on such a Mac, and MNG Launcher runs --seed from that answer (tools/builder_jobs/build_job.py). So the update failed halfway, and a player without Xcode's Metal toolchain was left with only the full build. The repair (--shader-libs) also had to be run by hand, by someone who knew of it. - missing_shader_libs counts the startup shaders of the app's seed that have no compiled library. It reads the app's seed-manifest.json alone (a library is named by its .metal's SHA-256, build_app.shader_libs_of), so nothing is hashed. - An express update with gaps and a compiler takes the --shader-libs path by itself. A list with new shaders makes a new seed instead, which compiles every shader still without a library (make_seed). - step_shader_libs records the sources its compiler refused (build/shader-libs/refused.json, tied to compiler.txt). These are not gaps for that compiler, so one shader it cannot take does not send every later express update through the completion. - --seed without a compiler makes the seed as a full build does, with a warning. --shader-libs still stops without one. - plan() says this first. The express reason names the gap and what the update does about it (shader_lib_gaps), and the fast reason names the toolchain on a Mac without it. No update is refused for want of a compiler. - The update's last line warns about any library still missing. - The docs follow. The Tears of the Kingdom, Breath of the Wild 1.9, Bananza and Pokopia apps here have no gap (2026-11-19). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
|
Thank you for tracing this to the quiet skip in
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Tears of the Kingdom / Breath of the Wild (and the Switch 2 games built from
games/totk) on the Mac load their startup shaders from libraries compiled at packaging (step_shader_libs, PR #16). This PR makes sure an update that changes the startup shaders also gets their libraries, and adds a way to repair an app that is missing them:update_runtime.py --seed(and--shader-libs) before the work folder or the app is touched, with the fix in the message (Xcode's Metal toolchain,xcodebuild -downloadComponent MetalToolchain,DEVELOPER_DIR).step_shader_libsgetsrequired=; with it a missing compiler is aBuildErrorinstead of a one-line note andreturn.update_runtime.py "<app>" --shader-libscompletes the libraries of the seed the app already has: the app's seed and libraries are cloned into the work folder (APFS clones), only the shaders without a library are compiled (on all cores, as before), the ShaderData bundle is sealed again with the full set, and the pipeline archive is checked against the new libraries. It needs no RomFS or modules in the work folder. The seed must be of the runtime's chain (otherwise it says to use--seed).--seedalso takes the app's libraries into an empty work folder first, as the list path (work_files_from_app, cee07b6) already does, so only the changed shaders compile.mac_pipelines: the names ofbuild/shader-libs/*.metallibare part of the archive's input stamp. A new library set then runs the tool withTOTK_PAR_RECHECK=1, so pipelines made while those shaders were compiled from source are checked against the offline libraries the game now loads ("a wrong file is a miss",totk_pipeline_archive.h). With no libraries the stamp is byte-identical to before.docs/install.mdandinstall.zh-CN.md: the fast update and--shader-libsneed the Metal toolchain; when to use--shader-libs.Why (root cause)
On my TotK 1.4.3 app, cold starts compiled shaders for minutes. The cause had three parts:
newLibraryWithSourceon every cold start.step_shader_libsreturning whenmetal_compiler()finds nothing. It prints one line and returns, and the update finishes with the new seed and the old libraries. The Command Line Tools thatxcode-selectpointed at have nometal, and the Xcode on this Mac may not have had its Metal toolchain component yet. Nothing after that rebuilds the libraries: the express update moves the ShaderData bundle from app to app unchanged, so there was no way back short of another--seedwith a toolchain (and work-folder game files).$(getconf DARWIN_USER_CACHE_DIR)/<bundle id>/com.apple.metal), with one shared root pool for processes without one. Beforebecf1249the game binary had no bundle ID, so it shared that root pool with every bundle-less tool (other ports' build tools and runtimes), which evict each other's entries (the pool is capped at about 1 GiB per file; third-party reports in sharpemu-mac#50 and mullion#171, consistent with what I saw).becf1249already gives the game binary its own id (org.macnativegames.totk-native), and it is on main. This PR does not touch it. That also means the--seedfallback without a compiler,step_warm_metal, now warms a cache the game no longer reads: its tool (build_warm_tool) has no__info_plist, so it fills the root pool. With no compiler,--seedmade an app that compiles everything from source at its next cold start. That is why the fast update now stops instead.Shipping AIR libraries is Apple's guidance for exactly this (WWDC22 10102: building a library from source "can be a CPU intensive operation, which you can move to app build time by pre-compiling your source to a Metal library"; WWDC20 10615 and Creating binary archives from device-built PSOs for the archive side). MNG already does this. The fix only makes sure it isn't skipped.
What changes for players
--seed) on a Mac without Xcode's Metal toolchain now stops at its start (nothing changed, the message says what to install). Before, it went on and produced an app that compiles its startup shaders from source at every cold start.update_runtime.py --planstill answersfastthere, and the stop comes when the update starts. Ocarina of Time puts the same check inplan()(c2334dc). I can add that for TotK/BotW here or in a follow-up. If you would rather keep--seedgoing without a compiler, it is one argument (required=args.seedinmake_seed) and the rest of the PR stands.build_app.py) without the toolchain goes on as documented, now with aWARNING:line. So does the express update's list path (new shaders from the newest shared list,list_adds_shaders) and the Launcher's Check shaders (shader_update.py): those keep the app's libraries and add a few shaders, so a missing compiler costs only those few.What does not change
shader_lib_prebuilt), the seed and the express update without flags.becf1249(games/totk/runtime/game_info.plist,GAME_INFOin all 7 link rules) is already on main. Nothing here touches it.step_warm_metalstill runs after--seed(and after--shader-libs). With complete libraries it skips itself (build_app.py"the startup shaders are compiled into the app"). Pointing its tool at the game's own cache id is a possible follow-up.--shader-libsdoes not translate the newest list's new shaders (it short-circuitslist_adds_shaders, as--seeddoes). Their pipelines still go into the warm-up lists without a library, the same as upstream does today whencan_translatesays no.--shader-libsand--seedtogether are refused. Ocarina of Time, Skyward Sword and the standalone ports refuse--shader-libs.Tests
tests/test_update_shader_libs.py(12): the app's seed and libraries are adopted (through the ShaderData links), an older work seed and its.verified.jsonare replaced and the work folder's libraries kept, an app without a seed is refused, no compiler stops--seedand--shader-libsbeforeprerequisitesand the work folder, a plain update needs no compiler, both flags together are refused, and which stepsmain()runs for--shader-libs/--seed/ list-only / plain.tests/test_variant_libs.pyNoMetalCompiler(2):required=Trueraises with the toolchain andDEVELOPER_DIR, and a build without it goes on withWARNING.tests/test_mac_pipelines.pyMacPipelinesStamp(1): an app without libraries keeps its old stamp, and a new library set changes the stamp and runs the tool withTOTK_PAR_RECHECK=1.tests/test_shader_update.py: the two source lines it pins inmain()follow the change.main@ 597cf54, with the same environment (python 3.14 venv fromgames/totk/requirements.txt, scratchHOMEand game slot): 47 test modules (the 46 that importbuild_app/update_runtime/shader_update, plustest_express_update_speed). main: 511 tests, PR: 526. Same result on both: 2 errors intest_work_copy_links(rsync on this Mac cannotmkdirthe nested target, exit 11; environment, not this change), 1 skipped. Everything else passes.make check-c: passes on both.py_compileof the changed files,git diff --check: clean.discover(it includes real Metal work,test_warm_metal,test_oot_hmma_calls, and I kept Metal off this Mac while it was in use). CI runs it.testgate withmake check-c, all green). That covers the fulldiscoverI did not run locally. Main at the base, 597cf54, is green too (run 44435769647).Tested on a Mac
becf1249's plist part), withupdate_runtime.py "<app copy>" --shader-libs --work <work folder>andDEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer(Xcode 27.2, Metal toolchain 27B47).--checkpassed.org.macnativegames.totk-native) in macOS's logs. That isbecf1249's part, already on main.cee07b61's library adoption reused instead of duplicated,TOTK_PAR_RECHECKinstead of a full archive rebuild, the list path). Not tested on iPhone/iPad (the change is Mac packaging only; iOS builds skipstep_shader_libs), BotW, the Switch 2 games, or other Macs.Not done
plan()does not report a missing compiler for TotK/BotW fast updates (see above).variant_folderis still hard-coded tort-totk-native-v9-unverified, harmless until the next chain bump.-mmacosx-version-minpin for the libraries. A library that fails to load falls back to source.🤖 Generated with Claude Code
https://claude.ai/code/session_01NnHGEHeQzgBps2MXvnkJC9