Files
metal2vulkan/docs
Anees Iqbal 04bf17db16 Fence each optnone call only helper invocations may make before a storage write with an identity simdgroup shuffle
What: on a driver whose compiler loses a simdgroup's texture writes after an `optnone` call that
only its helper invocations make (DriverWorkaround::DiscardDropsSimdgroupStores: MoltenVK on an
Apple GPU), a call the helper guard cannot keep the helpers away from exactly (an arm with a
derivative or subgroup operation, a loop the helpers repeat alone) and that no tangled
instruction reading its result follows was left as it was, with
PrecisionNote::HelperBranchDropsSimdgroupStores recorded. Now spirv::helper_branches fences each
such call: an OpGroupNonUniformShuffle of its result at SubgroupLocalInvocationId (a
MulExtended's structure member by member, put together again) follows it, and every use reads
the shuffled value. Each invocation, a helper too, reads its own lane, so no answer changes and
no lane reads another's; the shuffle is the simdgroup operation after the call, reading what it
computes, that the M4 probe found keeps the writes. The fences are placed once every analysis of
the module has run (compile.rs, before the verifier): those analyses would read a shuffle as a
move between lanes.
- guard_for returns the Fences beside Guarded (Guarded::fences counts them); plan lists every
  bare call (Facts::bare, which any_bare was) and no longer stops at the first function with one.
- The census names the fences `fragment.helper-fence`; the runtime's pipeline creation log
  prints `helper-fence <stage>`.
- The note stays where no shuffle can follow: no fragment-stage subgroup shuffle on the profile,
  or a 64-bit or bool lane, or an 8- or 16-bit one without shaderSubgroupExtendedTypes.

Why: the weather widget's glass edges in the 27.0.1 guest on the M3 draw white 8x4-pixel blocks
along the primitive's edges (solid strips in some boots, a comb in others, at every pin since 30),
and the guest's run announces helper-branch-drops-simdgroup-stores for a fragment function.

Tests: engine_fragment's helper guard tests (rch_helper_branch_loop and rch_helper_tangle's
`before` and `unread` functions fenced, census and shuffles counted, no note, L3), a new test that
the note stays with the fragment shuffle taken out of the profile, and the runtime lane
helper_tangle, which now requires the fence and no lost write where the fragment stage shuffles.
SEMANTICS_VERSION 2021.

Verified: cargo fmt; the build, the touched tests and the M3 lane follow.
2026-11-11 01:12:17 -08:00
..