diff --git a/desktop-src/direct3dhlsl/waveactivecountbits.md b/desktop-src/direct3dhlsl/waveactivecountbits.md index 392fbd43060..751ed4dfdb5 100644 --- a/desktop-src/direct3dhlsl/waveactivecountbits.md +++ b/desktop-src/direct3dhlsl/waveactivecountbits.md @@ -55,12 +55,21 @@ This function is supported from shader model 6.0 in all shader stages. ## Examples -This can be implemented more efficiently than a full WaveActiveSum, as described in the following example: +Although these are all equivalent, WaveActiveCountBits is the most efficient way to achieve this: ``` syntax -result = WaveActiveCountBits( WaveActiveBallot( bBit ) ); +// Use WaveActiveSum to count number of active lanes +uint result = WaveActiveSum(1); + +// Use countbits and WaveActiveBallot to count number of active lanes +uint4 bits = countbits( WaveActiveBallot( bBit ) ); +uint result = bits.x + bits.y + bits.z + bits.w; + +// Use WaveActiveCountBits to count number of active lanes +uint result = WaveActiveCountBits(true); ``` + ## See also