Title memory by address: every list brings up every copy, whoever made it
An arena another list made while this one was being recorded was brought up by that list's submission alone: structures unpacked from zeros, then written over by the arena's first upload. In run light-8 half of the 470 structures unpacked in the frame with the most (1381) were wrong, 5-15 % in frames with few. A title buffer the builder stores in sends up only the dwords the title changed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
be085e5385
commit
28fbbfdcbc
2 files changed
+23
-11
No files matched your search
@@ -463,6 +463,8 @@ impl Memory {
|
|||||||
if self.pages.contains_key(&(address / PAGE)) || !self.open.insert(n) {
|
if self.pages.contains_key(&(address / PAGE)) || !self.open.insert(n) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// (Its pages hold what the CPU writes beside the builder's scratch.)
|
||||||
|
self.copies[n].keep_stores();
|
||||||
let (first, len) = self.copies[n].span();
|
let (first, len) = self.copies[n].span();
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
start = format_args!("{first:#x}"),
|
start = format_args!("{first:#x}"),
|
||||||
@@ -791,7 +793,6 @@ pub(crate) fn ready(
|
|||||||
}
|
}
|
||||||
let builds = use_ != Use::Reads;
|
let builds = use_ != Use::Reads;
|
||||||
m.stats.uses[usize::from(builds)] += 1;
|
m.stats.uses[usize::from(builds)] += 1;
|
||||||
let numbered = m.copies.len();
|
|
||||||
// Once per list and page named: the builder dispatches hundreds of times
|
// Once per list and page named: the builder dispatches hundreds of times
|
||||||
// a frame with the same arguments.
|
// a frame with the same arguments.
|
||||||
const READ: usize = usize::MAX - 0x6d;
|
const READ: usize = usize::MAX - 0x6d;
|
||||||
@@ -880,18 +881,23 @@ pub(crate) fn ready(
|
|||||||
heap.raw_uav_at(base + 1 + n as u32, &shadow.buffer, 0, len);
|
heap.raw_uav_at(base + 1 + n as u32, &shadow.buffer, 0, len);
|
||||||
}
|
}
|
||||||
m.heaps.insert(key, (base, m.copies.len() as u32));
|
m.heaps.insert(key, (base, m.copies.len() as u32));
|
||||||
// shortcut: a copy another list numbers meanwhile is brought up to date
|
// Every copy by every list that has come to by-address memory, whoever
|
||||||
// by that list's submission, which may run after this one's.
|
// numbered it: an arena another list made while this one was being
|
||||||
|
// recorded was brought up to date by that list's submission alone, which
|
||||||
|
// may run after this one's (structures unpacked from zeros, and then
|
||||||
|
// written over by the arena's first upload: in frames that stream much in
|
||||||
|
// half of them, run light-8).
|
||||||
let first_read = list.first_use(READ);
|
let first_read = list.first_use(READ);
|
||||||
let from = if first_read { 0 } else { numbered };
|
if list.first_use(usize::MAX - (6 << 33) - m.copies.len()) {
|
||||||
if first_read || m.copies.len() > numbered {
|
|
||||||
let (start, len) = m.directory.1.span();
|
let (start, len) = m.directory.1.span();
|
||||||
m.directory.1.refresh(list, start, len);
|
m.directory.1.refresh(list, start, len);
|
||||||
}
|
for (n, shadow) in m.copies.iter().enumerate() {
|
||||||
for shadow in &m.copies[from..] {
|
if list.first_use(usize::MAX - (7 << 33) - n) {
|
||||||
let (start, len) = shadow.span();
|
let (start, len) = shadow.span();
|
||||||
shadow.refresh(list, start, len);
|
shadow.refresh(list, start, len);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if first_read {
|
if first_read {
|
||||||
list.keep(&m.faults.0);
|
list.keep(&m.faults.0);
|
||||||
#[cfg(feature = "diagnostics")]
|
#[cfg(feature = "diagnostics")]
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ pub(crate) struct Shadow {
|
|||||||
window: bool,
|
window: bool,
|
||||||
/// Of a copy with two sides: only the dwords the title changed go up,
|
/// Of a copy with two sides: only the dwords the title changed go up,
|
||||||
/// as with [`send_changed`] ([`by_address`]).
|
/// as with [`send_changed`] ([`by_address`]).
|
||||||
changes_only: bool,
|
changes_only: std::sync::atomic::AtomicBool,
|
||||||
/// A window in card memory the CPU maps ([`window_mapped_for`]).
|
/// A window in card memory the CPU maps ([`window_mapped_for`]).
|
||||||
mapped: bool,
|
mapped: bool,
|
||||||
/// With `crate::inplace`: not a copy at all. `buffer` is placed in a
|
/// With `crate::inplace`: not a copy at all. `buffer` is placed in a
|
||||||
@@ -2686,7 +2686,7 @@ impl Shadow {
|
|||||||
},
|
},
|
||||||
card: None,
|
card: None,
|
||||||
window: false,
|
window: false,
|
||||||
changes_only: false,
|
changes_only: Default::default(),
|
||||||
mapped: false,
|
mapped: false,
|
||||||
place: None,
|
place: None,
|
||||||
}
|
}
|
||||||
@@ -3572,7 +3572,7 @@ impl Shadow {
|
|||||||
/// A page of title memory, as read.
|
/// A page of title memory, as read.
|
||||||
static TITLE: std::cell::RefCell<Vec<u8>> = const { std::cell::RefCell::new(Vec::new()) };
|
static TITLE: std::cell::RefCell<Vec<u8>> = const { std::cell::RefCell::new(Vec::new()) };
|
||||||
}
|
}
|
||||||
let Some(card) = self.card.as_ref().filter(|_| self.changes_only || send_changed()) else {
|
let Some(card) = self.card.as_ref().filter(|_| self.changes_only.load(Ordering::Relaxed) || send_changed()) else {
|
||||||
return self.copy(from, to);
|
return self.copy(from, to);
|
||||||
};
|
};
|
||||||
let whole = !known && card.before.lock().unwrap_or_else(|e| e.into_inner()).is_none();
|
let whole = !known && card.before.lock().unwrap_or_else(|e| e.into_inner()).is_none();
|
||||||
@@ -3640,6 +3640,12 @@ impl Shadow {
|
|||||||
self.card.is_some()
|
self.card.is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Shaders store in it what is not declared: from here on only the dwords
|
||||||
|
/// the title changes go up ([`by_address`]).
|
||||||
|
pub(crate) fn keep_stores(&self) {
|
||||||
|
self.changes_only.store(true, Ordering::Relaxed);
|
||||||
|
}
|
||||||
|
|
||||||
/// Offsets `[from, to)` go up again whole, as the CPU's side has them.
|
/// Offsets `[from, to)` go up again whole, as the CPU's side has them.
|
||||||
pub(crate) fn resend(&self, from: usize, to: usize) {
|
pub(crate) fn resend(&self, from: usize, to: usize) {
|
||||||
self.card_changed(from, to);
|
self.card_changed(from, to);
|
||||||
@@ -4673,7 +4679,7 @@ pub(crate) fn by_address(start: u64, len: u64) -> Option<Arc<Shadow>> {
|
|||||||
let gpu = unsafe { buffer.GetGPUVirtualAddress() };
|
let gpu = unsafe { buffer.GetGPUVirtualAddress() };
|
||||||
let mut shadow = Shadow::new(buffer, data, gpu, start, len);
|
let mut shadow = Shadow::new(buffer, data, gpu, start, len);
|
||||||
shadow.window = true;
|
shadow.window = true;
|
||||||
shadow.changes_only = true;
|
shadow.changes_only.store(true, Ordering::Relaxed);
|
||||||
shadow.card = Some(Card {
|
shadow.card = Some(Card {
|
||||||
staging,
|
staging,
|
||||||
before: Mutex::default(),
|
before: Mutex::default(),
|
||||||
|
|||||||
Reference in new issue
Block a user