Repository navigation
rdna2spirv: fix f32/f16 lg and permlane's active flag on MoltenVK - #6224
fishingpvalues wants to merge 3 commits into
Conversation
test_the_digest_follows_an_uncommitted_submodule_edit committed "-m x" in a temporary Git repository. A contributor whose global config sets core.hooksPath (a Conventional Commits commit-msg hook, e.g. a lint setup) had that hook reject the message, so the file failed on their machine while CI stayed green. Commit e1cc07c fixed the same problem in tests/test_make_game_submodule.py; this applies the same isolation to the two fixtures that still lacked it. The new test poisons the global config with a rejecting commit-msg hook, checks the control commit is rejected, and runs the fixture test in a subprocess under that config. It fails on main and passes with the fix.
compute_decoder_digest() hashed the submodule's HEAD and its `git diff HEAD`, so a decoder source file the submodule does not track yet (added, not `git add`ed) left decoder.sha256 unchanged and the assets stage kept an export the new file would change. The comment called that a shortcut; this closes it by hashing the paths and bytes of `git ls-files --others --exclude-standard -z`. Ignored files (bin/, obj/) stay out, so a build inside the submodule does not churn the digest. The new test fails on main (the digest is identical before and after adding NewDecoder.cs) and passes with the fix.
v_cmp(x)_lg_f32/f16 lowered to OpFOrdNotEqual. MoltenVK turns that into Metal's unordered `!=`, which is
true for a NaN operand where the ISA's ordered "less or greater" is false. That was the single wrong
predicate bit in ps_vcmp_f32_nan, ps_vcmp_f16{,_e64} and ps_vcmpx_f16{,_e64} on an Apple M3 Max (issue
ItsNotRexed#3796). `lg` is now OpFOrdLessThan || OpFOrdGreaterThan, the ISA definition, exact for every input and quiet
on NaN. The macOS GPU job loses those five from its expected failures.
v_permlane16/x16 reads the source lane's activity by shuffling a per-lane flag, which SPIRV-Cross inlines as
the shuffle's argument; the lanes it inlines away never compute the flag, so on MoltenVK every off source
lane read as active and cs_w32_permlane_fi returned 4 4 4 1 52 52 52 49 (it is not in the job's expected
failures). The flag is stored to a Function variable first, as the DPP fix did (SHADER-529).
Measured on an Apple M3 Max with MoltenVK 1.4.2: run_gpu_tests 165 passed / 59 skipped / 8 failed before,
171 / 59 / 2 after (ps_ssharp and cs_fma_fused left); ctest 59/59. The semantic suite keeps both fix shapes
and the value tests, and its permlane sabotage test follows the eager store.
3af1c64 to
baa9067
Compare
|
Independent Windows RTX 4080 regression check at |
|
Thanks @CryingLaughing — that is exactly the regression check needed: the five compares and |
|
Heads-up: |
|
@Mortify7612 is right — and the rest is covered too. I rebuilt |
Claimed in #5781 (claim).
Two translator fixes, both found by running the GPU suite on an Apple M3 Max (MoltenVK 1.4.2) — the Mac hardware, not the paravirtual runner.
1.
lgmust not beOpFOrdNotEqualv_cmp(x)_lg_f32/f16is the ISA's ordered "less or greater" (OpFOrdNotEqual). MoltenVK's SPIR-V → MSL lowers that op to Metal's!=, which is unordered: true when either operand is NaN, where the ordered predicate is false. That is the single wrong predicate bit behind the five failures in #3796's MoltenVK list:ps_vcmp_f32_nan(bit 4 of word 0:lgon (NaN, 1.0) — bits of0x377cvs want0x376c)ps_vcmp_f16,ps_vcmp_f16_e64(fieldlg, cases k3/k4,0x4ce9bda2vs0x4ce9b1a2)ps_vcmpx_f16,ps_vcmpx_f16_e64(same bit in the EXEC form)lgis nowOpFOrdLessThan || OpFOrdGreaterThan— the ISA definition, exact for every input (both are false on a NaN, so the OR is false;+0/-0compare equal) and quiet on NaN. It costs one extra instruction per floatlgsite.tools/rdna2spirv.py,tests/semantic/test_vcmp_f16.py(test_lg_is_two_ordered_compareskeepsOpFOrdNotEqualout of float compares), the contract row for the 16 VOPC predicates indocs/design.md, and the five lines leave.github/workflows/runtime.yml'sEXPECTED_FAILURESfor the macOS GPU job.2.
v_permlane16/x16must commit the source-active flag before the shuffleThe
FI=0path decides whether each destination lane's source is active by shuffling a per-lane1/0flag. SPIRV-Cross inlines a single-useOpSelectinto the shuffle's argument, and the lanes it inlines away never compute it — the same SPIRV-Cross behaviour the DPP fix hit (SHADER-529). On MoltenVK every off source lane therefore read as active:This test is not in the macOS job's
EXPECTED_FAILURES, so it fails there on real Apple hardware while the paravirtual runner passes it. The flag now goes throughGen.eager()(a Function variable and a store, which every lane runs) before the shuffle.tests/semantic/test_permlane_fi.pychecks the eager store, andtest_valu_permlane16.py's sabotage test now skips eager stores when it picks the destinationOpSelectto remove (it was matching the flag's select).Tests run
macOS 27.2 (26B123), Apple M3 Max, MoltenVK 1.4.2, CPU + the Mac's Metal GPU, no game files:
ctest --test-dir runtime/build— 59/59 passed (2 skipped), before any change to itscripts/run_gpu_tests.py(full suite):ps_ssharp(Apply the S#'s LOD bias in the shader where samplers take none (SHADER-268) #1845, the S# LOD bias a Metal sampler can't take) andcs_fma_fused, both still listed as expected failurescs_w32_permlane_fiare 4096/4096 (or their expected words) exactpython -I -m unittest discover -s tests/semantic: 6152 tests; the only failure wastest_valu_permlane16's sabotage test, updated here and passing (16/16);test_vcmp_f16.py4/4,test_permlane_fi.py2/2,test_float_compares.py,test_vopc_const_ordered.py,test_cmp_f64.py,test_interp.py,test_wave64_halves.pyall passpython -m pytest tests -k "cmp or compare or vcmp"— 350 passedAI-assisted.