WaveActiveBallot function

Returns a 4-bit unsigned integer bitmask of the evaluation of the Boolean expression for all active lanes in the specified wave.

Syntax

uint4 WaveBallot(
   bool expr
);

Parameters

expr

The boolean expression to evaluate.

Return value

A uint4 containing a bitmask of the evaluation of the Boolean expression for all active lanes in the current wave. The least-significant bit corresponds to the lane with index zero. The bits corresponding to inactive lanes will be zero. The bits that are greater than or equal to WaveGetLaneCount will be zero.

Remarks

Different GPUs have different SIMD processor widths (lane counts). Most of these WaveXXX functions are able to operate at level of abstraction where SIMD machine width is concealed. To maximize portability of code across GPUs, use the intrinsics that don’t rely on machine width. For example, use:

uint result = WaveAllCountBits( bBit );

Instead of:

uint result = countbits( WaveBallot( bBit ) );

This function is supported from shader model 6.0, in the following types of shaders:

Vertex Hull Domain Geometry Pixel Compute
x x

 

Examples

// get a bitwise representation of the number of currently active lanes:
uint4 waveBits = WaveActiveBallot( true ); // convert to bits 

See also

Overview of Shader Model 6

Shader Model 6