Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions desktop-src/direct3dhlsl/waveactivecountbits.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<dl> <dt>
Expand Down
3 changes: 2 additions & 1 deletion desktop-src/direct3dhlsl/waveballot.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ uint result = WaveActiveCountBits( bBit );
Instead of:

``` syntax
uint result = countbits( WaveActiveBallot( bBit ) );
uint4 bits = countbits( WaveActiveBallot( bBit ) );
uint result = bits.x + bits.y + bits.z + bits.w;
```

This function is supported from shader model 6.0 in all shader stages.
Expand Down