Skip to content

TgpuRoot

Defined in: packages/typegpu/src/core/root/rootTypes.ts:810

[$internal]: object

Defined in: packages/typegpu/src/core/root/rootTypes.ts:811

logOptions: LogGeneratorOptions


~unstable: Pick<ExperimentalTgpuRoot, "beginRenderPass" | "beginRenderBundleEncoder" | "createComparisonSampler" | "createGuardedComputePipeline" | "createSampler" | "createTexture" | "flush" | "nameRegistrySetting" | "shaderGenerator" | "pipe" | "with" | "withCompute" | "withVertex">

Defined in: packages/typegpu/src/core/root/rootTypes.ts:1064


readonly device: GPUDevice

Defined in: packages/typegpu/src/core/root/rootTypes.ts:818

The GPU device associated with this root.

Unwrapper.device

get enabledFeatures(): ReadonlySet<GPUFeatureName>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:1055

Retrieves a read-only list of all enabled features of the GPU device.

ReadonlySet<GPUFeatureName>

A set of strings representing the enabled features.

configureContext(options): GPUCanvasContext

Defined in: packages/typegpu/src/core/root/rootTypes.ts:825

Creates and configures context for the provided canvas. Automatically sets the format to navigator.gpu.getPreferredCanvasFormat() if not provided.

ConfigureContextOptions

GPUCanvasContext

An error if no context could be obtained


createBindGroup<Entries>(layout, entries): TgpuBindGroup<Entries>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:1044

Creates a group of resources that can be bound to a shader based on a specified layout.

Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>

TgpuBindGroupLayout<Entries>

Layout describing the bind group to be created.

ExtractBindGroupInputFromLayout<Entries>

A record with values being the resources populating the bind group and keys being their associated names, matching the layout keys.

TgpuBindGroup<Entries>

Typed wrapper around a GPUBindGroup.

const fooLayout = tgpu.bindGroupLayout({
foo: { uniform: d.vec3f },
bar: { texture: 'float' },
});
const fooBuffer = ...;
const barTexture = ...;
const fooBindGroup = root.createBindGroup(fooLayout, {
foo: fooBuffer,
bar: barTexture,
});

createBuffer<TData>(typeSchema, initializer): TgpuBuffer<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:836

Allocates memory on the GPU, allows passing data between host and shader.

TData extends AnyData

ValidateBufferSchema<TData>

The type of data that this buffer will hold.

(buffer) => void

TgpuBuffer<TData>

Typed wrapper around a GPUBuffer.

createBuffer<TData>(typeSchema, initial?): TgpuBuffer<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:841

TData extends AnyData

ValidateBufferSchema<TData>

InferInput<NoInfer>

TgpuBuffer<TData>

createBuffer<TData>(typeSchema, initial?): TgpuBuffer<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:846

TData extends AnyData

ValidateBufferSchema<TData>

InferInput<NoInfer> | (buffer) => void

TgpuBuffer<TData>

createBuffer<TData>(typeSchema, gpuBuffer): TgpuBuffer<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:861

Allocates memory on the GPU, allows passing data between host and shader.

TData extends AnyData

ValidateBufferSchema<TData>

The type of data that this buffer will hold.

GPUBuffer

A vanilla WebGPU buffer.

TgpuBuffer<TData>

Typed wrapper around a GPUBuffer.


createComparisonSampler(props): TgpuFixedComparisonSampler

Defined in: packages/typegpu/src/core/root/rootTypes.ts:1002

WgslComparisonSamplerProps

TgpuFixedComparisonSampler


createComputePipeline<ComputeIn>(descriptor): TgpuComputePipeline

Defined in: packages/typegpu/src/core/root/rootTypes.ts:260

ComputeIn extends IORecord<AnyComputeBuiltin>

Descriptor<ComputeIn>

TgpuComputePipeline

WithBinding.createComputePipeline


createGuardedComputePipeline<TArgs>(callback): TgpuGuardedComputePipeline<TArgs>

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

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

WithBinding.createGuardedComputePipeline


createMutable<TData>(typeSchema, initializer): TgpuMutable<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:910

Allocates memory on the GPU, allows passing data between host and shader. Can be mutated in-place on the GPU. For a general-purpose buffer, use TgpuRoot.createBuffer.

TData extends AnyWgslData

ValidateStorageSchema<TData>

The type of data that this buffer will hold.

(buffer) => void

TgpuMutable<TData>

createMutable<TData>(typeSchema, initial?): TgpuMutable<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:914

TData extends AnyWgslData

ValidateStorageSchema<TData>

InferInput<NoInfer>

TgpuMutable<TData>

createMutable<TData>(typeSchema, initial?): TgpuMutable<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:919

TData extends AnyWgslData

ValidateStorageSchema<TData>

InferInput<NoInfer> | (buffer) => void

TgpuMutable<TData>

createMutable<TData>(typeSchema, gpuBuffer): TgpuMutable<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:933

Allocates memory on the GPU, allows passing data between host and shader. Can be mutated in-place on the GPU. For a general-purpose buffer, use TgpuRoot.createBuffer.

TData extends AnyWgslData

