2.7 KiB
metal2vulkan-ab — byte-A/B translation harness
Translates a pinned sample set with two metal2vulkan binaries and diffs the emitted SPIR-V
byte-for-byte, so a behavior-preserving refactor can be proven not to move any output on the
sample before more expensive checks.
Why byte comparison is meaningful
The emitter's output is id-canonicalized by passes::canonicalize_ids, so equal semantics ⇒ equal
bytes for the vast majority of cases. If a case stays nondeterministic across runs, fall back to a
semantic or validator gate rather than trusting the byte diff alone.
The CLI writes out.spv before running spirv-val, so a case that FALLBACKs at the spirv-val step
still produces comparable bytes. A case whose translate() errors writes no file and is reported as
a translate failure, not a diff.
Usage
# self-test: HEAD vs HEAD (exit 0 when every case is IDENTICAL or BOTH-FAIL)
./metal2vulkan-ab.sh
# real A/B: build the crate before your change and after, then diff
git stash # or check out the parent commit
cargo build --release --bin metal2vulkan
cp target/release/metal2vulkan ./m2v-old
git stash pop
./metal2vulkan-ab.sh --old ./m2v-old
# optional extra shaders after --
./metal2vulkan-ab.sh --old ./m2v-old -- path/to/case.ll
Flags:
--old PATH— "before" binary. Default: build--releasefrom this checkout.--new PATH— "after" binary. Default: same as--old(a self-test).--quiet— print only the summary and any regressions.-- file…— additional.ll/.airinputs to include in the sample.
Because --new defaults to --old, an explicit A/B run is usually: pass the pre-change binary as
--old and let --new build the current tree, or pass both explicitly.
Sample set
- Every
*.air/*.llundertests/fixtures/**when that directory exists (gitignored). - Every
*.air/*.llundervalidation/fixtures/public/**(committed synthetic samples). - Every
*.air/*.llundervalidation/corpus/local/air/**(gitignored private harvest). - Any paths listed after
--.
Paired harvest outputs (stem.air + stem.ll) use only the .ll so each module is
compared once.
This public tree does not ship third-party captured shaders. For cross-version hash pins (without
keeping two binaries around), see scripts/metal2vulkan-drift/ and
validation/corpus/README.md.
Output
Per-case verdicts (IDENTICAL / DIFFERS / OLD-ONLY / NEW-ONLY / BOTH-FAIL) plus a summary
line. Exit status is 0 only when there are no DIFFERS and no asymmetric cases; any byte
divergence exits 1. BOTH-FAIL (both binaries FALLBACK identically) is not a regression.