WithBinding
Methods
Section titled “Methods”createGuardedComputePipeline()
Section titled “createGuardedComputePipeline()”createGuardedComputePipeline<
TArgs>(callback):TgpuGuardedComputePipeline<TArgs>
Creates a compute pipeline that executes the given callback in an exact number of threads.
This is different from withCompute(...).createPipeline() in that it does a bounds check on the
thread id, where as regular pipelines do not and work in units of workgroups.
Type Parameters
Section titled “Type Parameters”• TArgs extends number[]
Parameters
Section titled “Parameters”callback
Section titled “callback”(…args) => void
A function converted to WGSL and executed on the GPU. It can accept up to 3 parameters (x, y, z) which correspond to the global invocation ID of the executing thread.
Returns
Section titled “Returns”TgpuGuardedComputePipeline<TArgs>
Examples
Section titled “Examples”If no parameters are provided, the callback will be executed once, in a single thread.
const fooPipeline = root .createGuardedComputePipeline(() => { 'use gpu'; console.log('Hello, GPU!'); });
fooPipeline.dispatchThreads();// [GPU] Hello, GPU!One parameter means n-threads will be executed in parallel.
const fooPipeline = root .createGuardedComputePipeline((x) => { 'use gpu'; if (x % 16 === 0) { // Logging every 16th thread console.log('I am the', x, 'thread'); } });
// executing 512 threadsfooPipeline.dispatchThreads(512);// [GPU] I am the 256 thread// [GPU] I am the 272 thread// ... (30 hidden logs)// [GPU] I am the 16 thread// [GPU] I am the 240 threadDefined in
Section titled “Defined in”packages/typegpu/src/core/root/rootTypes.ts:267
pipe()
Section titled “pipe()”pipe(
transform):WithBinding
Parameters
Section titled “Parameters”transform
Section titled “transform”(cfg) => Configurable
Returns
Section titled “Returns”Defined in
Section titled “Defined in”packages/typegpu/src/core/root/rootTypes.ts:293
with()
Section titled “with()”Call Signature
Section titled “Call Signature”with<
T>(slot,value):WithBinding
Type Parameters
Section titled “Type Parameters”• T
Parameters
Section titled “Parameters”TgpuSlot<T>
Eventual<T>
Returns
Section titled “Returns”Defined in
Section titled “Defined in”packages/typegpu/src/core/root/rootTypes.ts:279
Call Signature
Section titled “Call Signature”with<
T>(accessor,value):WithBinding
Type Parameters
Section titled “Type Parameters”• T extends WgslTexture<WgslTextureProps> | WgslStorageTexture<WgslStorageTextureProps>
Parameters
Section titled “Parameters”accessor
Section titled “accessor”TgpuAccessor<T>
TgpuTextureView<T> | Infer<T>
Returns
Section titled “Returns”Defined in
Section titled “Defined in”packages/typegpu/src/core/root/rootTypes.ts:280
Call Signature
Section titled “Call Signature”with<
T>(accessor,value):WithBinding
Type Parameters
Section titled “Type Parameters”• T extends AnyWgslData
Parameters
Section titled “Parameters”accessor
Section titled “accessor”TgpuAccessor<T>
TgpuFn<() => T> | TgpuBufferUsage<T, BindableBufferUsage> | TgpuBufferShorthand<T> | Infer<T>
Returns
Section titled “Returns”Defined in
Section titled “Defined in”packages/typegpu/src/core/root/rootTypes.ts:284
withCompute()
Section titled “withCompute()”withCompute<
ComputeIn>(entryFn):WithCompute
Type Parameters
Section titled “Type Parameters”• ComputeIn extends IORecord<AnyComputeBuiltin>
Parameters
Section titled “Parameters”entryFn
Section titled “entryFn”TgpuComputeFn<ComputeIn>
Returns
Section titled “Returns”Defined in
Section titled “Defined in”packages/typegpu/src/core/root/rootTypes.ts:218
withVertex()
Section titled “withVertex()”withVertex<
VertexIn,VertexOut>(entryFn,attribs):WithVertex<VertexOut>
Type Parameters
Section titled “Type Parameters”• VertexIn extends VertexInConstrained
• VertexOut extends VertexOutConstrained
Parameters
Section titled “Parameters”entryFn
Section titled “entryFn”TgpuVertexFn<VertexIn, VertexOut>
attribs
Section titled “attribs”LayoutToAllowedAttribs<OmitBuiltins<VertexIn>>
Returns
Section titled “Returns”WithVertex<VertexOut>