From 4d517171231250ccee3bca7d20ed96625d89c6fb Mon Sep 17 00:00:00 2001 From: Damyan Pepper Date: Fri, 11 Jul 2025 10:20:40 -0700 Subject: [PATCH 1/3] Update waveactivecountbits.md This example was incorrectly copied from the [spec](https://github.com/microsoft/DirectXShaderCompiler/wiki/Wave-Intrinsics#uint-waveactivecountbits-bool-bbit-), replacing `countbits` with `WaveActiveCountBits`. --- desktop-src/direct3dhlsl/waveactivecountbits.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop-src/direct3dhlsl/waveactivecountbits.md b/desktop-src/direct3dhlsl/waveactivecountbits.md index 392fbd43060..07ea24ae12d 100644 --- a/desktop-src/direct3dhlsl/waveactivecountbits.md +++ b/desktop-src/direct3dhlsl/waveactivecountbits.md @@ -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: ``` syntax -result = WaveActiveCountBits( WaveActiveBallot( bBit ) ); +result = countbits( WaveActiveBallot( bBit ) ); ``` ## See also From 527ae119bb3bfa2d84f7e00f489fbdb4b0cc9546 Mon Sep 17 00:00:00 2001 From: Damyan Pepper Date: Fri, 11 Jul 2025 10:45:02 -0700 Subject: [PATCH 2/3] Fixup examples --- desktop-src/direct3dhlsl/waveactivecountbits.md | 13 +++++++++++-- desktop-src/direct3dhlsl/waveballot.md | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/desktop-src/direct3dhlsl/waveactivecountbits.md b/desktop-src/direct3dhlsl/waveactivecountbits.md index 07ea24ae12d..dc2b0491798 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 = countbits( 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 langes +uint result = WaveActiveCountBits(true); ``` + ## See also
diff --git a/desktop-src/direct3dhlsl/waveballot.md b/desktop-src/direct3dhlsl/waveballot.md index a27f6c2c054..873c29fa608 100644 --- a/desktop-src/direct3dhlsl/waveballot.md +++ b/desktop-src/direct3dhlsl/waveballot.md @@ -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. From 9931e952ba29fcd72dcdd4edcfb45bb381e4e182 Mon Sep 17 00:00:00 2001 From: Damyan Pepper Date: Fri, 11 Jul 2025 10:51:28 -0700 Subject: [PATCH 3/3] typo --- desktop-src/direct3dhlsl/waveactivecountbits.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop-src/direct3dhlsl/waveactivecountbits.md b/desktop-src/direct3dhlsl/waveactivecountbits.md index dc2b0491798..751ed4dfdb5 100644 --- a/desktop-src/direct3dhlsl/waveactivecountbits.md +++ b/desktop-src/direct3dhlsl/waveactivecountbits.md @@ -65,7 +65,7 @@ uint result = WaveActiveSum(1); uint4 bits = countbits( WaveActiveBallot( bBit ) ); uint result = bits.x + bits.y + bits.z + bits.w; -// Use WaveActiveCountBits to count number of active langes +// Use WaveActiveCountBits to count number of active lanes uint result = WaveActiveCountBits(true); ```