ZenFG TypeScript API / webgpu / root / FrameGraph
Class: FrameGraph
Defined in: packages/webgpu/src/frameGraph.ts:250
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
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:254
Beta
Creates a FrameGraph runtime bound permanently to device.
Parameters
device
GPUDevice
Returns
FrameGraph
Methods
beginFrame()
beginFrame():
FrameGraphRecorder
Defined in: packages/webgpu/src/frameGraph.ts:272
Beta
Starts an independent single-use recording.
Returns
Throws
If this runtime has been destroyed.
clearResourcePool()
clearResourcePool(
scope?):void
Defined in: packages/webgpu/src/frameGraph.ts:318
Beta
Destroys retained resources in the specified scope. Omitted/undefined means every domain. Clearing does not invalidate the scope or compiled frames: executing an old plan repopulates its cache. To clear only the default domain, use evictResourcePool(info => info.scope === undefined).
Parameters
scope?
Returns
void
createResourcePoolScope()
createResourcePoolScope():
ResourcePoolScope
Defined in: packages/webgpu/src/frameGraph.ts:288
Beta
Creates an opaque partition identity that owns no GPU resources.
Returns
destroy()
destroy():
void
Defined in: packages/webgpu/src/frameGraph.ts:332
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.
evictResourcePool()
evictResourcePool(
predicate):ResourcePoolEvictionReport
Defined in: packages/webgpu/src/frameGraph.ts:302
Beta
Calls a synchronous boolean predicate once for each retained physical instance, in unspecified order. Selection finishes before any pool mutation. Throwing or returning an async/non-boolean value leaves the pool unchanged. Callback side effects outside the pool are not rolled back. During maintenance, same-runtime execution, eviction, clearing and destruction are rejected.
Parameters
predicate
(info) => boolean
Returns
getResourcePoolStats()
getResourcePoolStats():
FrameGraphResourcePoolStats
Defined in: packages/webgpu/src/frameGraph.ts:282
Beta
Returns aggregate transient-pool counters and retained-byte estimates.
Returns
Throws
If this runtime has been destroyed.