Intrinsics1 min read

wave_all

Returns true if a condition is true in all active lanes.

Reading Time
1 min
Word Count
148
Sections
12
Try It Live

Test wave_all in a live shader

Open the playground, start from a visual preset, and wire wave_all into the fragment stage to see how it behaves with real values.

Open Playground

Live Demo Pending

This intrinsic does not yet have a self-contained interactive preview. Compute-only and external-resource intrinsics need a different demo path than the current fragment and 3D showcases.

The wave_all function returns true if and only if the input boolean is true in all active lanes of the wave.

Signature

bwsl
wave_all :: (bool x) -> bool {...}

Parameters

ParameterTypeDescription
xboolCondition to test

Return Value

Returns true if x is true in all active lanes, otherwise false.

Example

bwsl
pipeline EarlyOut {
pass "Main" {
compute "Main" [64, 1, 1] {
// Check if all threads can skip work
bool canSkip = distance > maxRange || occluded;
if (wave_all(canSkip)) {
// All threads can skip - exit early
return;
}
// At least one thread needs to do work
if (!canSkip) {
processWork(input.local_index);
}
}
}
}

Common Use Cases

Early Exit Optimization

bwsl
// Skip wave if all threads are out of bounds
bool outOfBounds = any(uv < 0.0 || uv > 1.0);
if (wave_all(outOfBounds)) {
return;
}

Uniform Code Path

bwsl
// Check if all lanes take the same branch
bool useHighQuality = detailLevel > 0.5;
if (wave_all(useHighQuality)) {
// Uniform branch - no divergence penalty
processHighQuality();
} else if (wave_all(!useHighQuality)) {
processLowQuality();
} else {
// Divergent - handle both cases
}

Validation

bwsl
// Check if all values are valid
bool valid = !isnan(value) && !isinf(value);
if (!wave_all(valid)) {
handleInvalidData();
}

Convergence Check

bwsl
// Iterative algorithm convergence
bool converged = abs(newValue - oldValue) < epsilon;
if (wave_all(converged)) {
break; // All lanes have converged
}

Occlusion Testing

bwsl
// Check if entire wave is occluded
bool occluded = testOcclusion(position);
if (wave_all(occluded)) {
return; // Skip rendering for this wave
}

Boolean AND

wave_all(x) is equivalent to a boolean AND across all active lanes. If any lane has false, the result is false.

Optimization

Use wave_all for early-out optimizations. If all lanes can skip work, the entire wave can exit early, saving significant computation.

Compiled Output

When compiled to GLSL:

glsl
// Requires GL_KHR_shader_subgroup_vote
subgroupAll(x)

When compiled to HLSL:

hlsl
WaveActiveAllTrue(x)

When compiled to SPIR-V:

Uses OpGroupNonUniformAll instruction.

See Also