subgroupMul
A subgroup reduction that multiplies the input value across all active invocations in the subgroup and broadcasts the product to every active lane.
Core Advantages
Uses hardware-accelerated subgroup ops to reduce within a wave/warp without explicit loops, shared memory or barriers. Handy for all()-style tests with 0/1 masks and for combining multiplicative terms (e.g., transmittance).
Common Uses
All test within a subgroup: multiply 0/1 masks; result == 1 means all passed, 0 means at least one failed.
Combine multiplicative quantities (transmittance/probability/weights) across the subgroup.
Do a subgroup pre-reduction to speed up wider reductions.
Block-level product accumulation in compute shaders.
How to adjust
Pass exactly one numeric argument (float recommended; [0,1] is the clearest). Inside divergent control flow only active lanes participate. Missing arguments are padded with 0, yielding a 0 product. Availability depends on backend support; consider a fallback for unsupported targets.
Code Examples
1// Subgroup all test (any failure makes the product 0)
2const mask = step( 0.5, quality ); // 0 or 1
3const allPass = subgroupMul( mask );
4allPass.equal( 0 ).discard();
5
6// Combine per-lane transmittance (0-1)
7const t = saturate( transmittance );
8const T = subgroupMul( t ); // broadcast within the subgroup
9