Snapshot reads with no barrier: a draw reads its pass's texture through a snapshot where it can

Route (b), for timing: a draw that reads, at its own pixels, a texture its pass renders, and
writes the color it reads, now takes the snapshot route with no barrier before it too, in place
of the copy taken before the pass. It then reads what the draws before it wrote, the x86 Macs'
answer (docs/API.md's accepted differences), as with a barrier. Where the snapshot route does not
take the draw it reads the copy as before, and the fallback counts under no split reason
(Wanted::split_otherwise).

Verified: not yet; the 780M timing (backdrop_costs, base e303b7adbb against this) decides whether
it stays. Lane tests and docs for the no-barrier answer follow if it does.
This commit is contained in:
Anees Iqbal committed 2026-11-12 12:52:10 -08:00
1 parent a5254ead3a
commit 72c1dc128f
2 files changed
+42 -21

No files matched your search

+12 -8
View File
@@ -8396,9 +8396,9 @@ impl RenderLowering {
// The encoder's kept bind state, brought to the draw's (`live_bind.rs`), held for the
// draw: no draw of the encoder runs inside another past here.
// A draw that reads its pass's texture at its own pixels and writes nothing of it reads
// it in place, with a barrier or without; else, after a barrier inside its instance, it
// reads it through a snapshot where it can (`render/snapshot.rs`): asked of the plan,
// kept where the plan reads so, else `None` and the copy or the split.
// it in place; else it reads it through a snapshot where it can (`render/snapshot.rs`),
// each with a barrier before it or without: asked of the plan, kept where the plan reads
// so, else `None` and the copy or the split.
let mut snapshot = self
.in_place_wanted(&pipeline, &reformats, &routed.settings)
.or_else(|| self.snapshot_wanted(&pipeline, &reformats));
@@ -11683,12 +11683,15 @@ impl RenderLowering {
// the draw again (`LineRoute::refused`).
Err(refused) if settings.line.refused(&refused).is_some() => return Err(refused),
// A variant that reads through snapshots the compile or bind layer refuses: the
// draw takes the split (`render/snapshot.rs`).
// draw takes the split, or with no barrier before it the copy, counted under no
// split reason (`render/snapshot.rs`).
Err(Error::Unsupported(_) | Error::Bind(BindError::Unsupported(_)))
if snapshot.as_ref().is_some_and(|w| !w.in_place) =>
{
let reason = snapshot::SplitReason::VariantRefused;
snapshot::snapshot_fallback(self.core.device(), reason);
if snapshot.as_ref().is_some_and(|w| w.split_otherwise) {
let reason = snapshot::SplitReason::VariantRefused;
snapshot::snapshot_fallback(self.core.device(), reason);
}
*snapshot = None;
continue;
}
@@ -11721,10 +11724,11 @@ impl RenderLowering {
}
// A plan that does not read through every snapshot the draw asked for: the draw
// takes the split, settled again without them. One that does not read in place as the
// draw asked takes the copy, counted under no split reason.
// draw asked, or through snapshots with no barrier before it, takes the copy, counted
// under no split reason.
if let Some(wanted) = snapshot.as_ref() {
if let Err(reason) = self.snapshot_holds(&settled, wanted) {
if !wanted.in_place {
if wanted.split_otherwise {
snapshot::snapshot_fallback(self.core.device(), reason);
}
*snapshot = None;
@@ -214,6 +214,11 @@ pub(super) struct Wanted {
/// The draw reads the slots' textures in place, drawn once, with no snapshot (the module
/// docs' in place).
pub(super) in_place: bool,
/// Without its snapshots the draw takes the split: it follows a barrier inside its
/// instance, or behind the pass's loads (`loads_ordered`) reads a color the pass clears.
/// Else it reads the copy taken before the pass (`texture/attached_reads.rs`), and gives up
/// its snapshots counted under no split reason.
pub(super) split_otherwise: bool,
}
/// The form `plan` keeps fragment texture slot `slot`'s snapshot in
@@ -447,14 +452,14 @@ impl RenderLowering {
pipeline: &DrawingState,
reformats: &[Reformat],
) -> Option<Wanted> {
// After a barrier before the pass's first draw alone (`loads_ordered`), a slot reads
// through a snapshot only where its texture's color is one the pass clears: one the pass
// loads holds the texels from before the pass, which its copy holds
// (`texture/attached_reads.rs`).
// With a barrier before it or not: a draw that reads with none reads what the draws
// before it wrote, as with one (`docs/API.md`'s accepted differences), where it would
// read the copy taken before the pass, the texels from before it.
let ordered = self.current.barriers || self.barrier;
if self.replaying || self.rerouting || !(ordered || self.loads_ordered) {
if self.replaying || self.rerouting {
return None;
}
let mut split = ordered;
let base = pipeline.base();
let fragment = base
.stages
@@ -465,17 +470,17 @@ impl RenderLowering {
let Some(texture) = self.fragment.textures.get(&slot) else {
continue;
};
if !texture.attached_in(&self.layout) || !(ordered || texture.cleared_in(&self.layout))
{
if !texture.attached_in(&self.layout) {
continue;
}
split |= self.loads_ordered && texture.cleared_in(&self.layout);
let Some(index) = texture.snapshot_color(&self.layout) else {
// On a device without the path no image takes the feedback loop usage.
let reason = match self.core.device().shared().color_write_masks.is_none() {
true => SplitReason::DeviceLacks,
false => SplitReason::NotInPlace,
};
return self.snapshot_fallback(reason);
return self.fallback_if(split, reason);
};
wanted.slots.insert(slot);
wanted.feedback.0 |= 1 << index;
@@ -498,15 +503,16 @@ impl RenderLowering {
}
return None;
}
wanted.split_otherwise = split;
let device = self.core.device();
if device.shared().color_write_masks.is_none() {
return self.snapshot_fallback(SplitReason::DeviceLacks);
return self.fallback_if(split, SplitReason::DeviceLacks);
}
if self.visibility.active() {
return self.snapshot_fallback(SplitReason::VisibilityQuery);
return self.fallback_if(split, SplitReason::VisibilityQuery);
}
if let Err(reason) = self.in_instance(pipeline, reformats, &mut wanted) {
return self.snapshot_fallback(reason);
return self.fallback_if(split, reason);
}
Some(wanted)
}
@@ -683,10 +689,11 @@ impl RenderLowering {
Some((key, texture)) => self.readers.measure(self.core.device(), &texture, key)?,
None => None,
};
let split = wanted.split_otherwise;
let wanted = match (within, learned) {
(true, _) => Some(wanted),
(false, Some(_)) => self.snapshot_fallback(SplitReason::Coverage),
(false, None) => self.snapshot_fallback(SplitReason::Area),
(false, Some(_)) => self.fallback_if(split, SplitReason::Coverage),
(false, None) => self.fallback_if(split, SplitReason::Area),
};
Ok((wanted, query))
}
@@ -947,6 +954,16 @@ impl RenderLowering {
snapshot_fallback(self.core.device(), reason);
None
}
/// [`snapshot_fallback`](Self::snapshot_fallback) where the draw takes the split without
/// its snapshots (`split`, [`Wanted::split_otherwise`]); else `None` alone, the draw reading
/// the copy taken before the pass.
fn fallback_if(&self, split: bool, reason: SplitReason) -> Option<Wanted> {
match split {
true => self.snapshot_fallback(reason),
false => None,
}
}
}
/// Whether the split's copy of `texture` for a draw that reads it at its own pixels is cut to the