bake: offline NVN translation harness + live bank writer + verify #1707
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!1707
Loading…
Reference in a new issue
No description provided.
Delete branch "bake-offline"
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?
Developer tooling: translate archived NVN shaders to SPIR-V with no GPU, no game, no playthrough, and write/verify live-format program banks offline.
What it adds (purely additive — nothing under
gpu/vk,nx2/build.pyorhost/; game behavior unchanged):spirv-val --target-env vulkan1.3clean.hookshot_programs.binwriter (kDiskMagic/disk_stamp) with read-back verify through a copy ofprogram_cache_load.bake verify(seed-sha round-trip, stamp currency, per-module validation), container enumeration (BNSH/BAHS/NDSR/NDVE/vsetb/SARC incl. zstd-dictionary frames), Ampere encoding probe.--targetfeature profiles (plain/tensor/tensor-software/rdna2/gfx1201/query): tensor-gated programs + integer-answer variants translated per profile, feature set folded into the stamp (target belongs to the stamp, never to a key), verified against liveseed_computesemantics (dedup + cap-64 arithmetic identical).tests/run_all.py bake: 3 passed, 0 failed.BAKE.md: design, run guide, key/stamp derivation, offline assumptions, cut list, trap index.First real-ROM run (measured, read-only): 42,856 stages / 38,809 programs in 1m15s; 46,500 slots translated in 3m20s, 0 translate failures; 5.93 GB bank, 0 bad records; 90,132/90,135 modules valid (99.9967%) under the layout feature the build enables; 167 skips itemized (71 tensor-gate, now covered by profiles; 95 real recompiler gaps the shipping build also skips; 1 capture refusal).
Why: first-visit shader stutter is the player-facing cost of runtime translation; this moves all of it ahead of time for archived content, locally from the user's own ROM — no cache sharing, no legal gray zone, supportable upstream. Built by four independent implementations that converged (four-way stamp agreement, mutual verification).
Second commit: --target profiles + layout-aware verify gate (both MiMo-verified with independent rebuilds and measurements).
Nice piece of tooling, and purely additive is the right shape for it. One thing will break CI though.
tests/test_bake_skeleton.pyhardcodesdir="/tmp/opencode"in fourtempfile.TemporaryDirectory(...)calls (lines 91, 128, 183, 245), plustool = "/tmp/opencode/sb-tool-cache"(188, 250).run_all.pypicks up everytests/test_*.pyautomatically, andTemporaryDirectory(dir=...)raises FileNotFoundError when that directory doesn't exist, which is the case on CI runners and on Windows. Sotest_bake_end_to_endand friends will fail rather than skip. Please drop thedir=argument (use the default temp dir) and put the tool cache inside the temp dir or undertempfile.gettempdir(). Also: the translate tests there need a compiler/headers, so they should skip when those are missing, the way test_bake_mimo.py does.Smaller things (nits):
nx2/bake_ds/build.shdefaultsOUTto/tmp/opencode/dsand looks for externals in/home/deck/azahar-build/externals. Those are your machine's paths; I'd keep only the$ROOT-relative candidates and default OUT to something under${TMPDIR:-/tmp}. Same default appears in thetest_bake_ds.pydocstring.gpu/shaderbatch.cppandnx2/bake_mimo.pypoint toBAKE-MIMO.mdfor the stop-lines, but that file isn't in the PR (BAKE.md is). Point them at BAKE.md.I didn't build or run the translator, so I'm taking the 90,132/90,135 module numbers from the description.
Re-review at
a2bbd4e. The new commits (verify/partial-bank work in bake.py, bake_ds, BAKE.md) don't touch the blocker from last round, and the new test added one more instance of it.Still open:
tests/test_bake_skeleton.pystill hardcodesdir="/tmp/opencode"(lines 91, 128, 183, 245, and the new one at 285) plustool = "/tmp/opencode/sb-tool-cache"(188, 250, 290).run_all.pydiscovers everytests/test_*.py, andTemporaryDirectory(dir=...)raises FileNotFoundError when that dir doesn't exist (CI, Windows). Dropping thedir=argument and putting the tool cache under the temp dir fixes it. These tests also need a compiler/headers, so they should skip when those are missing like test_bake_mimo.py does.Nits, still unchanged:
nx2/bake_ds/build.shdefaults (OUT=/tmp/opencode/ds,/home/deck/azahar-build/externals) and the same default in thetest_bake_ds.pydocstring;BAKE-MIMO.mdreferences ingpu/shaderbatch.cpp/nx2/bake_mimo.py(check whether they're fixed, I didn't see that file added).Also: if you add RUN_ALL_ARGS/RUN_ALL_SKIP needs for these tests, they now live in each test file (see #1822), not in run_all.py. No CI has run on this branch yet (no checks reported).
@ -0,0 +1,316 @@"""Bake skeleton end-to-end on synthetic data only (no game files, no GPU).Same hardcoded
/tmp/opencodehere (andtoolat line 290), now in the new partial-bank test too. Use the default temp dir.Review follow-ups landed (commit
31d3b83):dir="/tmp/opencode"dropped (default temp dirs), tool caches live inside the temp dir, and compiler-dependent tests skip when the toolchain is missing (thebake_mimopattern — including the partial-bank test, which I initially missed and caught on the re-run: 9/9 green locally).build.shOUT is now${TMPDIR:-/tmp}-relative, machine-specific externals path removed (docstring + BAKE.md updated); dangling doc references repointed atBAKE.md(verified no other references to non-PR files);RUN_ALL_ARGSdeclared intest_bake_mimo.pyper #1822 (skeleton keeps in-test skips so file-level declaration doesn't nuke coverage; ds self-skips on--tool).Note: the new runner's
header_dirdoesn't probe in-treebuildext/cpm, so locally the mimo test skips at runner level while the skeleton runs its translate half via its own probe; consistent on CI (nobuildext/there). Thenx2/build.pyline refs in PR comments now point at moved code (comment-only).Conflicts resolved and pushed (merge
9b424be+ one-line fixc00cfab):self.require_toolchain()(nonexistent method) instead of the module-level call — the exact failure mode the review flagged, now fixed and green (9/9 locally; skips-not-errors where no toolchain exists).Thanks, this covers what I raised before.
tests/test_bake_skeleton.pyno longer hardcodes/tmp/opencode: all five temp dirs useTemporaryDirectory(prefix=...)in the default location, the tool caches live inside them, and the translate/verify tests skip when the compiler or SPIR-V headers aren't there. So it shouldn't fail on CI runners or Windows any more.tests/test_bake_mimo.pydeclaresRUN_ALL_ARGSwith{cxx}/{spirv_headers}, whichrun_all.pyknows.build.shdefaults to${TMPDIR:-/tmp}/hookshot-ds, and the machine-specific path is gone.dsfixture is a hand-built synthetic tree, with no dumped shaders or banks.Nit:
test_bake_skeleton.pyskips inside the test rather than throughRUN_ALL_SKIP, which is fine, just less visible in the run summary.CI hasn't run on this branch yet (the fork workflows are waiting for approval), so it'd be good to confirm the new tests skip rather than fail once they do.