Update examples in waveballot.md and waveactivecountbits.md#2077
Open
damyanp wants to merge 3 commits into
Open
Update examples in waveballot.md and waveactivecountbits.md#2077damyanp wants to merge 3 commits into
damyanp wants to merge 3 commits into
Conversation
This example was incorrectly copied from the [spec](https://github.com/microsoft/DirectXShaderCompiler/wiki/Wave-Intrinsics#uint-waveactivecountbits-bool-bbit-), replacing `countbits` with `WaveActiveCountBits`.
Contributor
|
@damyanp : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change. |
tex3d
reviewed
Jul 11, 2025
|
|
||
| ``` syntax | ||
| result = WaveActiveCountBits( WaveActiveBallot( bBit ) ); | ||
| result = countbits( WaveActiveBallot( bBit ) ); |
Contributor
There was a problem hiding this comment.
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.
tex3d
reviewed
Jul 11, 2025
| @@ -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: | |||
Contributor
There was a problem hiding this comment.
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: |
Contributor
Author
There was a problem hiding this comment.
Tried another way to put this, hopefully this is clearer?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One example was incorrectly copied from the spec, replacing
countbitswithWaveActiveCountBits. In both cases they were relying on an implicit vector truncation which would result in incorrect results on devices with wave size > 32.