Commit Graph

2 Commits

Author SHA1 Message Date
4f760c1aed Shader: isolate wave32 pixel operations in wider subgroups (SHADER-731) 2026-11-22 20:07:05 -04:00
289f2e948a Translator: v_readfirstlane_b32 in a vertex shader without BallotFindLSB (SHADER-413)
A native readfirstlane is a ballot of the EXEC lanes, its lowest set bit
and a shuffle from that lane. MoltenVK lowers OpGroupNonUniformBallotFindLSB,
like the SubgroupSize built-in, to Metal's threads_per_simdgroup input,
which a vertex function can't declare, so every VS with a readfirstlane
failed to compile on Apple GPUs.

In a vertex shader the lowest bit is now taken with FindILsb over the
ballot's four words, the form the --wave64-emulate path already uses on
its mask words. It gives the same lane, since a ballot has no bit at or
above the subgroup size. Other stages keep BallotFindLSB.

On an Apple M4 (MoltenVK 1.4.2), with the 1.0.2.1 corpus translated from
4eb6155d: exactly the 572 VS that contain v_readfirstlane_b32 change, and
all 2,236 stay spirv-val-valid. VS pipelines go from 667 to 672 on main,
and from 1,662 to 2,233 of 2,236 with #1784's --no-vertex-subgroups.

tests/semantic/test_vs_readfirstlane.py runs it on the wave interpreter,
with the first EXEC lane in word 0 and word 1 of the ballot.

AI-assisted.
2026-11-22 18:14:30 +01:00