Skip to content

Translate the startup shaders on all cores when building - #27

Merged
ly05010419 merged 2 commits into
ly05010419:mainfrom
tvc97:perf/parallel-shader-seed
Oct 19, 2026
Merged

ly05010419 merged 2 commits into
ly05010419:mainfrom
tvc97:perf/parallel-shader-seed

Conversation

@tvc97

@tvc97 tvc97 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

prepare_shader_seed.py sends every translation job through one totk_xlate --service process, one request at a time, so build step 3/4 shaders uses one core. On 1.4.3 that is now 24,032 jobs: the startup shaders plus the bind states from the shared shader list.

This PR starts one translator service per CPU core and splits the work per shader:

  • Order within a shader is kept. A shader's default job and its listed jobs run in order on one service, because whether a listed job is translated and kept depends on that shader's earlier results (produced, deps dedup).
  • Output order is kept. The results are taken in the original jobs order: rows (pso_manifest.tsv), completed, skipped, and each shader's .variants.
  • No file clashes. Each job writes only files named after its own shader.
  • Same output. It is byte-identical to the one-at-a-time run (below).

build_app.py also passes -j<cores> to the make runtime… call.

seed-manifest.json's preparation_sha256 covers this script, so an existing build/shader-seed is prepared again once after updating, and is reused after that.

Updated after upstream's rewrite of prepare_shader_seed.py (shared shader list, .sharcb and game-module shaders): the parallel loop was ported onto the new prepare() and measured again.

Measurements (Apple M4, 10 cores, macOS 27, TOTK 1.4.3)

Same RomFS, modules (--modules rewritten/v143), translator, SPIRV-Cross and shader list. Fresh output folder each run, outside the repo.

Translation (seconds in seed-manifest.json) Whole step (wall) Peak RSS
main, one service 166.1 s 203.8 s 1.17 GB
This PR, 10 services 28.5 s 64.7 s 1.20 GB
  • Output is identical. All 44,885 files listed in seed-manifest.json have the same SHA-256. pso_manifest.tsv is byte-identical, the 84 skipped entries are identical, and so are 15,321 variants and 12,472 startup shaders. Only preparation_sha256 and seconds differ.
  • Where the rest of the wall time goes. About 36 s is the single-threaded RomFS scan and decompression, which this PR doesn't change.
  • make -j. A clean make runtime-v143 goes from 15.0 / 14.5 s to 12.2 / 11.8 s. This gain is small because nvn_mtl.m dominates the build.

Tests

  • python -m unittest discover -s tests: all tests pass.
  • git diff --check: clean.

🤖 Generated with Claude Code

prepare_shader_seed.py sent all 8,290 startup shaders through one translator
service, one at a time. It now starts one service per CPU core, gives each a
share of the shaders, and merges the results in the original order. The
output is byte-identical to the one-at-a-time run. On an Apple M4 (10 cores),
1.4.3 translation went from about 74 s to about 16 s.

build_app.py also runs make with -j for the game binary, about 3 s less.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
tvc97 added a commit to tvc97/MacNativeGames that referenced this pull request Oct 19, 2026
Upstream rewrote prepare_shader_seed.py (the shared shader list, agl
.sharcb and game-module shaders, listed bind states, deps dedup), so the
parallel translation is ported onto the new prepare(). Work is split per
shader: a shader's default and listed jobs run in order on one translator
service, because whether a listed job is translated and kept depends on
that shader's earlier results. The results are then taken in job order.

Checked against upstream's script on the same 1.4.3 RomFS and modules
(Apple M4, 10 cores): all 44,885 output files, the 84 skipped and
pso_manifest.tsv are identical. Translation took 166.1 s, now 28.5 s;
the whole step took 203.8 s, now 64.7 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
tvc97 added a commit to tvc97/MacNativeGames that referenced this pull request Oct 19, 2026
…y05010419#38)

Conflicts resolved toward the refreshed PR branches: nvn_mtl.m from
perf/async-shader-loading (ly05010419#30 on current upstream) plus ly05010419#13's parallel
warm-up and the precompiled-library hit/miss log; prepare_shader_seed.py
from perf/parallel-shader-seed (ly05010419#27); runtime/cheats.c kept in every
runtime target and in loader.c. AGENTS.md stays tracked here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ly05010419
ly05010419 merged commit 37ab7bd into ly05010419:main Oct 19, 2026
1 check passed
tvc97 added a commit to tvc97/MacNativeGames that referenced this pull request Oct 19, 2026
…mods, shortcut status, 1.4.3 world survey, shader list)

Conflicts:
- nvn_mtl.m pso_get: kept the async pipeline path (ly05010419#30) with upstream's sampler
  border colour emulation, as on perf/async-shader-loading (6d4cbfb); pso_pend_kick
  builds from the key's fsfn.
- game_patches_v143.c: our overlay scene-size manifest beside upstream's
  runtime_output_size_current.
- frontend.m: upstream's live shortcut status.
- README: upstream's text; key 3 keeps "native high resolution".
- prepare_shader_seed.py: upstream's follow-up to ly05010419#27 (8 services, stop on failure).
- shader_list.tsv: upstream's list, which already holds every row of ours.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ly05010419 added a commit that referenced this pull request Oct 20, 2026
…ultrawide HUD, 1.4.3 survey, mods, controls.txt) into the Breath of the Wild branch

Resolved by hand: nvn_mtl.m (PR #34's paged-bitmap serial sets keep the serial forgetting of 635fb31: totk_serial_del
clears a bit; the memory line shows both; the BotW frame reset stays in mtl_present), build_app.py (make -j and the
per-game launcher defines), the Makefile (the BotW targets and the Opus test), loader.c (the #57 stale-reference handler
and 1.4.3's survey return address are TOTK-only: Breath of the Wild has no GAME_ADDR for them), world_survey.c (BotW
keeps its stub, with runtime_survey_sync), README (both update-history rows).

Found by the merged build: Breath of the Wild lacked runtime_output_size_current (frontend.m's shortcut text) and
runtime_survey_sync (hle_nvn.c); and the add-on content file handles shared fs_host.c's 0x200000000 range, so closing a
host file at the title ended the game ("close invalid add-on content handle"): they now start at 0x400000000.

Tested on the merged binaries: TOTK 1.2.1 jump session (anomalies 0, occlusion normal, serial set 48,606 / 13 pages),
Breath of the Wild DLC + key 3 (k3a6) and key 2 (k2c, 11 of 12 pairs within 5 px).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants