pub struct RenderGraph {
pub resource_table: ResourceTable,
/* private fields */
}Expand description
A declarative render graph: collection of passes (nodes) connected via resource dependencies (edges). Supports topological sorting, cycle detection, validation, conditional execution, and DOT export.
Fields§
§resource_table: ResourceTableResource table for handle bookkeeping.
Implementations§
Source§impl RenderGraph
impl RenderGraph
pub fn new(label: &str) -> Self
pub fn enable_feature(&mut self, feature: &str)
pub fn disable_feature(&mut self, feature: &str)
pub fn is_feature_enabled(&self, feature: &str) -> bool
pub fn set_callback(&mut self, name: &str, value: bool)
Sourcepub fn declare_resource(
&mut self,
descriptor: ResourceDescriptor,
) -> ResourceHandle
pub fn declare_resource( &mut self, descriptor: ResourceDescriptor, ) -> ResourceHandle
Declare a transient texture resource.
Sourcepub fn import_resource(
&mut self,
descriptor: ResourceDescriptor,
) -> ResourceHandle
pub fn import_resource( &mut self, descriptor: ResourceDescriptor, ) -> ResourceHandle
Declare an imported (externally managed) resource.
Sourcepub fn add_pass(&mut self, pass: RenderPass)
pub fn add_pass(&mut self, pass: RenderPass)
Add a render pass to the graph.
Sourcepub fn remove_pass(&mut self, name: &str) -> Option<RenderPass>
pub fn remove_pass(&mut self, name: &str) -> Option<RenderPass>
Remove a pass by name.
Sourcepub fn get_pass(&self, name: &str) -> Option<&RenderPass>
pub fn get_pass(&self, name: &str) -> Option<&RenderPass>
Get a pass by name.
Sourcepub fn get_pass_mut(&mut self, name: &str) -> Option<&mut RenderPass>
pub fn get_pass_mut(&mut self, name: &str) -> Option<&mut RenderPass>
Get a mutable pass by name.
Sourcepub fn pass_names(&self) -> &[String]
pub fn pass_names(&self) -> &[String]
All pass names in insertion order.
Sourcepub fn pass_count(&self) -> usize
pub fn pass_count(&self) -> usize
Number of passes.
Sourcepub fn resource_count(&self) -> usize
pub fn resource_count(&self) -> usize
Number of resource nodes.
Sourcepub fn build_edges(&mut self)
pub fn build_edges(&mut self)
Rebuild dependency edges from resource read/write declarations.
Sourcepub fn edges(&self) -> &[PassDependency]
pub fn edges(&self) -> &[PassDependency]
Get all edges.
Sourcepub fn detect_cycles(&mut self) -> Vec<Vec<String>>
pub fn detect_cycles(&mut self) -> Vec<Vec<String>>
Detect cycles in the dependency graph. Returns the set of passes involved in a cycle, or empty if acyclic.
Sourcepub fn topological_sort(&mut self) -> Result<Vec<String>, Vec<String>>
pub fn topological_sort(&mut self) -> Result<Vec<String>, Vec<String>>
Perform topological sort using Kahn’s algorithm.
Returns Err with cycle participants if a cycle is detected.
Sourcepub fn sorted(&mut self) -> Result<&[String], Vec<String>>
pub fn sorted(&mut self) -> Result<&[String], Vec<String>>
Get the sorted pass list (computes if dirty).
Sourcepub fn active_passes(&mut self) -> Result<Vec<String>, Vec<String>>
pub fn active_passes(&mut self) -> Result<Vec<String>, Vec<String>>
Filter sorted passes to only those whose conditions are satisfied.
Sourcepub fn validate(&mut self) -> ValidationResult
pub fn validate(&mut self) -> ValidationResult
Validate the graph: check for cycles, dangling resources, disconnected inputs, and other structural issues.
Sourcepub fn merge(&mut self, other: &RenderGraph, prefix: &str)
pub fn merge(&mut self, other: &RenderGraph, prefix: &str)
Merge another graph into this one. Passes and resources from other
are added. Conflicting names get a prefix.
Sourcepub fn export_dot(&mut self) -> String
pub fn export_dot(&mut self) -> String
Export the graph in Graphviz DOT format for debug visualization.
pub fn label(&self) -> &str
pub fn resource_node(&self, name: &str) -> Option<&ResourceNode>
pub fn all_passes(&self) -> impl Iterator<Item = &RenderPass>
pub fn all_resource_nodes(&self) -> impl Iterator<Item = &ResourceNode>
pub fn features(&self) -> &HashSet<String>
Sourcepub fn passes_by_tag(&self) -> HashMap<String, Vec<&RenderPass>>
pub fn passes_by_tag(&self) -> HashMap<String, Vec<&RenderPass>>
Returns passes grouped by tag.