Merge fork main a26859f (the first room renders right)

Descriptor records the title copies as bytes are mirrored before each
submission. Views off their copy's elements: our rule (raw views too, and
now typed views on 16 bytes), the fork's copies. Wave sums of halves: ours
(the fork's test passes with it). Sizes of descriptors nothing uses: ours,
then the fork's for 2D images. The fork's count of cut indirect groups is
left out: up to WIDEST groups run as asked here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-25 01:00:56 -06:00
commit f1650b7e45
13 files changed
+964 -109

No files matched your search

+67 -4
View File
@@ -44,6 +44,27 @@ fn next_asking() -> u64 {
ASKED.fetch_add(1, std::sync::atomic::Ordering::Relaxed) + 1
}
/// A title-memory range whose changed pages another subsystem needs to read.
pub(crate) struct Tracked {
start: usize,
end: usize,
seen: Mutex<BTreeMap<usize, u64>>,
}
/// Tracks a runtime GPU-memory range, including physical-page views when
/// `views` is true. Other process memory is not tracked.
pub(crate) fn track(start: usize, len: usize, views: bool) -> Option<Tracked> {
let end = start.checked_add(len)?;
if len == 0 || writes(start, end, views).is_none() {
return None;
}
Some(Tracked {
start,
end,
seen: Mutex::default(),
})
}
struct Journal {
/// Page number → the asking that last found it written.
written: BTreeMap<usize, u64>,
@@ -498,6 +519,42 @@ pub(crate) fn nothing_new(start: usize, end: usize, base: usize, copied: &[u64],
&& j.written.range(first..last).all(|(&page, &write)| write <= taken[page - first].max(ranged))
}
impl Tracked {
/// Takes changed pages of `[from, to)`, cut to the tracked range. A
/// partial page stays changed so a later take can read its other bytes.
pub(crate) fn take(&self, from: usize, to: usize) -> Vec<(usize, usize)> {
let (from, to) = (from.max(self.start), to.min(self.end));
if from >= to {
return Vec::new();
}
let Some((_, pages)) = writes(from, to, true) else {
return Vec::new();
};
let mut seen = self.seen.lock().unwrap_or_else(|e| e.into_inner());
let mut ranges: Vec<(usize, usize)> = Vec::new();
for (page, write) in pages {
if seen.get(&page).is_some_and(|&last| last >= write) {
continue;
}
let (start, end) = ((page * PAGE).max(from), ((page + 1) * PAGE).min(to));
if start >= end {
continue;
}
// Keep partial pages dirty: the caller has not taken the rest.
if (page * PAGE).max(self.start) >= from
&& ((page + 1) * PAGE).min(self.end) <= to
{
seen.insert(page, write);
}
match ranges.last_mut() {
Some((_, last)) if *last == start => *last = end,
_ => ranges.push((start, end)),
}
}
ranges
}
}
/// Guarded blocks of view memory.
const BLOCK: usize = PAGE;
@@ -1424,16 +1481,22 @@ impl Drop for KernelWrite {
/// copies of buffers and textures read through tables take them again);
/// 2, the placed textures picked by index that lie under it are due again;
/// 4, both also for reads to plain addresses when they have finished.
/// Unset or `0`: nothing, counted only. `1`: bits 1 and 2. `guards`: bit 1
/// alone. `slots`: bit 2 alone. `all`: everything.
/// Unset or `guards`: bit 1 alone. `0`: nothing, counted only (the default
/// until run 199). `1`: bits 1 and 2. `slots`: bit 2 alone. `all`:
/// everything.
/// (Bit 1 by default: in every run 10,000 to 50,000 guarded blocks of host
/// copies lay under such writes and kept the bytes from before; runs 197
/// and 198 opened them, 9,766 and 10,796 blocks, with nothing worse for
/// it. Bit 2 makes texture slots due and is the one that flooded the
/// queue in an earlier form: still asked for by name.)
pub(crate) fn page_writes() -> u8 {
static MODE: std::sync::OnceLock<u8> = std::sync::OnceLock::new();
*MODE.get_or_init(|| match std::env::var("VICTORY_PAGE_WRITES").as_deref().map(str::trim) {
Ok("0") => 0,
Ok("1") => 3,
Ok("guards") => 1,
Ok("slots") => 2,
Ok("all") => 7,
_ => 0,
_ => 1,
})
}