Skip to content

Require the Metal compiler the shaders were tested with - #333

Closed
v0lumehi wants to merge 2 commits into
seedds:mainfrom
v0lumehi:require-tested-metal
Closed

v0lumehi wants to merge 2 commits into
seedds:mainfrom
v0lumehi:require-tested-metal

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Require the Metal compiler the shaders were tested with

Part of #242.

Symptom. Players building on macOS 26 get corrupted pictures. The shader chain is tested with the Metal compiler in dm/gfx/tools/dmsh_chain.lock (Apple metal version 32023.921, Xcode 27.1, which needs macOS 26.6 or later). The NSP script builds every NVN game's shaders through own_compilers.py, which let any Metal compiler through with one note: line, and the README named no Xcode version.

Fix. The tested Metal compiler becomes a requirement; another one stops the build unless asked for.

  • dm/gfx/tools/own_compilers.py: a Metal compiler (macOS or iOS) other than the lock's stops the build with one [RED] line. The line names both versions, Xcode 27.1 / macOS 26.6, xcodebuild -downloadComponent MetalToolchain and the override. DM_ALLOW_OTHER_METAL=1 builds with it anyway, and the note: line then names the override. spirv-cross may still differ, with the note as before: Homebrew builds it from source on macOS 26, so its fingerprint never matches there even at the same version, and Pin spirv-cross with the translation chain #337 pins it with the chain. A missing compiler or another translator fails as before.
  • scripts/build_ipa_from_nsp.py: check_metal runs own_compilers.py --check-metal as soon as the graphics API is known, before an NVN game's captures and shader split. A Mac with another Xcode now stops in seconds, not after the split. ALLOW_OTHER_METAL = True / --allow-other-metal skips the check and passes DM_ALLOW_OTHER_METAL=1 to the shader step, the same pattern as ALLOW_SHADER_REGRESSIONS (b117c91). Vulkan and OpenGL games don't use the lock, so they are not checked.
  • README: the build Mac needs macOS 26.6 or later with Xcode 27.1, and step 1 adds xcodebuild -downloadComponent MetalToolchain (since Xcode 26 the Metal toolchain is a separate download). docs/development.md, dm/gfx/README.md and docs/env_switches.tsv describe the check and the override.