ValidateStorageSchema<TData>

The type of data that this buffer will hold.

GPUBuffer

A vanilla WebGPU buffer.

TgpuMutable<TData>


createQuerySet<T>(type, count, rawQuerySet?): TgpuQuerySet<T>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:1014

Creates a query set for collecting timestamps or occlusion queries.

T extends GPUQueryType

T

The type of queries to collect (‘occlusion’ or ‘timestamp’).

number

The number of queries in the set.

GPUQuerySet

An optional pre-existing GPUQuerySet to use instead of creating a new one.

TgpuQuerySet<T>

Typed wrapper around a GPUQuerySet.


createReadonly<TData>(typeSchema, initializer): TgpuReadonly<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:946

Allocates memory on the GPU, allows passing data between host and shader. Read-only on the GPU, optimized for large data. For a general-purpose buffer, use TgpuRoot.createBuffer.

TData extends AnyWgslData

ValidateStorageSchema<TData>

The type of data that this buffer will hold.

(buffer) => void

TgpuReadonly<TData>

createReadonly<TData>(typeSchema, initial?): TgpuReadonly<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:950

TData extends AnyWgslData

ValidateStorageSchema<TData>

InferInput<NoInfer>

TgpuReadonly<TData>

createReadonly<TData>(typeSchema, initial?): TgpuReadonly<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:955

TData extends AnyWgslData

ValidateStorageSchema<TData>

InferInput<NoInfer> | (buffer) => void

TgpuReadonly<TData>

createReadonly<TData>(typeSchema, gpuBuffer): TgpuReadonly<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:969

Allocates memory on the GPU, allows passing data between host and shader. Read-only on the GPU, optimized for large data. For a general-purpose buffer, use TgpuRoot.createBuffer.

TData extends AnyWgslData

ValidateStorageSchema<TData>

The type of data that this buffer will hold.

GPUBuffer

A vanilla WebGPU buffer.

TgpuReadonly<TData>


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

Defined in: packages/typegpu/src/core/root/rootTypes.ts:264

TVertexIn extends In = Record<string, any>

TAttribs extends object = LayoutToAllowedAttribs<TVertexIn>

TVertexOut = unknown

TFragmentOut = unknown

DescriptorBase & object

TgpuRenderPipeline<NormalizeOutput<TFragmentOut>>

WithBinding.createRenderPipeline

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

Defined in: packages/typegpu/src/core/root/rootTypes.ts:293

TVertexIn extends In = Record<string, any>

TAttribs extends object = LayoutToAllowedAttribs<TVertexIn>

TVertexOut extends Out = Out

DescriptorBase & object

TgpuRenderPipeline<Void>

WithBinding.createRenderPipeline

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

Defined in: packages/typegpu/src/core/root/rootTypes.ts:322

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>; 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>>

WithBinding.createRenderPipeline


createSampler(props): TgpuFixedSampler

Defined in: packages/typegpu/src/core/root/rootTypes.ts:1000

WgslSamplerProps

TgpuFixedSampler


createTexture<TWidth, THeight, TDepth, TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>(props): TgpuTexture<{ [K in “size” | “dimension” | “format” | “mipLevelCount” | “sampleCount” | “viewFormats”]: ({ format: TFormat; size: Mutable<TSize> } & OmitProps<{ dimension: GPUTextureDimension extends TDimension ? undefined : TDimension extends “2d” ? undefined : TDimension; mipLevelCount: number extends TMipLevelCount ? undefined : TMipLevelCount extends 1 ? undefined : TMipLevelCount; sampleCount: number extends TSampleCount ? undefined : TSampleCount extends 1 ? undefined : TSampleCount; viewFormats: GPUTextureFormat[] extends TViewFormats ? undefined : TViewFormats extends never[] ? undefined : TViewFormats extends SrgbVariantOrSelf<TFormat> ? TViewFormats : never }, undefined>)[K] }>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:974

TWidth extends number

THeight extends number

TDepth extends number

TSize extends readonly [TWidth] | readonly [TWidth, THeight] | readonly [TWidth, THeight, TDepth]

TFormat extends GPUTextureFormat

TMipLevelCount extends number

TSampleCount extends number

TViewFormats extends GPUTextureFormat[]

TDimension extends GPUTextureDimension

CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>

TgpuTexture<{ [K in “size” | “dimension” | “format” | “mipLevelCount” | “sampleCount” | “viewFormats”]: ({ format: TFormat; size: Mutable<TSize> } & OmitProps<{ dimension: GPUTextureDimension extends TDimension ? undefined : TDimension extends “2d” ? undefined : TDimension; mipLevelCount: number extends TMipLevelCount ? undefined : TMipLevelCount extends 1 ? undefined : TMipLevelCount; sampleCount: number extends TSampleCount ? undefined : TSampleCount extends 1 ? undefined : TSampleCount; viewFormats: GPUTextureFormat[] extends TViewFormats ? undefined : TViewFormats extends never[] ? undefined : TViewFormats extends SrgbVariantOrSelf<TFormat> ? TViewFormats : never }, undefined>)[K] }>


createUniform<TData>(typeSchema, initializer): TgpuUniform<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:874

