Skip to content

ZenFG TypeScript API / webgpu / snapshot / createFrameGraphSnapshot

Function: createFrameGraphSnapshot() ​

createFrameGraphSnapshot(options): FrameGraphSnapshotV1

Defined in: packages/webgpu/src/snapshot.ts:151

Creates an independent canonical Snapshot 1.2 value from one executed frame.

Parameters ​

options ​

CreateFrameGraphSnapshotOptions

Returns ​

FrameGraphSnapshotV1

Remarks ​

The conversion preserves retained and culled nodes, normalized accesses and dependencies, execution segments, allocation planning, GPU timing availability, and resource-pool counters. The returned object is a deep JSON clone and does not retain references to the supplied reports.

Throws ​

FrameGraphSnapshotValidationError if the projected draft does not satisfy Snapshot 1.2, or if supplied timing nodes are not an ordered subset of the retained execution sequence. Also throws if a compilation resource contains WebGPU usage bits that Snapshot 1.2 cannot represent.

Example ​

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

const graph = new FrameGraph(device);
const recorder = graph.beginFrame();
const scratch = recorder.createBuffer({ size: 256 });
recorder.clearBuffer({
  operations: [{ target: scratch }],
  sideEffect: true,
});
const compiled = recorder.compile({ report: true });
const timing = compiled.executeWithTiming({ frameIndex: 7, timing: 'both' });
const resourcePool = graph.getResourcePoolStats();
const gpuTiming = await timing.gpu;
const snapshot = createFrameGraphSnapshot({
  frameIndex: timing.frameIndex, cpuTiming: timing.cpu,
  compilation: compiled.compilationReport,
  gpuTiming,
  resourcePool,
});

Open source / MIT licensed