2020-04-24 00:24:41 +00:00
|
|
|
use super::NodeId;
|
|
|
|
|
2021-12-14 03:58:23 +00:00
|
|
|
/// An edge, which connects two [`Nodes`](super::Node) in
|
|
|
|
/// a [`RenderGraph`](crate::render_graph::RenderGraph).
|
|
|
|
///
|
|
|
|
/// They are used to describe the ordering (which node has to run first)
|
|
|
|
/// and may be of two kinds: [`NodeEdge`](Self::NodeEdge) and [`SlotEdge`](Self::SlotEdge).
|
|
|
|
///
|
2022-01-09 11:09:46 +00:00
|
|
|
/// Edges are added via the `render_graph::add_node_edge(output_node, input_node)` and the
|
|
|
|
/// `render_graph::add_slot_edge(output_node, output_slot, input_node, input_slot)` methods.
|
2021-12-14 03:58:23 +00:00
|
|
|
///
|
|
|
|
/// The former simply states that the `output_node` has to be run before the `input_node`,
|
|
|
|
/// while the later connects an output slot of the `output_node`
|
|
|
|
/// with an input slot of the `input_node` to pass additional data along.
|
|
|
|
/// For more information see [`SlotType`](super::SlotType).
|
2020-04-24 00:24:41 +00:00
|
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
|
|
pub enum Edge {
|
2021-12-14 03:58:23 +00:00
|
|
|
/// An edge describing to ordering of both nodes (`output_node` before `input_node`)
|
|
|
|
/// and connecting the output slot at the `output_index` of the output_node
|
|
|
|
/// with the slot at the `input_index` of the `input_node`.
|
2020-04-24 00:24:41 +00:00
|
|
|
SlotEdge {
|
|
|
|
input_node: NodeId,
|
|
|
|
input_index: usize,
|
|
|
|
output_node: NodeId,
|
|
|
|
output_index: usize,
|
|
|
|
},
|
2021-12-14 03:58:23 +00:00
|
|
|
/// An edge describing to ordering of both nodes (`output_node` before `input_node`).
|
2020-04-24 00:24:41 +00:00
|
|
|
NodeEdge {
|
|
|
|
input_node: NodeId,
|
|
|
|
output_node: NodeId,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Edge {
|
2022-01-09 11:09:46 +00:00
|
|
|
/// Returns the id of the `input_node`.
|
2020-04-24 00:24:41 +00:00
|
|
|
pub fn get_input_node(&self) -> NodeId {
|
|
|
|
match self {
|
2022-05-31 01:38:07 +00:00
|
|
|
Edge::SlotEdge { input_node, .. } | Edge::NodeEdge { input_node, .. } => *input_node,
|
2020-04-24 00:24:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-09 11:09:46 +00:00
|
|
|
/// Returns the id of the `output_node`.
|
2020-04-24 00:24:41 +00:00
|
|
|
pub fn get_output_node(&self) -> NodeId {
|
|
|
|
match self {
|
2022-05-31 01:38:07 +00:00
|
|
|
Edge::SlotEdge { output_node, .. } | Edge::NodeEdge { output_node, .. } => *output_node,
|
2020-04-24 00:24:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-03-21 23:58:37 +00:00
|
|
|
|
|
|
|
#[derive(PartialEq, Eq)]
|
|
|
|
pub enum EdgeExistence {
|
|
|
|
Exists,
|
|
|
|
DoesNotExist,
|
|
|
|
}
|