Writes through views picked from the heap come back (VICTORY_PICKED_WRITES)
Off by default. A shader that stores through a view it picks by an index (37 compute programs of the title, 82a2ad6d07417d36 one of them) writes buffers nobody declared. With a submission that has one, the buffers found written that way are declared and landed as any; of the other buffers the heap shows unordered views of 32 MB a frame are compared on the card, in turn, and one that changed undeclared is found. Found late is not landed late. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
c11b92e9ac
commit
424013a59c
8 files changed
+523
-11
No files matched your search
@@ -1670,6 +1670,22 @@ struct CardRange {
|
||||
at: u32,
|
||||
/// Whether the card compares it; else every piece is fetched.
|
||||
compared: bool,
|
||||
/// Looked at by `crate::picked`, and not declared: what is found changed
|
||||
/// there was written through a view nobody declared. Not landed.
|
||||
picked: bool,
|
||||
}
|
||||
|
||||
impl CardPlan {
|
||||
/// `crate::picked` is told where what it looked at changed, by the
|
||||
/// compare's results.
|
||||
fn picked_found(&self, differs: &[u32]) {
|
||||
for r in self.ranges.iter().filter(|r| r.picked) {
|
||||
let changed = (0..r.span.pieces).find(|p| differs.get((r.at + p) as usize).is_some_and(|&d| torn::flagged(d)));
|
||||
if let Some(p) = changed {
|
||||
crate::picked::found(&r.shadow, r.shadow.card_piece(&r.span, p).0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What a submission does for copies in the card's memory.
|
||||
@@ -2946,6 +2962,7 @@ fn late_line(frames: f64) {
|
||||
}
|
||||
crate::land::log(frames);
|
||||
card_steps::log(frames);
|
||||
crate::picked::log(frames);
|
||||
#[cfg(feature = "diagnostics")]
|
||||
log_blame(frames);
|
||||
if late_exact() {
|
||||
@@ -3463,7 +3480,9 @@ impl Host {
|
||||
/// `flown`: the submission is sent ahead with [`relay`]. Its compare
|
||||
/// then stores the hashes it makes (see [`flagged_pieces`] and
|
||||
/// `relay`).
|
||||
fn card_before(&self, runs: &[&HostList], flown: bool) -> Option<CardPlan> {
|
||||
/// `picked`: ranges that may be written too, and ranges to look at
|
||||
/// (`crate::picked`).
|
||||
fn card_before(&self, runs: &[&HostList], picked: &crate::picked::Ranges, flown: bool) -> Option<CardPlan> {
|
||||
use std::sync::Arc;
|
||||
if !crate::shadow::cards() {
|
||||
return None;
|
||||
@@ -3487,6 +3506,10 @@ impl Host {
|
||||
}
|
||||
}
|
||||
}
|
||||
let declared = crate::picked::with(declared, &picked.written);
|
||||
// (Of a copy with a declared range here, that says it.)
|
||||
let looked: Vec<&crate::picked::Range> =
|
||||
picked.looked.iter().filter(|l| !declared.iter().any(|(s, _)| Arc::ptr_eq(s, &l.0))).collect();
|
||||
// With the relay: the order of the queue is held from here until
|
||||
// what is taken is on the queue, and the taking is numbered.
|
||||
let mut order = relay().then(|| QUEUE_ORDER.lock().unwrap_or_else(|e| e.into_inner()));
|
||||
@@ -3498,7 +3521,7 @@ impl Host {
|
||||
None => 0,
|
||||
};
|
||||
let mut dirty = crate::shadow::card_dirty(sent_as);
|
||||
if declared.is_empty() && dirty.is_empty() {
|
||||
if declared.is_empty() && dirty.is_empty() && looked.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let mut work = CARD_WORK.lock().unwrap_or_else(|e| e.into_inner());
|
||||
@@ -3506,7 +3529,7 @@ impl Host {
|
||||
// A copy whose shader writes are declared for the first time gets
|
||||
// its bytes from before, whole.
|
||||
let mut whole: Vec<Arc<crate::shadow::Shadow>> = Vec::new();
|
||||
for (shadow, _) in &declared {
|
||||
for shadow in declared.iter().map(|d| &d.0).chain(looked.iter().map(|l| &l.0)) {
|
||||
if shadow.card_make_before(|size| {
|
||||
let before = self.uav_buffer(crate::shadow::card_hash_bytes(size))?;
|
||||
name(&before, || "title buffer on the card, hashes of its pieces".into());
|
||||
@@ -3631,12 +3654,30 @@ impl Host {
|
||||
span,
|
||||
at,
|
||||
compared,
|
||||
picked: false,
|
||||
});
|
||||
if compared {
|
||||
at += span.pieces;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (shadow, from, len) in looked {
|
||||
let twin = shadow.card_sides().is_some_and(|(_, before, _)| before.is_some());
|
||||
if let Some(span) = shadow.card_span(*from, from + len)
|
||||
&& twin
|
||||
&& u64::from(at + span.pieces) * 4 <= work.differs.2
|
||||
{
|
||||
plan.ranges.push(CardRange {
|
||||
shadow: shadow.clone(),
|
||||
declared: (*from, from + len),
|
||||
span,
|
||||
at,
|
||||
compared: true,
|
||||
picked: true,
|
||||
});
|
||||
at += span.pieces;
|
||||
}
|
||||
}
|
||||
work.taken = at;
|
||||
if plan.ranges.iter().any(|r| r.compared) {
|
||||
let Some(check) = work.check.pop().or_else(|| self.make_prelude()) else {
|
||||
@@ -3669,7 +3710,9 @@ impl Host {
|
||||
};
|
||||
list.SetComputeRootShaderResourceView(1, r.shadow.buffer.GetGPUVirtualAddress());
|
||||
list.SetComputeRootUnorderedAccessView(2, before.GetGPUVirtualAddress());
|
||||
card_pass(list, &r.span, size as u32, r.at, if flown { 2 } else { 1 });
|
||||
// (What is only looked at keeps its hashes: what
|
||||
// changed there is the next declared range's to land.)
|
||||
card_pass(list, &r.span, size as u32, r.at, if flown && !r.picked { 2 } else { 1 });
|
||||
CARD_PASSES[2].fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
list.Close()?;
|
||||
@@ -3795,9 +3838,11 @@ impl Host {
|
||||
let suspects = fetch.as_ref().map(|f| &f.suspects);
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
for &(plan, behind) in plans {
|
||||
plan.picked_found(differs);
|
||||
let flags: Vec<(usize, u32, bool)> = plan
|
||||
.ranges
|
||||
.iter()
|
||||
.filter(|r| !r.picked)
|
||||
.flat_map(|r| {
|
||||
(0..r.span.pieces).map(move |p| {
|
||||
let flagged = !r.compared || differs.get((r.at + p) as usize).is_none_or(|&d| torn::flagged(d));
|
||||
@@ -3807,7 +3852,7 @@ impl Host {
|
||||
})
|
||||
.collect();
|
||||
let fetched = flagged_pieces(&flags);
|
||||
for r in &plan.ranges {
|
||||
for r in plan.ranges.iter().filter(|r| !r.picked) {
|
||||
let copy = std::sync::Arc::as_ptr(&r.shadow) as usize;
|
||||
if upcheck::on() {
|
||||
upcheck::declared(r.shadow.id(), r.span.from as usize, r.span.to as usize);
|
||||
@@ -4166,7 +4211,8 @@ impl Host {
|
||||
// where the bytes come down.
|
||||
let mut pieces: Vec<(usize, usize, usize, u64)> = Vec::new();
|
||||
let mut total = 0u64;
|
||||
for (i, r) in plan.ranges.iter().enumerate() {
|
||||
plan.picked_found(differs);
|
||||
for (i, r) in plan.ranges.iter().enumerate().filter(|(_, r)| !r.picked) {
|
||||
for p in 0..r.span.pieces {
|
||||
if r.compared && !torn::flagged(differs[(r.at + p) as usize]) {
|
||||
continue;
|
||||
@@ -4708,7 +4754,13 @@ impl Host {
|
||||
self.settle(&mut submitted, WHY_MOST);
|
||||
settled += settling.elapsed();
|
||||
}
|
||||
let card = self.card_before(runs, flown);
|
||||
// What shaders may write through views they pick: last, so that no
|
||||
// refresh of this submission leaves it alone.
|
||||
let picked = crate::picked::declare(runs);
|
||||
for (shadow, at, len) in &picked.written {
|
||||
shadow.writing(*at, *len);
|
||||
}
|
||||
let card = self.card_before(runs, &picked, flown);
|
||||
if let Some(check) = card.as_ref().and_then(|c| c.check.clone()) {
|
||||
lists.push(Some(check));
|
||||
}
|
||||
@@ -4724,7 +4776,7 @@ impl Host {
|
||||
if let Err(e) = signalled {
|
||||
fail(format_args!("a submission sent ahead could not be followed by a signal ({e})"));
|
||||
}
|
||||
let back = declared_writes(runs);
|
||||
let back = crate::picked::with(declared_writes(runs), &picked.written);
|
||||
let writes = runs.iter().flat_map(|l| l.deferred().writes.clone()).collect();
|
||||
SUBMISSION_US[0].fetch_add((prepared - started).saturating_sub(settled).as_micros() as u64, Ordering::Relaxed);
|
||||
submitting(0, 0);
|
||||
@@ -4844,7 +4896,7 @@ impl Host {
|
||||
if let Some(card) = &card {
|
||||
self.card_back(card, &mut submitted, &mut std::collections::HashSet::new());
|
||||
}
|
||||
let back = declared_writes(runs);
|
||||
let back = crate::picked::with(declared_writes(runs), &picked.written);
|
||||
hand_back(&back);
|
||||
if let Some(card) = card {
|
||||
self.card_done(card);
|
||||
@@ -5969,6 +6021,12 @@ impl HostList {
|
||||
self.deferred().textures.insert(key)
|
||||
}
|
||||
|
||||
/// Whether `key` was asked about ([`HostList::first_use`]) since the
|
||||
/// reset.
|
||||
pub(crate) fn used(&self, key: usize) -> bool {
|
||||
self.deferred().textures.contains(&key)
|
||||
}
|
||||
|
||||
/// Runs `work` when the list is submitted, in order with its copies.
|
||||
/// `work` may write title memory (refreshes after it copy again).
|
||||
pub(crate) fn defer(&self, work: impl Fn() + Send + 'static) {
|
||||
|
||||
Reference in new issue
Block a user