Skip to content

WithBinding

createComputePipeline<ComputeIn>(descriptor): TgpuComputePipeline

ComputeIn extends IORecord<AnyComputeBuiltin>

Descriptor<ComputeIn>

TgpuComputePipeline

packages/typegpu/src/core/root/rootTypes.ts:253


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.

TArgs extends number[]

(…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.

TgpuGuardedComputePipeline<TArgs>

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 threads
fooPipeline.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 thread

packages/typegpu/src/core/root/rootTypes.ts:417


createRenderPipeline<TVertexIn, TAttribs, TVertexOut, TFragmentOut>(descriptor): TgpuRenderPipeline<NormalizeOutput<TFragmentOut>>

TVertexIn extends In = Record<string, any>

TAttribs extends object = LayoutToAllowedAttribs<TVertexIn>

TVertexOut = unknown

TFragmentOut = unknown

DescriptorBase & object

TgpuRenderPipeline<NormalizeOutput<TFragmentOut>>

packages/typegpu/src/core/root/rootTypes.ts:257

createRenderPipeline<TVertexIn, TAttribs, TVertexOut>(descriptor): TgpuRenderPipeline<Void>

TVertexIn extends In = Record<string, any>

TAttribs extends object = LayoutToAllowedAttribs<TVertexIn>

TVertexOut extends Out = Out

DescriptorBase & object

TgpuRenderPipeline<Void>

packages/typegpu/src/core/root/rootTypes.ts:286

createRenderPipeline<TVertexIn, TAttribs, TVertexOut, TFragmentOut>(descriptor): TgpuRenderPipeline<Void> | TgpuRenderPipeline<NormalizeOutput<TFragmentOut>>

TVertexIn extends In = Record<string, any>

TAttribs extends object = LayoutToAllowedAttribs<TVertexIn>

TVertexOut extends Out = Out

TFragmentOut = unknown

DescriptorBase & {attribs: TAttribs;fragment: TgpuFragmentFn<VertexOutToVarying<OmitBuiltins<TVertexOut>> & Record<string, AnyFragmentInputBuiltin>, Assume<TFragmentOut, Out>> | (input) => AutoFragmentOut<Assume<TFragmentOut, v4f | AnyAutoCustoms>>;targets: FragmentOutToTargets<NoInfer<TFragmentOut>>;vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, Out>> | (input) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>; } | {attribs: TAttribs;fragment: TgpuFragmentFn<VertexOutToVarying<OmitBuiltins<TVertexOut>> & Record<string, AnyFragmentInputBuiltin>, Record<string, never>> | (input) => undefined;targets: undefined;vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, Out>> | (input) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>; }

TgpuRenderPipeline<Void> | TgpuRenderPipeline<NormalizeOutput<TFragmentOut>>

packages/typegpu/src/core/root/rootTypes.ts:315


pipe(transform): WithBinding

(cfg) => Configurable

WithBinding

packages/typegpu/src/core/root/rootTypes.ts:429


with<T>(slot, value): WithBinding

T

TgpuSlot<T>

Eventual<T>

WithBinding

Withable.with

packages/typegpu/src/core/root/rootTypes.ts:197

with<T>(accessor, value): WithBinding

T extends BaseData

TgpuAccessor<T>

In<NoInfer<T>>

WithBinding

Withable.with

packages/typegpu/src/core/root/rootTypes.ts:198

with<T>(accessor, value): WithBinding

T extends BaseData

TgpuMutableAccessor<T>

In<NoInfer<T>>

WithBinding

Withable.with

packages/typegpu/src/core/root/rootTypes.ts:199


withCompute<ComputeIn>(entryFn): WithCompute

ComputeIn extends IORecord<AnyComputeBuiltin>

TgpuComputeFn<ComputeIn>

WithCompute

packages/typegpu/src/core/root/rootTypes.ts:249


withVertex<VertexIn, VertexOut>(entryFn, …args): WithVertex<VertexOut>

VertexIn extends In

VertexOut extends Out

TgpuVertexFn<VertexIn, VertexOut>

OptionalArgs<LayoutToAllowedAttribs<OmitBuiltins<VertexIn>>>

WithVertex<VertexOut>

packages/typegpu/src/core/root/rootTypes.ts:424