subgroupInclusiveAdd
Performs an "inclusive" addition scan (inclusive scan) inside a subgroup (subgroup / wave / warp), returning the prefix sum for the calling invocation within its subgroup (including itself). Available only when the underlying backend supports subgroup operations.
Core Advantages
Computes prefix sums within the subgroup using hardware-level parallelism, avoiding explicit shared memory and multiple synchronizations. In TSL this node is wrapped via nodeProxyIntent as a unary function (setParameterLength(1)) and automatically generates temporaries (toVarIntent), which makes reuse and composition easier.
Common Uses
Prefix sums in compute shaders: histograms, bucketing, prefix allocation and other parallel algorithms.
Flows based on cumulative intensity or masks (per-pixel or per-sample parallel accumulation).
Local scan building block in subgroup-level data compaction or sorting stages.
How to adjust
Control the result by changing the input value; the function is fixed to a single parameter. Ensure the runtime enables subgroup features and account for subgroup size and boundaries in your algorithm (subgroup sizes may differ across devices).
Code Examples
1// Compute an inclusive prefix sum of each invocation's floating value within the subgroup
2const prefix = subgroupInclusiveAdd( value );
3// Can be used for cumulative weights/indices. Note the result is defined only within subgroup boundaries
4