Not a chain bump. own_compilers.py is not one of the files dmsh_chain.py fingerprints, so DMSH_CHAIN stays a4e2088c2e69 and existing libraries stay valid. dmsh_build.py run directly (the maintainer's path) keeps its strict check of every tool.

iOS path. The lock has both metal_macosx and metal_iphoneos, and both are checked the same way, also in a Mac-only build (both come from the same Xcode). ios_metal.py is unchanged.

Checked

  • dm/tools/tests/test_own_compilers.py (new, 10 tests):
    • another macOS or iOS Metal compiler stops, and the message carries the versions, the Xcode, the toolchain download and the override;
    • the override builds with the other compiler and notes it;
    • spirv-cross alone is a note;
    • a missing compiler or another translator still fails;
    • --check-metal reports correctly;
    • the NSP script's check raises with its own override wording, is skipped with ALLOW_OTHER_METAL, parses the flag, and passes DM_ALLOW_OTHER_METAL to the shader step.
  • By hand, with a stand-in xcrun that reports 32023.850: --check-metal exits 1 with the message, or 0 with the override. own_compilers.py stops before translating anything, and with the override it goes on and prints the note. With the real Xcode 27.1 (macOS 27.0, M-series), --check-metal exits 0 and the build passes the tool check.
  • dm/ios/tests/test_xcode_workflow.py stubs check_metal like check_prereqs (it runs main for an NVN fixture; the real check stops on the CI runner's Xcode).
  • test_docs, test_env_switches, test_nsp_mac, test_nsp_chain, test_nsp_incremental, test_shader_regressions, and lint_python.py with the pinned tools (the baseline loses own_compilers.py's three Optional-subscript findings).

Users building on macOS 26 got corrupted pictures (seedds#242): the shader chain is tested with the
Metal compiler in dmsh_chain.lock (32023.921, Xcode 27.1), but own_compilers.py, through which
the NSP script builds every NVN game's shaders, let any Metal compiler through with one note
line, and the README named no Xcode version.

- own_compilers.py: another Metal compiler (macOS or iOS) stops the build with a message naming
  the Xcode to install and the Metal toolchain download, unless DM_ALLOW_OTHER_METAL=1, which
  builds with it and says so in the note line. spirv-cross may still differ (a note, as before).
  A missing compiler or another translator fails as before. own_compilers.py is not one of the
  chain's fingerprinted files: the chain version does not change.
- NSP script: check_metal runs own_compilers.py --check-metal before an NVN game's captures and
  shader split, so a Mac with another Xcode stops in seconds instead of after the split;
  ALLOW_OTHER_METAL / --allow-other-metal skips it and passes DM_ALLOW_OTHER_METAL to the shader
  step (modelled on ALLOW_SHADER_REGRESSIONS). Vulkan and OpenGL games do not use the lock and
  are not checked.
- README: the build Mac needs macOS 26.6 or later with Xcode 27.1, and the Metal toolchain
  (xcodebuild -downloadComponent MetalToolchain). docs/development.md, dm/gfx/README.md and
  docs/env_switches.tsv describe the check and the override.
- dm/tools/tests/test_own_compilers.py: the stop (macOS and iOS), the override, spirv-cross as
  a note, missing compiler and translator mismatches, --check-metal, and the NSP script's check,
  flag and environment.
test_xcode_workflow runs the NSP script's main for an NVN fixture with every
step stubbed; check_metal ran the real own_compilers.py --check-metal, which
stops on the CI runner's Xcode. Stub it like check_prereqs.
@v0lumehi
v0lumehi force-pushed the require-tested-metal branch from f85b568 to cee9b90 Compare October 26, 2026 23:47
seedds added a commit that referenced this pull request Oct 27, 2026
Incorporate the tested Metal compiler requirement and reproducible universal
SPIRV-Cross build from PRs #333 and #337. Credit v0lumehi for the compiler
guard, bundled converter, build recipe, licences, tests and documentation.

Require the pinned converter for NVN builds. Include actual compiler/SDK
identities in shader and fetch-variant cache keys, stamp every library's
compiler provenance, and reject foreign or unmarked libraries during prefill.
Bump the Metal cache format to discard entries older prefill could misclassify.
Fingerprint selected converter overrides in NSP and regression keys, and keep
subgroup CI coverage on the bundled converter.

Two independent converter rebuilds match the committed binary. Comparisons
on Galaxy 2 and Balatro produce 3,830 identical MSL outputs. The 420-test
Python suite, pinned lint, graphics suite, Mac host and Mac/iOS TACTICS shader
build pass. The two-game shader regression report has no new failures or MSL
changes; TACTICS variants differ only in provenance metadata. The full local
game sweep remains incomplete. Issue #242's rendering cause is unconfirmed.

Co-authored-by: v0lumehi <aljic.zijad@gmail.com>
@seedds

seedds commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Thanks, @v0lumehi. Incorporated this PR and #337 into main in 4eeac03, with you credited as coauthor. Closing this PR because its changes are included in that combined commit.

The early tested-Metal check, installation guidance and explicit override are retained. I also fixed the shared cache paths that could otherwise restore libraries built by another compiler: shader and fetch-variant keys include the actual compiler/SDK identity, every prefilled library must carry matching compiler provenance, and the Metal cache format is bumped to reject previously misclassified entries. The bundled SPIRV-Cross must now match the lock even when another Metal compiler is explicitly allowed. This is general shader-build behavior, with no per-game rule.

Validation after rebasing onto current main: all 53 Python test files pass (422 tests), pinned lint has no new findings, and the graphics suite passes. A complete TACTICS shader build passed for Mac and iOS, with compiler provenance checked on all 312 library reflections per platform.

The report below covers shader builds for TACTICS and Super Mario Galaxy 2. TACTICS' sole CHANGED item is geometry reflection metadata (chain and chain_compiler); its MSL and binary libraries are unchanged. Galaxy 2 passes. These two profiles have no smoke route, so this report includes no gameplay run. The full local-game sweep remains incomplete, and the cause of #242's rendering corruption is still unconfirmed; #242 remains open.

Local shader regression report

regress.py check (full): CHANGED

Baseline origin/main b7a5cd4, candidate HEAD 4eeac03; Apple M4 Pro, macOS 27.0.1, Xcode 27.1; 5.1 s

game status shaders (base → cand) newly failing newly building changed MSL interface (new / known) boot fps p50 frame p99 ms peak MB prepare s new RED
FINAL FANTASY TACTICS - The Ivalice Chronicles 010038B015560000 CHANGED 306/306 → 306/306 0 0 0 0 / 0 – – – – – –
Super Mario Galaxy 2 0100FD8022DAA000 PASS 5009/5009 → 5009/5009 0 0 0 – – – – – – –

FINAL FANTASY TACTICS - The Ivalice Chronicles 010038B015560000: CHANGED

  • CHANGED: 1 shaders changed (MSL 0, reflection 0, variants 1)
    • changed shaders: 7e9d62fedb21324b
    • time: chain 0.2 s

Super Mario Galaxy 2 0100FD8022DAA000: PASS

  • time: chain 4.7 s

@seedds seedds closed this Oct 27, 2026
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
Incorporate the tested Metal compiler requirement and reproducible universal
SPIRV-Cross build from PRs seedds#333 and seedds#337. Credit v0lumehi for the compiler
guard, bundled converter, build recipe, licences, tests and documentation.

Require the pinned converter for NVN builds. Include actual compiler/SDK
identities in shader and fetch-variant cache keys, stamp every library's
compiler provenance, and reject foreign or unmarked libraries during prefill.
Bump the Metal cache format to discard entries older prefill could misclassify.
Fingerprint selected converter overrides in NSP and regression keys, and keep
subgroup CI coverage on the bundled converter.

Two independent converter rebuilds match the committed binary. Comparisons
on Galaxy 2 and Balatro produce 3,830 identical MSL outputs. The 420-test
Python suite, pinned lint, graphics suite, Mac host and Mac/iOS TACTICS shader
build pass. The two-game shader regression report has no new failures or MSL
changes; TACTICS variants differ only in provenance metadata. The full local
game sweep remains incomplete. Issue seedds#242's rendering cause is unconfirmed.

Co-authored-by: v0lumehi <aljic.zijad@gmail.com>
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