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)| Parameter | Type | Default Value |
|---|---|---|
| builtinName | string | — |
| nodeType | string | — |
Constructs a new compute builtin node.
| Accessor | Type | |
|---|---|---|
| get type | string | |
Properties
| Property | Type | Default Value | |
|---|---|---|---|
| _builtinName | string | — | |
| Method | Type | |
|---|---|---|
| getHash | (builder: NodeBuilder) => string | |
| generateNodeType | () => string | |
| setBuiltinName | (builtinName: string) => ComputeBuiltinNode | |
| getBuiltinName | () => string | |
| hasBuiltin | (builder: NodeBuilder) => boolean | |
| generate | (builder: any, output: any) => any | |
| serialize | (data: any) => void | |
| deserialize | (data: any) => void | |
Extends
NodeRepresents 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>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>A non-linearized 3-dimensional representation of the current invocation’s position within a 3D global grid.
Type
ComputeBuiltinNode<uvec3>A non-linearized 3-dimensional representation of the current invocation’s position within a 3D workgroup grid.
Type
ComputeBuiltinNode<uvec3>A device dependent variable that exposes the size of the current invocation’s subgroup.
Type
ComputeBuiltinNode<uint>