Skip to content

ZenFG TypeScript API / webgpu / root / FrameGraph

Class: FrameGraph

Defined in: packages/webgpu/src/frameGraph.ts:247

Beta

Long-lived device-bound runtime shared by independent recordings and compiled frames. It owns only the transient pool and GPU profiler.

Remarks

A FrameGraph may create many independent single-use recorders, but only one compiled frame may execute at a time. Imported textures and buffers always remain caller-owned. Call FrameGraph.destroy before releasing the device-bound runtime.

Example

ts
import { FrameGraph } from '@zenfg/webgpu';

const graph = new FrameGraph(device);
const frame = graph.beginFrame();
const buffer = frame.createBuffer({ label: 'scratch', size: 256 });
frame.clearBuffer({ operations: [{ target: buffer }], sideEffect: true });
frame.compile().execute();
graph.destroy();

Constructors

Constructor

new FrameGraph(device): FrameGraph

Defined in: packages/webgpu/src/frameGraph.ts:251

Beta

Creates a CPU-only runtime bound permanently to device.

Parameters

device

GPUDevice

Returns

FrameGraph

Methods

beginFrame()

beginFrame(): FrameGraphRecorder

Defined in: packages/webgpu/src/frameGraph.ts:266

Beta

Starts an independent single-use recording.

Returns

FrameGraphRecorder

Throws

If this runtime has been destroyed.


clearResourcePool()

clearResourcePool(): void

Defined in: packages/webgpu/src/frameGraph.ts:287

Beta

Destroys resources retained for reuse while preserving historical counters.

Returns

void

Throws

If this runtime has been destroyed or a compiled frame is currently executing.


destroy()

destroy(): void

Defined in: packages/webgpu/src/frameGraph.ts:300

Beta

Permanently releases runtime-owned resources and invalidates outstanding recorders and compiled frames. Imported resources remain caller-owned. Repeated calls after successful destruction are no-ops.

Returns

void

Throws

If a compiled frame is currently executing.


getResourcePoolStats()

getResourcePoolStats(): FrameGraphResourcePoolStats

Defined in: packages/webgpu/src/frameGraph.ts:276

Beta

Returns aggregate transient-pool counters and retained-byte estimates.

Returns

FrameGraphResourcePoolStats

Throws

If this runtime has been destroyed.

Open source / MIT licensed