Skip to content
Open
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion desktop-src/direct3dhlsl/waveactivecountbits.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ This function is supported from shader model 6.0 in all shader stages.
This can be implemented more efficiently than a full WaveActiveSum, as described in the following example:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this line should be clarified that this is meant to demonstrate what this operation does:

Suggested change
This can be implemented more efficiently than a full WaveActiveSum, as described in the following example:
This can be implemented more efficiently than a full WaveActiveSum, in a way similar to this equivalent code:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried another way to put this, hopefully this is clearer?


``` syntax
result = WaveActiveCountBits( WaveActiveBallot( bBit ) );
result = countbits( WaveActiveBallot( bBit ) );
Copy link
Contributor

@tex3d tex3d Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an improvement, but still not quite correct HLSL. It needs to be more like this:

Suggested change
result = countbits( WaveActiveBallot( bBit ) );
uint4 counts = countbits( WaveActiveBallot( bBit ) );
result = counts.x + counts.y + counts.z + counts.w;

This is because WaveActiveBallow returns a uint4 in order to have one bit for every potential lane in the widest possible lane width of 128.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Updated.

```

## See also
Expand Down