transition imported resources at the beginning of rendergraph
This commit is contained in:
parent
5a1ed9340e
commit
3deca28391
|
@ -493,6 +493,7 @@ impl RenderGraph {
|
||||||
|
|
||||||
let mut topological_map = Vec::new();
|
let mut topological_map = Vec::new();
|
||||||
let mut top_dag = dag.clone();
|
let mut top_dag = dag.clone();
|
||||||
|
let mut root_barriers = BTreeMap::new();
|
||||||
|
|
||||||
// create topological map of DAG from sink to source
|
// create topological map of DAG from sink to source
|
||||||
loop {
|
loop {
|
||||||
|
@ -514,7 +515,13 @@ impl RenderGraph {
|
||||||
.for_each(|edge| {
|
.for_each(|edge| {
|
||||||
let (rid, (before, after)) = edge.weight();
|
let (rid, (before, after)) = edge.weight();
|
||||||
|
|
||||||
barriers
|
// initial access is transitioned at the beginning
|
||||||
|
// this affects imported resources only.
|
||||||
|
if edge.source() == root {
|
||||||
|
&mut root_barriers
|
||||||
|
} else {
|
||||||
|
&mut barriers
|
||||||
|
}
|
||||||
.entry(*rid)
|
.entry(*rid)
|
||||||
.and_modify(|(from, to)| {
|
.and_modify(|(from, to)| {
|
||||||
*from = *from | *before;
|
*from = *from | *before;
|
||||||
|
@ -525,9 +532,23 @@ impl RenderGraph {
|
||||||
top_dag.remove_node(sink);
|
top_dag.remove_node(sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let passes = passes
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|pass| {
|
||||||
|
if let PassNode::Pass(i) = pass {
|
||||||
|
Some(i)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map(|i| core::mem::take(&mut self.pass_descs[i]))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
topological_map.push((passes, barriers));
|
topological_map.push((passes, barriers));
|
||||||
}
|
}
|
||||||
|
topological_map.push((vec![], root_barriers));
|
||||||
|
|
||||||
|
//tracing::debug!("mapping: {topological_map:#?}");
|
||||||
// I don't think this can currently happen with the way passes are added.
|
// I don't think this can currently happen with the way passes are added.
|
||||||
top_dag.remove_node(root);
|
top_dag.remove_node(root);
|
||||||
if top_dag.node_count() > 0 {
|
if top_dag.node_count() > 0 {
|
||||||
|
@ -546,25 +567,11 @@ impl RenderGraph {
|
||||||
|
|
||||||
let resources = &self.resources;
|
let resources = &self.resources;
|
||||||
let cmds = topological_map
|
let cmds = topological_map
|
||||||
.iter()
|
|
||||||
.rev()
|
|
||||||
.map(|(set, accesses)| {
|
|
||||||
let pool = pool.clone();
|
|
||||||
let device = device.clone();
|
|
||||||
let passes = set
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|pass| {
|
.rev()
|
||||||
if let &PassNode::Pass(i) = pass {
|
.map({
|
||||||
Some(i)
|
|(passes, accesses)| {
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.map(|i| core::mem::take(&mut self.pass_descs[i]))
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
let cmd = pool.alloc()?;
|
let cmd = pool.alloc()?;
|
||||||
|
|
||||||
// transitions
|
// transitions
|
||||||
for (&id, &(from, to)) in accesses.iter() {
|
for (&id, &(from, to)) in accesses.iter() {
|
||||||
Self::transition_resource(
|
Self::transition_resource(
|
||||||
|
@ -577,7 +584,7 @@ impl RenderGraph {
|
||||||
}
|
}
|
||||||
|
|
||||||
let ctx = RenderContext {
|
let ctx = RenderContext {
|
||||||
device,
|
device: device.clone(),
|
||||||
cmd,
|
cmd,
|
||||||
resources,
|
resources,
|
||||||
};
|
};
|
||||||
|
@ -588,6 +595,7 @@ impl RenderGraph {
|
||||||
|
|
||||||
ctx.cmd.end()?;
|
ctx.cmd.end()?;
|
||||||
crate::Result::Ok(ctx.cmd)
|
crate::Result::Ok(ctx.cmd)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.collect::<crate::Result<Vec<_>>>()?;
|
.collect::<crate::Result<Vec<_>>>()?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue