ComputeBuiltinNode

Last modified: Mar 5, 2026

ComputeBuiltinNode represents a compute-scope builtin value that expose information about the currently running dispatch and/or the device it is running on.

This node can only be used with a WebGPU backend.

Constructor

new ComputeBuiltinNode(builtinName, nodeType)
ParameterTypeDefault Value
builtinNamestring
nodeTypestring

Constructs a new compute builtin node.

AccessorType

Properties

PropertyTypeDefault Value
_builtinNamestring
MethodType

Extends

Node

numWorkgroups

Represents the number of workgroups dispatched by the compute shader.

// Run 512 invocations/threads with a workgroup size of 128.
const computeFn = Fn(() => {
Cannot redeclare block-scoped variable 'computeFn'. (2451)
    // numWorkgroups.x = 4
    storageBuffer.element(0).assign(numWorkgroups.x)

})().compute(512, [128]);

// Run 512 invocations/threads with the default workgroup size of 64.
const computeFn = Fn(() => {
Cannot redeclare block-scoped variable 'computeFn'. (2451)
    // numWorkgroups.x = 8
    storageBuffer.element(0).assign(numWorkgroups.x)

})().compute(512);
export {}

Type

ComputeBuiltinNode<uvec3>

workgroupId

Represents the 3-dimensional index of the workgroup the current compute invocation belongs to.

// Execute 12 compute threads with a workgroup size of 3.
const computeFn = Fn( () => {

	If( workgroupId.x.mod( 2 ).equal( 0 ), () => {

		storageBuffer.element( instanceIndex ).assign( instanceIndex );

	} ).Else( () => {

		storageBuffer.element( instanceIndex ).assign( 0 );

	} );

} )().compute( 12, [ 3 ] );

// workgroupId.x =  [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3];
// Buffer Output =  [0, 1, 2, 0, 0, 0, 6, 7, 8, 0, 0, 0];
export {}

Type

ComputeBuiltinNode<uvec3>

globalId

A non-linearized 3-dimensional representation of the current invocation’s position within a 3D global grid.

Type

ComputeBuiltinNode<uvec3>

localId

A non-linearized 3-dimensional representation of the current invocation’s position within a 3D workgroup grid.

Type

ComputeBuiltinNode<uvec3>

subgroupSize

A device dependent variable that exposes the size of the current invocation’s subgroup.

Type

ComputeBuiltinNode<uint>