fix: check for layout transition is always necessary, layout in eguiprepass

This commit is contained in:
Janis 2025-01-10 13:28:43 +01:00
parent dbc4294c09
commit d623b8fc46
2 changed files with 28 additions and 15 deletions

View file

@ -279,13 +279,24 @@ pub fn egui_pre_pass(
},
None,
);
let to_barrier = image_barrier(
texture.handle(),
texture.format(),
Access {
stage: vk::PipelineStageFlags2::NONE,
mask: vk::AccessFlags2::empty(),
layout: vk::ImageLayout::GENERAL,
// TODO: this is somewhat sub-optimal, but I think
// perfectly legal to not-care about the layout of a
// texture? In this case, the entire texture is
// overwritten, so the layout doesn't matter, and else
// the layout will be `GENERAL` because the texture was
// previously written to.
layout: if alias.size() == texture.size() {
vk::ImageLayout::UNDEFINED
} else {
vk::ImageLayout::GENERAL
},
},
Access {
stage: vk::PipelineStageFlags2::TRANSFER,

View file

@ -918,6 +918,22 @@ mod graph_resolver {
let write = self.get_writes_for_rid_pass(rid, pass);
if let Some(write) = write {
tracing::trace!("write: {:?}", write);
if let Some(last) = last_ref.as_ref()
&& last.access().layout != write.layout
{
let before = last.access();
edges.push(Edge {
from: last.node(),
to: pass,
rid,
barrier: Barrier::LayoutTransition {
src: (before.stage, before.layout),
dst: (write.stage, write.layout),
},
});
}
match last_ref.as_ref() {
Some(Ref::Read(node, before)) => {
// execution barrier to ward against write-after-read
@ -932,20 +948,6 @@ mod graph_resolver {
},
});
}
Some(Ref::Write(node, before)) => {
// check for layout transition here
if before.layout != write.layout {
edges.push(Edge {
from: *node,
to: pass,
rid,
barrier: Barrier::LayoutTransition {
src: (before.stage, before.layout),
dst: (write.stage, write.layout),
},
});
}
}
_ => {}
}
}