Allocates memory on the GPU, allows passing data between host and shader. Read-only on the GPU, optimized for small data. For a general-purpose buffer, use TgpuRoot.createBuffer.

TData extends AnyWgslData

ValidateUniformSchema<TData>

The type of data that this buffer will hold.

(buffer) => void

TgpuUniform<TData>

createUniform<TData>(typeSchema, initial?): TgpuUniform<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:878

TData extends AnyWgslData

ValidateUniformSchema<TData>

InferInput<NoInfer>

TgpuUniform<TData>

createUniform<TData>(typeSchema, initial?): TgpuUniform<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:883

TData extends AnyWgslData

ValidateUniformSchema<TData>

InferInput<NoInfer> | (buffer) => void

TgpuUniform<TData>

createUniform<TData>(typeSchema, gpuBuffer): TgpuUniform<TData>

Defined in: packages/typegpu/src/core/root/rootTypes.ts:897

Allocates memory on the GPU, allows passing data between host and shader. Read-only on the GPU, optimized for small data. For a general-purpose buffer, use TgpuRoot.createBuffer.

TData extends AnyWgslData

ValidateUniformSchema<TData>

The type of data that this buffer will hold.

GPUBuffer

A vanilla WebGPU buffer.

TgpuUniform<TData>


destroy(): void

Defined in: packages/typegpu/src/core/root/rootTypes.ts:1062

Destroys all underlying resources (i.e. buffers…) created through this root object. If the object is created via tgpu.init instead of tgpu.initFromDevice, then the inner GPU device is destroyed as well.

void


pipe(transform): WithBinding

Defined in: packages/typegpu/src/core/root/rootTypes.ts:436

(cfg) => Configurable

WithBinding

WithBinding.pipe


unwrap(resource): GPUComputePipeline

Defined in: packages/typegpu/src/unwrapper.ts:13

TgpuComputePipeline

GPUComputePipeline

Unwrapper.unwrap

unwrap(resource): GPURenderPipeline

Defined in: packages/typegpu/src/unwrapper.ts:14

TgpuRenderPipeline

GPURenderPipeline

Unwrapper.unwrap

unwrap(resource): GPUBindGroupLayout

Defined in: packages/typegpu/src/unwrapper.ts:15

TgpuBindGroupLayout

GPUBindGroupLayout

Unwrapper.unwrap

unwrap(resource): GPUBindGroup

Defined in: packages/typegpu/src/unwrapper.ts:16

TgpuBindGroup

GPUBindGroup

Unwrapper.unwrap

unwrap(resource): GPUBuffer

Defined in: packages/typegpu/src/unwrapper.ts:17

TgpuBuffer<BaseData>

GPUBuffer

Unwrapper.unwrap

unwrap(resource): GPUTextureView

Defined in: packages/typegpu/src/unwrapper.ts:18

TgpuTextureView

GPUTextureView

Unwrapper.unwrap

unwrap(resource): GPUVertexBufferLayout

Defined in: packages/typegpu/src/unwrapper.ts:19

TgpuVertexLayout

GPUVertexBufferLayout

Unwrapper.unwrap

unwrap(resource): GPUSampler

Defined in: packages/typegpu/src/unwrapper.ts:20

TgpuSampler

GPUSampler

Unwrapper.unwrap

unwrap(resource): GPUSampler

Defined in: packages/typegpu/src/unwrapper.ts:21

TgpuComparisonSampler

GPUSampler

Unwrapper.unwrap

unwrap(resource): GPUQuerySet

Defined in: packages/typegpu/src/unwrapper.ts:22

TgpuQuerySet<GPUQueryType>

GPUQuerySet

Unwrapper.unwrap

unwrap(resource): GPUTexture

Defined in: packages/typegpu/src/unwrapper.ts:23

TgpuTexture

GPUTexture

Unwrapper.unwrap


with<T>(slot, value): WithBinding

Defined in: packages/typegpu/src/core/root/rootTypes.ts:204

T

TgpuSlot<T>

Eventual<T>

WithBinding

WithBinding.with

with<T>(accessor, value): WithBinding

Defined in: packages/typegpu/src/core/root/rootTypes.ts:205

T extends BaseData

TgpuAccessor<T>

In<NoInfer>

WithBinding

WithBinding.with

with<T>(accessor, value): WithBinding

Defined in: packages/typegpu/src/core/root/rootTypes.ts:206

T extends BaseData

TgpuMutableAccessor<T>

In<NoInfer>

WithBinding

WithBinding.with


withCompute<ComputeIn>(entryFn): WithCompute

Defined in: packages/typegpu/src/core/root/rootTypes.ts:256

ComputeIn extends IORecord<AnyComputeBuiltin>

TgpuComputeFn<ComputeIn>

WithCompute

WithBinding.withCompute


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

Defined in: packages/typegpu/src/core/root/rootTypes.ts:431

VertexIn extends In

VertexOut extends Out

TgpuVertexFn<VertexIn, VertexOut>

OptionalArgs<LayoutToAllowedAttribs<OmitBuiltins<VertexIn>>>

WithVertex<VertexOut>

WithBinding.withVertex