render: impl Node for RenderGraph in prep for sub-graphs

This commit is contained in:
SeanOMik 2024-06-21 22:06:58 -04:00
parent f17bf40c77
commit f440f306be
Signed by: SeanOMik
GPG Key ID: FEC9E2FC15235964
2 changed files with 25 additions and 2 deletions

View File

@ -242,9 +242,9 @@ impl RenderGraph {
.as_compute_pipeline_descriptor() .as_compute_pipeline_descriptor()
.expect("got render pipeline descriptor in a compute pass"), .expect("got render pipeline descriptor in a compute pass"),
)), )),
NodeType::Presenter | NodeType::Node => { NodeType::Presenter | NodeType::Node | NodeType::Graph => {
panic!("Present or Node RenderGraph passes should not have a pipeline descriptor!"); panic!("Present or Node RenderGraph passes should not have a pipeline descriptor!");
} },
}; };
drop(desc); drop(desc);
@ -466,3 +466,23 @@ impl RenderGraph {
} }
} }
} }
impl Node for RenderGraph {
fn desc<'a, 'b>(&'a mut self, graph: &'b mut RenderGraph) -> NodeDesc {
// TODO: how would bind groups be shared between sub-graphs?
NodeDesc::new(NodeType::Graph, None, vec![])
}
fn prepare(&mut self, world: &mut World, _: &mut RenderGraphContext) {
self.prepare(world);
}
fn execute(
&mut self,
_: &mut RenderGraph,
_: &NodeDesc,
_: &mut RenderGraphContext,
) {
self.render();
}
}

View File

@ -18,6 +18,8 @@ pub enum NodeType {
Render, Render,
/// A node that presents render results to a render target. /// A node that presents render results to a render target.
Presenter, Presenter,
/// A node that represents a sub-graph.
Graph,
} }
impl NodeType { impl NodeType {
@ -28,6 +30,7 @@ impl NodeType {
NodeType::Compute => true, NodeType::Compute => true,
NodeType::Render => true, NodeType::Render => true,
NodeType::Presenter => false, NodeType::Presenter => false,
NodeType::Graph => false,
} }
} }
} }