Render Graph Reference
RenderGraph
The compiled frame graph. Obtained from RenderGraphBuilder::build() and then compiled against a RenderTarget.
cpp
class RenderGraph {
public:
void compile(Ref<RenderTarget> target);
void execute(double dt);
void cleanup();
void export_graph(const RenderGraphExporter& exporter,
const std::string& filename) const;
};| Method | Description |
|---|---|
compile(target) | Runs the full compilation pipeline (lifetime, sort, cull, alias, allocate, setup) |
execute(dt) | Calls begin → execute → end on all active, non-culled passes |
cleanup() | Calls cleanup() on all passes and frees transient resources |
export_graph(exporter, filename) | Serializes the graph to a file using the given exporter |
RenderGraphBuilder
The builder accumulates resource descriptors and pass declarations, then assembles a RenderGraph.
cpp
class RenderGraphBuilder {
public:
// Transient resource declarations
uint32_t declare_texture_2d(const std::string& name,
uint32_t width, uint32_t height,
FramebufferTextureFormat format = RGBA8,
uint32_t mip_levels = 1,
uint32_t sample_count = 1);
uint32_t declare_framebuffer(const std::string& name,
uint32_t width, uint32_t height,
FramebufferTextureFormat format = RGBA8,
uint32_t sample_count = 1,
RenderGraphResourceLifetime lifetime = Transient);
uint32_t declare_storage_buffer(const std::string& name, uint32_t size,
RenderGraphResourceLifetime lifetime = Transient);
template <typename T>
uint32_t declare_logical_buffer(const std::string& name);
// Persistent (externally owned) resource imports
uint32_t import_persistent_framebuffer(const std::string& name,
Framebuffer* framebuffer);
uint32_t import_persistent_texture(const std::string& name,
ResourceHandle handle);
// Pass registration - returns a PassBuilder for fluent resource binding
PassBuilder add_pass(Scope<RenderPass> pass,
RenderGraphPassType type = Graphics);
Scope<RenderGraph> build();
};PassBuilder
Returned by RenderGraphBuilder::add_pass(). Declares which resources the pass accesses.
cpp
class PassBuilder {
public:
PassBuilder& read(uint32_t resource_index);
PassBuilder& write(uint32_t resource_index);
PassBuilder& read_write(uint32_t resource_index);
RenderGraphBuilder* end(); // returns to the builder
};RenderGraphPass
Wraps a RenderPass with resource access metadata and execution state.
cpp
class RenderGraphPass {
public:
bool is_enabled() const;
bool is_culled() const;
std::string get_name() const;
int get_priority() const;
RenderGraphPassType get_type() const;
void read(uint32_t resource_index);
void write(uint32_t resource_index);
void read_write(uint32_t resource_index);
};Pass Types
cpp
enum class RenderGraphPassType { Graphics, Compute, Transfer };Resource Access Modes
cpp
enum class RenderGraphResourceAccessMode { Read, Write, ReadWrite };RenderGraphResource
Describes a single resource and tracks its lifetime within the graph.
cpp
struct RenderGraphResource {
RenderGraphResourceDescriptor desc;
int32_t first_write_pass = -1;
int32_t last_read_pass = -1;
bool is_written = false;
bool is_read = false;
int32_t alias_group = -1; // -1 means not aliased
bool is_transient() const;
bool is_persistent() const;
// Content accessors
Framebuffer* get_framebuffer() const;
StorageBuffer* get_storage_buffer() const;
ResourceHandle get_texture_handle() const;
void* get_logical_buffer() const;
};Resource Types
cpp
enum class RenderGraphResourceType {
Texture2D,
Texture3D,
Framebuffer,
StorageBuffer,
DepthStencil,
LogicalBuffer
};Resource Lifetimes
cpp
enum class RenderGraphResourceLifetime { Transient, Persistent };RenderPass
The abstract base for all passes.
cpp
class RenderPass {
public:
virtual void setup(Ref<RenderTarget> target,
const std::vector<const RenderGraphResource*>& resources) = 0;
virtual void begin(double dt) = 0;
virtual void execute(double dt) = 0;
virtual void end(double dt) = 0;
virtual void cleanup() = 0;
virtual std::string name() const = 0;
virtual bool is_enabled() const;
virtual void set_enabled(bool enabled);
virtual int priority() const;
virtual void set_priority(int priority);
virtual std::vector<RenderPass*> dependencies() const;
virtual void add_dependency(RenderPass* pass);
virtual void clear_dependencies();
};Graph Exporters
Three exporters are provided for visualizing the compiled graph:
| Class | Format | Use |
|---|---|---|
MermaidExporter | Mermaid diagram | Documentation, VitePress |
GraphvizExporter | DOT format | Graphviz rendering |
AsciiExporter | Plain text | Terminal output |
cpp
graph->export_graph(MermaidExporter{}, "frame_graph.md");
graph->export_graph(GraphvizExporter{}, "frame_graph.dot");
graph->export_graph(AsciiExporter{}, "frame_graph.txt");