The first room renders right: byte-copied descriptor records are mirrored, views off their copy's elements get their own bytes, card room for the first world frame, levels on demand run on the card

- Descriptor records the title copies into its heap as bytes are mirrored
  before each submission (pull request #305 by Flyander, after upstream
  VIctory 86a5ed6), with a per-slot fingerprint so only records that
  changed are mirrored, the page read through the kernel, a switch
  (VICTORY_HEAP_SYNC=0) and a counter: about 40,000 records a frame on the
  test machine.
- A buffer view off its copy's elements gets a copy of its own bytes
  (after upstream 86a5ed6; VICTORY_VIEW_OWN_COPY=0: refused as before).
- Room on the card for the world's first-frame bursts: buffer copies
  (VICTORY_CARD_ROOM_FOR_BUFFERS, now on) and render targets
  (VICTORY_CARD_ROOM_FOR_TARGETS_MB, 3,072); a copy turned down gives its
  room up and is logged; the texture pass asks again every 32 MiB. 98
  buffer copies made (945 MB) where earlier runs made 1; 25 MB compared
  on the processor a frame where it was 550 to 710.
- Levels on demand: the fixes of pull request #747 by AscilCH. First run
  on a card (RTX 4070, VICTORY_LEVELS_ON_DEMAND=1): no device loss, 3.1 GB
  not allocated for levels the title does not hold. Still off by default.
- The guarded blocks under storage writes into physical pages are opened
  by default (VICTORY_PAGE_WRITES=0: counted only).
- Shaders: a program is translated with first-half interpolation pairs
  only if it was refused for one (with it on for every program 8,551
  working pixel programs came out changed); parked lane-mask pairs,
  f64 conversions and sums, lane permutations: 14 more programs translate.
- Counted, not fixed: an indirect compute pass asks for about 77,500
  groups in x and is cut to 65,535.

One five-minute game run of these changes on the test machine: no device
loss, no failed request. This merged tree was built; its test suites
were not run.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
fxcelessandClaude Fable 5.2 committed 2026-11-25 01:46:49 -05:00
1 parent 847a0af35e
commit 6afd80f252
13 files changed
+1188 -58

No files matched your search

+67 -4
View File
@@ -33,6 +33,27 @@ pub(crate) const PAGE: usize = 64 << 10;
/// The kernel's page, the unit of its answers.
const KERNEL_PAGE: usize = 4096;
/// 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 {
/// Numbers the askings; 0 is "never".
asked: u64,
@@ -377,6 +398,42 @@ pub(crate) fn writes(start: usize, end: usize, guarded: bool) -> Option<(u64, Ve
))
}
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;
@@ -698,16 +755,22 @@ pub fn writing(at: usize, len: usize) {
/// 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,
})
}