Documentation / scene / RenderGraph
Class: RenderGraph
Defined in: libs/scene/src/render/rendergraph/rendergraph.ts:42
Render Graph — declarative, configurable render pipeline.
Usage:
const graph = new RenderGraph();
let backbuffer = graph.importTexture('backbuffer');
let linearDepth: RGHandle;
graph.addPass('DepthPrepass', (builder) => {
linearDepth = builder.createTexture({ format: 'r32f', label: 'linearDepth' });
builder.setExecute(() => { ... });
});
graph.addPass('LightPass', (builder) => {
builder.read(linearDepth);
backbuffer = builder.write(backbuffer);
builder.setExecute(() => { ... });
});
const compiled = graph.compile([backbuffer]);
graph.execute(compiled);
graph.reset();Constructors
Constructor
new RenderGraph():
RenderGraph
Returns
RenderGraph
Methods
importTexture()
importTexture(
name):RGHandle
Defined in: libs/scene/src/render/rendergraph/rendergraph.ts:63
Import an external (persistent) texture into the graph.
Imported resources are not allocated or released by the graph. Typically used for the backbuffer or any texture that outlives a single frame.
Parameters
name
string
Debug label for the imported resource.
Returns
A handle referencing the imported resource.
addPass()
addPass<
T>(name,setup):T
Defined in: libs/scene/src/render/rendergraph/rendergraph.ts:81
Add a render pass to the graph.
The setup callback receives a RGPassBuilder to declare resource dependencies. Call builder.setExecute(fn) inside setup to provide the execution callback.
Type Parameters
T
T = void
Parameters
name
string
Debug label for the pass.
setup
(builder) => T
Setup callback that declares resources and sets the execute function.
Returns
T
compile()
compile(
outputs):CompiledRenderGraph
Defined in: libs/scene/src/render/rendergraph/rendergraph.ts:105
Compile the render graph.
Performs dead-pass culling, topological sorting, and resource lifetime analysis.
Parameters
outputs
RGHandle[]
Handles of resources that must be produced (graph sinks). If a resource was passed to RGPassBuilder.write, use the returned post-write handle here, not the original handle. Passes that do not contribute to these outputs (directly or transitively) are culled, unless marked as side-effect passes.
Returns
The compiled graph ready for execution.
execute()
execute(
compiled):void
Defined in: libs/scene/src/render/rendergraph/rendergraph.ts:125
Execute a compiled render graph (simple mode, no resource management).
For automatic resource allocation/release, use RenderGraphExecutor instead.
Parameters
compiled
The compiled graph from RenderGraph.compile.
Returns
void
reset()
reset():
void
Defined in: libs/scene/src/render/rendergraph/rendergraph.ts:163
Reset the graph for the next frame.
Clears all passes, transient resources, and compiled state. Imported resources are also cleared — re-import them each frame.
Returns
void