From 83eb5866d316ca8e0c2cd73568dc0bae762362ce Mon Sep 17 00:00:00 2001 From: Octo <180629317+OctoAlgo@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:18:48 +0100 Subject: [PATCH 1/6] pr995-candidate: optional VICTORY_BACK_QUIET patch (fork PR 1188) Copy-backs into write-watched title memory reset the pages' write-watch bits afterwards, so the layer no longer takes its own output in again as a title write. Off by default. Applies to the finished three-PR source that build.sh leaves; one conflict against the candidate's writing_exact path was resolved by keeping writing_exact. Original: Yorivel, https://github.com/fxceless/victory-fork/pull/1188 (fork commit 0460bf535). Co-Authored-By: Claude Opus 5.5 --- docs/pr995-candidate/README.md | 21 ++++ docs/pr995-candidate/back-quiet.patch.txt | 134 ++++++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 docs/pr995-candidate/back-quiet.patch.txt diff --git a/docs/pr995-candidate/README.md b/docs/pr995-candidate/README.md index 71d6ca22992..d7a450ce569 100644 --- a/docs/pr995-candidate/README.md +++ b/docs/pr995-candidate/README.md @@ -189,6 +189,27 @@ with the original source patch at commit `4331d2b`. Its matched checkpoint runs measured 5.17 FPS on the historical baseline and 5.19 FPS with PR927. [Historical source kit](https://github.com/ThomasHFWright/LinVxtory/tree/4331d2b95ab2a56af74884c1b62a2966a35588b3/docs/pr995-candidate) · [Linux integration notes](../pr927-integration.md) +## Optional frame-rate patches + +This patch applies to the finished three-PR source that `build.sh` leaves in +the external directory. The switch is off by default, so a build without +it set behaves like the tested renderer. See [Linux notes from a second RTX 5090](../linux-notes-5090.md) +for the measurements. + +```sh +src=../linvxtory-renderer # the directory given to build.sh +git -C "$src" apply --check docs/pr995-candidate/back-quiet.patch.txt +git -C "$src" apply docs/pr995-candidate/back-quiet.patch.txt +``` + +Then run the same `cargo build` command as the last line of `build.sh`, from the source directory. +Rerunning `build.sh` stops at `verify.sh`, because shadow.rs and descriptor/host.rs +no longer match the lock. + +- `back-quiet.patch.txt`: `VICTORY_BACK_QUIET=1` from + [fork PR 1188](https://github.com/fxceless/victory-fork/pull/1188) by Yorivel. + After a copy-back, the pages' write-watch bits are reset, so the copy-back's + own writes no longer count as title writes. ## Linux preset and runtime [linux-preset.sh](linux-preset.sh) records the measured candidate flags without diff --git a/docs/pr995-candidate/back-quiet.patch.txt b/docs/pr995-candidate/back-quiet.patch.txt new file mode 100644 index 00000000000..d94ca5f26de --- /dev/null +++ b/docs/pr995-candidate/back-quiet.patch.txt @@ -0,0 +1,134 @@ +diff --git a/crates/victory-gpu/src/shadow.rs b/crates/victory-gpu/src/shadow.rs +index 8e21c4871..bf1deb5b6 100644 +--- a/crates/victory-gpu/src/shadow.rs ++++ b/crates/victory-gpu/src/shadow.rs +@@ -4596,7 +4596,9 @@ impl Shadow { + // stretch is the title's as read, and a title write landing + // there since stays. + for &(off, len) in &runs { +- crate::host::write_mapped((start + at + off) as *mut u8, title[off..].as_ptr(), len); ++ if !self.put_back_quiet(start + at + off, &title[off..off + len]) { ++ crate::host::write_mapped((start + at + off) as *mut u8, title[off..].as_ptr(), len); ++ } + written += len; + } + } +@@ -4689,6 +4691,9 @@ impl Shadow { + } + count_skinned(skinned::MERGED, (start + at) as u64, (start + at + title.len()) as u64); + crate::host::shaders_write(start + at, &title[..]); ++ if self.put_back_quiet(start + at, &title[..]) { ++ return n; ++ } + if self.put_back_own(start + at, &title[..]) { + return n; + } +@@ -4698,6 +4703,66 @@ impl Shadow { + n + } + ++ /// With `VICTORY_BACK_QUIET=1`: what a merge made of private, ++ /// write-watched title memory `[at, at + bytes.len())` is written as ++ /// before, then the kernel's write-watch bits of those pages are reset, ++ /// so the write does not read as the title's; the journal is told the ++ /// pages changed (as [`Self::put_back_own`] does for view memory), so ++ /// every other copy that holds them takes them again, and this copy, ++ /// which holds them already, notes itself current instead of taking ++ /// its own output in again. The read census on the fork (#1169) found ++ /// about 92% of the layer's touches of copied-back pages were that. ++ /// False with nothing written if the switch is off, the pages are not ++ /// write-watched, or the title wrote one of them since the last asking ++ /// (its bit would be reset too): the caller writes as before. ++ /// shortcut: a title write to one of the pages between the write and ++ /// the reset is lost to the write-watch. ++ fn put_back_quiet(&self, at: usize, bytes: &[u8]) -> bool { ++ use windows_sys::Win32::System::Memory::{GetWriteWatch, ResetWriteWatch}; ++ if !quiet_back() || bytes.is_empty() { ++ return false; ++ } ++ let first = at & !4095; ++ let end = (at + bytes.len()).next_multiple_of(4096); ++ let mut found = [std::ptr::null_mut::(); 32]; ++ let mut count = found.len(); ++ let mut granularity = 0u32; ++ // SAFETY: a query of title memory into arrays of ours. ++ let asked = unsafe { ++ GetWriteWatch(0, first as _, end - first, found.as_mut_ptr(), &mut count, &mut granularity) ++ }; ++ if asked != 0 || count != 0 { ++ QUIET[1].fetch_add(1, Ordering::Relaxed); ++ return false; ++ } ++ crate::watch::writing(at, bytes.len()); ++ crate::host::write_mapped(at as *mut u8, bytes.as_ptr(), bytes.len()); ++ // SAFETY: the same write-watched pages. ++ unsafe { ResetWriteWatch(first as _, end - first) }; ++ crate::descriptor::host::remapped(at, bytes.len()); ++ let base = self.start as usize / PAGE; ++ for page in at / PAGE..(at + bytes.len()).div_ceil(PAGE) { ++ let (before, now) = crate::watch::wrote_own(page, &[]); ++ let mut copied = self.copied.lock().unwrap_or_else(|e| e.into_inner()); ++ if let Some(taken) = page.checked_sub(base).and_then(|i| copied.get_mut(i)) ++ && *taken != 0 ++ && *taken >= before ++ { ++ *taken = (*taken).max(now); ++ } ++ } ++ QUIET[0].fetch_add(bytes.len() as u64, Ordering::Relaxed); ++ let n = QUIET[2].fetch_add(1, Ordering::Relaxed) + 1; ++ if n.is_multiple_of(16384) { ++ tracing::info!( ++ "copy-backs written quietly (VICTORY_BACK_QUIET=1) since the start: {n} stretches {} MB; written the old way (not write-watched, or the title had written there): {}", ++ QUIET[0].load(Ordering::Relaxed) >> 20, ++ QUIET[1].load(Ordering::Relaxed) ++ ); ++ } ++ true ++ } ++ + /// With `crate::inplace::back_own` (`VICTORY_BACK_OWN_VIEW=1`): stores + /// what a merge made of title memory `[at, at + bytes.len())` (inside + /// one 64 KiB page, as every merged stretch is) through a view of our +@@ -6025,9 +6090,11 @@ impl Shadow { + if differs != 0 { + count_skinned(skinned::MERGED, (start + at) as u64, (start + at + title.len()) as u64); + crate::host::shaders_write(start + at, &title[..]); +- crate::watch::writing_exact(start + at, n); +- merge_race(as_read.as_deref(), (self.start, self.len), start + at, &title[..], "card"); +- crate::host::write_mapped((start + at) as *mut u8, title.as_ptr(), n); ++ if !self.put_back_quiet(start + at, &title[..]) { ++ crate::watch::writing_exact(start + at, n); ++ merge_race(as_read.as_deref(), (self.start, self.len), start + at, &title[..], "card"); ++ crate::host::write_mapped((start + at) as *mut u8, title.as_ptr(), n); ++ } + written = n; + } + } else { +@@ -6117,6 +6184,9 @@ impl Shadow { + } + count_skinned(skinned::MERGED, (start + at) as u64, (start + at + title.len()) as u64); + crate::host::shaders_write(start + at, &title[..]); ++ if self.put_back_quiet(start + at, &title[..]) { ++ return n; ++ } + if self.put_back_own(start + at, &title[..]) { + return n; + } +@@ -6487,6 +6557,16 @@ fn window_of(address: u64, end: u64, grid: u64) -> (u64, u64) { + /// together with `VICTORY_WINDOW_KB` below 4096: on the 4 MiB grid an ask + /// with a length in the same cell makes the whole cell's window, and the + /// tail is that. ++/// `VICTORY_BACK_QUIET=1`: see [`Shadow::put_back_quiet`]. Off by default. ++fn quiet_back() -> bool { ++ static ON: std::sync::OnceLock = std::sync::OnceLock::new(); ++ *ON.get_or_init(|| std::env::var_os("VICTORY_BACK_QUIET").is_some_and(|v| v == "1")) ++} ++ ++/// Quiet copy-backs since the start: bytes, stretches written the old way, ++/// stretches written quietly. ++static QUIET: [AtomicU64; 3] = [const { AtomicU64::new(0) }; 3]; ++ + fn tails() -> bool { + static ON: std::sync::OnceLock = std::sync::OnceLock::new(); + *ON.get_or_init(|| std::env::var_os("VICTORY_WINDOW_TAILS").is_some_and(|v| v == "1")) From 9def71af9dbdbbb326a5c7b2a0b740bb10562d4f Mon Sep 17 00:00:00 2001 From: Octo <180629317+OctoAlgo@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:19:03 +0100 Subject: [PATCH 2/6] pr995-candidate: optional VICTORY_DYNAMIC_SLOTS patch On a host that caps the view heap (NVIDIA: 1,000,000 slots for the title's 1,245,184), VICTORY_DYNAMIC_SLOTS= gives the dynamic-slot ring n slots (2^18 up to half the heap), taken from the title's slots kept in place; the allocator's bitmap, free count and wrap follow the heap's own count. Unset: unchanged. Idea and first implementation: trustno1-coder, https://github.com/trustno1-coder/VIctory-NVIDIA/commit/a9632bc8de343aa20adf4f1123f16445f5b1b21b This version: OctoAlgo, adapted to the candidate's single `kept` lock. Co-Authored-By: Claude Opus 5.5 --- docs/pr995-candidate/README.md | 14 ++++- docs/pr995-candidate/dynamic-slots.patch.txt | 63 ++++++++++++++++++++ 2 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 docs/pr995-candidate/dynamic-slots.patch.txt diff --git a/docs/pr995-candidate/README.md b/docs/pr995-candidate/README.md index d7a450ce569..e4822f7b346 100644 --- a/docs/pr995-candidate/README.md +++ b/docs/pr995-candidate/README.md @@ -191,15 +191,17 @@ runs measured 5.17 FPS on the historical baseline and 5.19 FPS with PR927. ## Optional frame-rate patches -This patch applies to the finished three-PR source that `build.sh` leaves in -the external directory. The switch is off by default, so a build without -it set behaves like the tested renderer. See [Linux notes from a second RTX 5090](../linux-notes-5090.md) +These patches apply to the finished three-PR source that `build.sh` leaves in +the external directory. Both switches are off by default, so a build with +neither switch set behaves like the tested renderer. See [Linux notes from a second RTX 5090](../linux-notes-5090.md) for the measurements. ```sh src=../linvxtory-renderer # the directory given to build.sh git -C "$src" apply --check docs/pr995-candidate/back-quiet.patch.txt git -C "$src" apply docs/pr995-candidate/back-quiet.patch.txt +git -C "$src" apply --check docs/pr995-candidate/dynamic-slots.patch.txt +git -C "$src" apply docs/pr995-candidate/dynamic-slots.patch.txt ``` Then run the same `cargo build` command as the last line of `build.sh`, from the source directory. @@ -210,6 +212,12 @@ no longer match the lock. [fork PR 1188](https://github.com/fxceless/victory-fork/pull/1188) by Yorivel. After a copy-back, the pages' write-watch bits are reset, so the copy-back's own writes no longer count as title writes. +- `dynamic-slots.patch.txt`: `VICTORY_DYNAMIC_SLOTS=` (2^18 up to half the + heap; we use 524288). NVIDIA caps the host view heap at 1,000,000 slots, and + the 2^18 dynamic slots can run full, which drops draws. This patch enlarges + that ring and takes the extra slots from the title's slots kept in place. The + idea comes from [trustno1-coder/VIctory-NVIDIA a9632bc](https://github.com/trustno1-coder/VIctory-NVIDIA/commit/a9632bc8de343aa20adf4f1123f16445f5b1b21b). + ## Linux preset and runtime [linux-preset.sh](linux-preset.sh) records the measured candidate flags without diff --git a/docs/pr995-candidate/dynamic-slots.patch.txt b/docs/pr995-candidate/dynamic-slots.patch.txt new file mode 100644 index 00000000000..253767e7a7e --- /dev/null +++ b/docs/pr995-candidate/dynamic-slots.patch.txt @@ -0,0 +1,63 @@ +diff --git a/crates/victory-gpu/src/descriptor/host.rs b/crates/victory-gpu/src/descriptor/host.rs +index c215b2cb4..896de448b 100644 +--- a/crates/victory-gpu/src/descriptor/host.rs ++++ b/crates/victory-gpu/src/descriptor/host.rs +@@ -942,6 +942,20 @@ pub(crate) fn probe_view_limit() { + /// table past them is made afresh in these slots like any other. + pub(crate) const DYNAMIC: u32 = 1 << 18; + ++/// The dynamic slots of a capped view heap whose null slot is `null` ++/// (`VICTORY_DYNAMIC_SLOTS`, read once; [`DYNAMIC`] when unset). ++fn dynamic_slots_capped(null: u32) -> u32 { ++ static SLOTS: std::sync::OnceLock = std::sync::OnceLock::new(); ++ *SLOTS.get_or_init(|| { ++ let asked = std::env::var("VICTORY_DYNAMIC_SLOTS").ok().and_then(|v| v.trim().parse::().ok()); ++ let slots = asked.map_or(DYNAMIC, |n| n.clamp(DYNAMIC, (null / 2).max(DYNAMIC))); ++ if slots != DYNAMIC { ++ tracing::info!(slots, title_slots_in_place = null - slots, "dynamic view slots on a capped host heap (VICTORY_DYNAMIC_SLOTS)"); ++ } ++ slots ++ }) ++} ++ + impl HostHeap { + pub(crate) fn new(sampler: bool, count: u32) -> Option { + let host = host()?; +@@ -974,6 +988,17 @@ impl HostHeap { + } else { + victory_shader::emit::view_heap_limit() + }; ++ // After trustno1-coder/VIctory-NVIDIA a9632bc's finding: on a host that caps view heaps (NVIDIA: 1,000,000 for ++ // the title's 1,245,184) the title's slots past the cap are not kept in ++ // place anyway, and the ring of dynamic slots (2^18) can run full: a ++ // table that finds no room is a dropped draw. `VICTORY_DYNAMIC_SLOTS=` ++ // gives the ring n slots there (at least 2^18, at most half the heap), ++ // taken from the title's slots kept in place. Unset: as before. ++ let extra = if !sampler && null != 0 && count + extra > null { ++ dynamic_slots_capped(null) ++ } else { ++ extra ++ }; + let (heap, count, size) = if null == 0 { + match make(count + extra) { + Ok(heap) => (heap, count, count + extra), +@@ -1052,8 +1077,8 @@ impl HostHeap { + .map(|_| std::sync::atomic::AtomicU64::new(0)) + .collect(), + kept: Mutex::new(vec![None; (count + extra) as usize]), +- next: Mutex::new((0, vec![false; DYNAMIC as usize])), +- free: std::sync::atomic::AtomicU32::new(DYNAMIC), ++ next: Mutex::new((0, vec![false; if sampler { DYNAMIC } else { extra } as usize])), ++ free: std::sync::atomic::AtomicU32::new(if sampler { DYNAMIC } else { extra }), + too_long: std::sync::atomic::AtomicU32::new(u32::MAX), + strides, + buffers: Mutex::default(), +@@ -1197,7 +1222,7 @@ impl HostHeap { + crate::copystat::add(crate::copystat::C::DynamicNs, started.elapsed().as_nanos() as u64); + taken[first..first + n].fill(true); + self.free.fetch_sub(n as u32, std::sync::atomic::Ordering::Relaxed); +- *next = ((first + n) % DYNAMIC as usize) as u32; ++ *next = ((first + n) % self.dynamic.max(1) as usize) as u32; + Some(self.count + first as u32) + } + From 66e50fa2d79b2a6b24cbae2182b280d5be1c2c09 Mon Sep 17 00:00:00 2001 From: Octo <180629317+OctoAlgo@users.noreply.github.com> Date: Thu, 26 Nov 2026 11:39:41 +0100 Subject: [PATCH 3/6] pr995-candidate: optional VICTORY_CARD_BUFFERS_MIN_KB patch VICTORY_CARD_BUFFERS_MIN_KB= sets the least size of a title buffer whose host copy lives in the card's memory below the 1 MiB floor of VICTORY_CARD_BUFFERS_MIN_MB (64 = every buffer). The copies under 1 MiB are thousands of small buffers that shaders load, store and do atomics on over the bus. Unset: unchanged. Logs one line when set. Original: fxceless, fxceless/victory-fork commit c36971b213770e48f513f0d6e3ced3f1f65a32b2 (the card_limits part only; its placement counters are not ported). Co-Authored-By: Claude Opus 5.5 --- docs/pr995-candidate/README.md | 15 ++++++++--- .../card-buffers-min-kb.patch.txt | 27 +++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 docs/pr995-candidate/card-buffers-min-kb.patch.txt diff --git a/docs/pr995-candidate/README.md b/docs/pr995-candidate/README.md index e4822f7b346..eda6a34026b 100644 --- a/docs/pr995-candidate/README.md +++ b/docs/pr995-candidate/README.md @@ -191,9 +191,9 @@ runs measured 5.17 FPS on the historical baseline and 5.19 FPS with PR927. ## Optional frame-rate patches -These patches apply to the finished three-PR source that `build.sh` leaves in -the external directory. Both switches are off by default, so a build with -neither switch set behaves like the tested renderer. See [Linux notes from a second RTX 5090](../linux-notes-5090.md) +These patches apply to the finished source that `build.sh` leaves in +the external directory. All three switches are off by default, so a build with +none of them set behaves like the tested renderer. See [Linux notes from a second RTX 5090](../linux-notes-5090.md) for the measurements. ```sh @@ -202,10 +202,12 @@ git -C "$src" apply --check docs/pr995-candidate/back-quiet.patch.txt git -C "$src" apply docs/pr995-candidate/back-quiet.patch.txt git -C "$src" apply --check docs/pr995-candidate/dynamic-slots.patch.txt git -C "$src" apply docs/pr995-candidate/dynamic-slots.patch.txt +git -C "$src" apply --check docs/pr995-candidate/card-buffers-min-kb.patch.txt +git -C "$src" apply docs/pr995-candidate/card-buffers-min-kb.patch.txt ``` Then run the same `cargo build` command as the last line of `build.sh`, from the source directory. -Rerunning `build.sh` stops at `verify.sh`, because shadow.rs and descriptor/host.rs +Rerunning `build.sh` stops at `verify.sh`, because the patched files no longer match the lock. - `back-quiet.patch.txt`: `VICTORY_BACK_QUIET=1` from @@ -217,6 +219,11 @@ no longer match the lock. the 2^18 dynamic slots can run full, which drops draws. This patch enlarges that ring and takes the extra slots from the title's slots kept in place. The idea comes from [trustno1-coder/VIctory-NVIDIA a9632bc](https://github.com/trustno1-coder/VIctory-NVIDIA/commit/a9632bc8de343aa20adf4f1123f16445f5b1b21b). +- `card-buffers-min-kb.patch.txt`: `VICTORY_CARD_BUFFERS_MIN_KB=`, from + fxceless's [c36971b](https://github.com/fxceless/victory-fork/commit/c36971b213770e48f513f0d6e3ced3f1f65a32b2). + It lowers the 1 MiB floor for title-buffer copies in the card's memory, so + small buffers that shaders hammer stop crossing the bus. We use `64` together + with `VICTORY_CARD_BUFFERS_MB=1536`. ## Linux preset and runtime diff --git a/docs/pr995-candidate/card-buffers-min-kb.patch.txt b/docs/pr995-candidate/card-buffers-min-kb.patch.txt new file mode 100644 index 00000000000..bee2201230d --- /dev/null +++ b/docs/pr995-candidate/card-buffers-min-kb.patch.txt @@ -0,0 +1,27 @@ +diff --git a/crates/victory-gpu/src/shadow.rs b/crates/victory-gpu/src/shadow.rs +index 8a0ab5807..0d86e5608 100644 +--- a/crates/victory-gpu/src/shadow.rs ++++ b/crates/victory-gpu/src/shadow.rs +@@ -188,7 +188,21 @@ fn card_limits() -> (u64, u64) { + // the shader writes of the smaller buffers are then found by the + // card's hashes too, and with that the first room's walls were + // drawn in every run. +- (mb("VICTORY_CARD_BUFFERS_MIN_MB", 1).max(1 << 20), mb("VICTORY_CARD_BUFFERS_MB", 1024)) ++ // `VICTORY_CARD_BUFFERS_MIN_KB` (not set by default) says the least ++ // size in KiB instead, so that it can go under 1 MiB: 64 is every ++ // title buffer (a copy's size is rounded up to 64 KiB). The copies ++ // under 1 MiB otherwise stay in the PC's memory, and every load, ++ // store and atomic a shader does on them crosses the bus. What it ++ // costs: 64 KiB of the card's memory a copy, and as much again for ++ // one that shaders write (fxceless/victory-fork c36971b). ++ let least = match std::env::var("VICTORY_CARD_BUFFERS_MIN_KB").ok().and_then(|v| v.trim().parse::().ok()) { ++ Some(kib) if kib > 0 => { ++ tracing::info!(kib, "title buffers from this size get copies in the card's memory (VICTORY_CARD_BUFFERS_MIN_KB)"); ++ kib << 10 ++ } ++ _ => mb("VICTORY_CARD_BUFFERS_MIN_MB", 1).max(1 << 20), ++ }; ++ (least, mb("VICTORY_CARD_BUFFERS_MB", 1024)) + }) + } + From 15014f3a2ecf8b4fbdad97ea0ddf191e703010a6 Mon Sep 17 00:00:00 2001 From: Octo <180629317+OctoAlgo@users.noreply.github.com> Date: Thu, 26 Nov 2026 11:39:53 +0100 Subject: [PATCH 4/6] docs: notes from a second RTX 5090 on Linux Measured results from another CachyOS + RTX 5090 setup: small buffers in the card's memory (CARD_BUFFERS_MIN_KB=64, +33.5 %), the view-tree wineserver (CachyOS/wine-cachyos#50 by ajsem1337, after neonbyte1), the title's pool-empty breakpoint on new games (Marvisak/VIctory#698), TEXTURE_BACK for the Chapter 1 boat (fxceless/victory-fork#999), the ambient tint that matched the PS5 reference, and frame-rate switches measured on fork main (fxceless/victory-fork#1014, #1188, 5d659e0c8). Co-Authored-By: Claude Opus 5.5 --- docs/linux-notes-5090.md | 121 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 docs/linux-notes-5090.md diff --git a/docs/linux-notes-5090.md b/docs/linux-notes-5090.md new file mode 100644 index 00000000000..d6434e82d6f --- /dev/null +++ b/docs/linux-notes-5090.md @@ -0,0 +1,121 @@ +# Notes from a second RTX 5090 on Linux + +Findings from another CachyOS + RTX 5090 setup (also an RTX 5070 Ti), NVIDIA +620.73.04, Proton 11.0 / GE-Proton 11-14, running fxceless/victory-fork main +plus Linux fixes. All numbers are from our own runs. They are measured on a +different base than the PR995 renderer, so treat them as leads, not as +promises for this tree. No binaries, game data or captures are included. + +## Biggest single win: small buffers in the card's memory + +`VICTORY_CARD_BUFFERS_MIN_KB=64` with `VICTORY_CARD_BUFFERS_MB=1536` keeps the +copies of *all* title buffers in the card's memory. Without it, buffers under +1 MiB stay in PC memory: thousands of small buffers, and every shader access +to them crosses the bus. On our RTX 5090 (fork main, release, desktop, world +frames 300–600 of our cell save): + +| | FPS | Waiting for the GPU | Copy-back | +|---|---:|---:|---:| +| Our previous defaults | 6.14 | 60 ms | 90 ms | +| `CARD_BUFFERS_MIN_KB=64`, `CARD_BUFFERS_MB=1536` | **8.19 (+33.5 % ± 6.4 %)** | 23 ms | 62 ms | + +Keep `CARD_BUFFERS_MB` at 1536: with `MIN_KB=64` and 1024 MB, our runs were +about 50 % slower. The PR995 renderer has `CARD_BUFFERS_MB` but not `MIN_KB`. +[card-buffers-min-kb.patch.txt](pr995-candidate/card-buffers-min-kb.patch.txt) +adds `MIN_KB` from fxceless's +[c36971b](https://github.com/fxceless/victory-fork/commit/c36971b213770e48f513f0d6e3ced3f1f65a32b2). + +On this repository's renderer (`438872d` + the three kit patches, RTX 5090, +Xvfb, release, one run each), setting `MIN_KB=64`, `CARD_BUFFERS_MB=1536`, +`BACK_QUIET=1` and `DYNAMIC_SLOTS=524288` together gave 4.91 FPS. With nothing +set, it gave 4.34 FPS. That's +13 %, with copy-back down from 84 to 61 ms a +frame. The switched run paid for the cold shader translations. Neither run +had an Xid. + +One caveat: in 4 of 17 of our runs the cell came up dark with very few shader +lookups. This happened with the switch on and off, and we haven't found the +cause. Check the picture when you compare. + +## Wineserver: memory views in a tree + +[CachyOS/wine-cachyos PR #50](https://github.com/CachyOS/wine-cachyos/pull/50) +(ajsem1337, based on a version by neonbyte1) keeps each process's memory views +in a red-black tree by base address. It is the same idea as the indexed GE11-14 +wineserver used here. It touches only `server/file.h`, `server/mapping.c`, +`server/process.c` and `server/process.h` (+56/-21), with no protocol change. +It applied cleanly to Valve's Proton 11.0 wine (`e60892cc`). + +On Proton 11.0 with only the wineserver swapped: + +| | Stock wineserver | View tree | +|---|---:|---:| +| Loading the world from a save | 118–131 s | 69 s | +| Cutscene right after loading | 2.3–2.4 FPS | 4.9 FPS | +| Steady FPS in the cell | unchanged | unchanged | + +An unpatched wineserver built with the same compiler loaded like stock, so the +gain comes from the patch. Wine reuses a running wineserver for the same +prefix, so stop the old one before you switch. + +## The title's breakpoint on a new game (`0x5149aec`) + +The opening cutscene's prestreaming fills the title's 45,000-entry instance +list. The title then stops at its own breakpoint (`int3`, exit +`0x80000003`), usually 6–10 minutes into a new game. This matches the runs +here that stopped at `0x5149aec` with 45,000 of 45,000 instance slots +occupied. It is tracked in +[Marvisak/VIctory#698](https://github.com/Marvisak/VIctory/issues/698). +Starting from a save made after the intro avoids it. All our measured runs +load such a save. + +## Picture fixes we use + +- **`VICTORY_TEXTURE_BACK=1`** + ([fork PR 999](https://github.com/fxceless/victory-fork/pull/999), + cxy0072019-sketch): in Chapter 1, the boat no longer sinks. Others confirm + this on a 5080, a 3080 and an RX 9070 XT on Linux. The pre-migration + `linux-edge` tree has it, but the PR995 renderer does not. +- **Ambient stand-in** ([fork PR 917](https://github.com/fxceless/victory-fork/pull/917) + plus Belobug's SHADE/TINT commits): `VICTORY_AMBIENT=0.3`, + `VICTORY_AMBIENT_TINT=1,0.6,0.4` and `VICTORY_AMBIENT_SHADE=1.5,0.8,0.1,0.45` + came closest to PS5 reference footage at the cell window. A value of 0.6 + washed the cell out. The PR995 renderer does not include #917. +- From #995's own list of settings, `VICTORY_VIEW_GUARD=0` and + `VICTORY_COMMIT_FLOOR_MB=6144` hid the cell's left wall and the window's wire + mesh on our machine. The preset here does not set them. + +## Frame-rate settings on fork main (RTX 5090, our cell save) + +These are release builds at warm cache. Each value is the FPS over world frames +300–600 of the same save. The base averages three runs at 5.68 FPS (sd 3.3 %). +Any single run within ±6.3 % of the base is noise. + +| On top of our base | FPS | vs base | +|---|---:|---:| +| `VICTORY_CARD_HASH_WIDE=1` ([fork PR 1014](https://github.com/fxceless/victory-fork/pull/1014)) | 6.06 | +6.7 % | +| `VICTORY_TABLE_STAGES=1` (fork main `5d659e0c8`) | 6.08 | +7.1 % | +| Both, plus `VICTORY_CARD_BUFFERS_MB=1536`, `VICTORY_DYNAMIC_SLOTS=524288` and `VICTORY_BACK_QUIET=1` | **6.58** | **+15.8 %** | +| `VICTORY_LOOKUP_CACHE`, `HEAP_PASS_MARKED`, `CARD_SYNC_BATCH`, `STEP_INDEX` or `FILLS_PLAIN` (one at a time) | 5.59–5.88 | noise | + +With the combined set, the submitting thread spends 19 ms in heap sync instead +of 34 ms, and 23 ms instead of 31–36 ms on write-watch queries. The rest of +each frame now goes to waiting for the GPU. + +Only two of these fit the PR995 renderer as small patches. Both are included +as optional kit patches, off by default (with `MIN_KB` above, three in all): + +- [back-quiet.patch.txt](pr995-candidate/back-quiet.patch.txt): + `VICTORY_BACK_QUIET=1` from + [fork PR 1188](https://github.com/fxceless/victory-fork/pull/1188) (Yorivel). + It resets the write-watch bits of pages that copy-back has just written, so + those writes are no longer read back as title writes. On GE-Proton with an + RTX 5080, BitWuehler reported 122 → 51 ms of CPU preparation. +- [dynamic-slots.patch.txt](pr995-candidate/dynamic-slots.patch.txt): + `VICTORY_DYNAMIC_SLOTS=`. NVIDIA caps the host view heap at 1,000,000 + slots, and the 2^18 dynamic slots can run full, which drops draws. This + switch enlarges that ring, up to half the heap. The idea comes from + [trustno1-coder/VIctory-NVIDIA a9632bc](https://github.com/trustno1-coder/VIctory-NVIDIA/commit/a9632bc8de343aa20adf4f1123f16445f5b1b21b). + +`CARD_HASH_WIDE` (344 lines) and `TABLE_STAGES` (226 lines) do not apply to the +candidate without larger rework. They are listed here in case you rebase onto +fork main. From 09804427223ebbf27cea67841aa22e12bc99c4f0 Mon Sep 17 00:00:00 2001 From: Thomas Wright Date: Thu, 26 Nov 2026 14:03:08 +0000 Subject: [PATCH 5/6] Verify the opt-in GPU memory threshold in the source kit --- build.sh | 3 + docs/linux-notes-5090.md | 43 +++--- docs/pr995-candidate/README.md | 44 ++---- docs/pr995-candidate/back-quiet.patch.txt | 134 ------------------ docs/pr995-candidate/card-buffers-files.json | 3 + .../card-buffers-min-kb.patch.txt | 18 ++- docs/pr995-candidate/check_inputs.py | 4 +- docs/pr995-candidate/dynamic-slots.patch.txt | 63 -------- docs/pr995-candidate/validation.md | 28 +++- docs/pr995-candidate/verify.sh | 2 +- 10 files changed, 77 insertions(+), 265 deletions(-) delete mode 100644 docs/pr995-candidate/back-quiet.patch.txt create mode 100644 docs/pr995-candidate/card-buffers-files.json delete mode 100644 docs/pr995-candidate/dynamic-slots.patch.txt diff --git a/build.sh b/build.sh index 2a95dcee411..eab9007f8c7 100755 --- a/build.sh +++ b/build.sh @@ -29,6 +29,9 @@ fi if python3 "$kit/check_inputs.py" "$src" "$kit/final-files.json" >/dev/null 2>&1; then git -C "$src" apply --unidiff-zero "$kit/followup.patch.txt" fi +if python3 "$kit/check_inputs.py" "$src" "$kit/followup-files.json" >/dev/null 2>&1; then + git -C "$src" apply "$kit/card-buffers-min-kb.patch.txt" +fi sh "$kit/verify.sh" "$src" cd "$src" exec cargo build --locked --offline --profile diag -p victory --features diagnostics --target x86_64-pc-windows-msvc diff --git a/docs/linux-notes-5090.md b/docs/linux-notes-5090.md index d6434e82d6f..8e20f17a89f 100644 --- a/docs/linux-notes-5090.md +++ b/docs/linux-notes-5090.md @@ -8,8 +8,8 @@ promises for this tree. No binaries, game data or captures are included. ## Biggest single win: small buffers in the card's memory -`VICTORY_CARD_BUFFERS_MIN_KB=64` with `VICTORY_CARD_BUFFERS_MB=1536` keeps the -copies of *all* title buffers in the card's memory. Without it, buffers under +`VICTORY_CARD_BUFFERS_MIN_KB=64` with `VICTORY_CARD_BUFFERS_MB=1536` makes +all title-buffer copies eligible for GPU memory within the residency budget. Without it, buffers under 1 MiB stay in PC memory: thousands of small buffers, and every shader access to them crosses the bus. On our RTX 5090 (fork main, release, desktop, world frames 300–600 of our cell save): @@ -20,13 +20,12 @@ frames 300–600 of our cell save): | `CARD_BUFFERS_MIN_KB=64`, `CARD_BUFFERS_MB=1536` | **8.19 (+33.5 % ± 6.4 %)** | 23 ms | 62 ms | Keep `CARD_BUFFERS_MB` at 1536: with `MIN_KB=64` and 1024 MB, our runs were -about 50 % slower. The PR995 renderer has `CARD_BUFFERS_MB` but not `MIN_KB`. -[card-buffers-min-kb.patch.txt](pr995-candidate/card-buffers-min-kb.patch.txt) -adds `MIN_KB` from fxceless's +about 50 % slower on our setup. The [standard source build](pr995-candidate/README.md#small-buffer-copies-in-gpu-memory) +includes the threshold from fxceless's [c36971b](https://github.com/fxceless/victory-fork/commit/c36971b213770e48f513f0d6e3ced3f1f65a32b2). -On this repository's renderer (`438872d` + the three kit patches, RTX 5090, -Xvfb, release, one run each), setting `MIN_KB=64`, `CARD_BUFFERS_MB=1536`, +In our earlier PR995 experiment (`438872d` plus three experimental patches, +RTX 5090, Xvfb, release, one run each), setting `MIN_KB=64`, `CARD_BUFFERS_MB=1536`, `BACK_QUIET=1` and `DYNAMIC_SLOTS=524288` together gave 4.91 FPS. With nothing set, it gave 4.34 FPS. That's +13 %, with copy-back down from 84 to 61 ms a frame. The switched run paid for the cold shader translations. Neither run @@ -101,21 +100,23 @@ With the combined set, the submitting thread spends 19 ms in heap sync instead of 34 ms, and 23 ms instead of 31–36 ms on write-watch queries. The rest of each frame now goes to waiting for the GPU. -Only two of these fit the PR995 renderer as small patches. Both are included -as optional kit patches, off by default (with `MIN_KB` above, three in all): - -- [back-quiet.patch.txt](pr995-candidate/back-quiet.patch.txt): - `VICTORY_BACK_QUIET=1` from - [fork PR 1188](https://github.com/fxceless/victory-fork/pull/1188) (Yorivel). - It resets the write-watch bits of pages that copy-back has just written, so - those writes are no longer read back as title writes. On GE-Proton with an - RTX 5080, BitWuehler reported 122 → 51 ms of CPU preparation. -- [dynamic-slots.patch.txt](pr995-candidate/dynamic-slots.patch.txt): - `VICTORY_DYNAMIC_SLOTS=`. NVIDIA caps the host view heap at 1,000,000 - slots, and the 2^18 dynamic slots can run full, which drops draws. This - switch enlarges that ring, up to half the heap. The idea comes from - [trustno1-coder/VIctory-NVIDIA a9632bc](https://github.com/trustno1-coder/VIctory-NVIDIA/commit/a9632bc8de343aa20adf4f1123f16445f5b1b21b). +The combined run included two experimental renderer changes. The copy-back +experiment can clear a concurrent title write from write-watch before the +renderer sees it. The enlarged dynamic ring can let a direct shader read +select a temporary view. These switches are recorded to describe our +measurements. The source build ships the small-buffer threshold. `CARD_HASH_WIDE` (344 lines) and `TABLE_STAGES` (226 lines) do not apply to the candidate without larger rework. They are listed here in case you rebase onto fork main. + +## Face rendering on the separate fork build + +OctoAlgo reported visible facial skin, eyes and a closed jaw in the diner and +bar close-ups on a separate [fxceless build at `46bf535`](https://github.com/fxceless/victory-fork/tree/46bf5351707b1697c04e5d871c30973ebaa3e973). +Their build also included full [#854/#993 shader pairing](https://github.com/fxceless/victory-fork/pull/993), +[#938](https://github.com/fxceless/victory-fork/pull/938), +[#1002](https://github.com/fxceless/victory-fork/pull/1002) and +[#927](https://github.com/fxceless/victory-fork/pull/927). Face recovery was +observed with the combined renderer. The contributor did not bisect it. +[Original test report](https://github.com/ThomasHFWright/LinVxtory/pull/1) diff --git a/docs/pr995-candidate/README.md b/docs/pr995-candidate/README.md index eda6a34026b..e8dc017ce48 100644 --- a/docs/pr995-candidate/README.md +++ b/docs/pr995-candidate/README.md @@ -1,7 +1,7 @@ # PR995 Linux candidate: source and reproduction kit The public renderer pin is `7406afbbd9cef0dcddef0b0a23b4855437715eb5`. -The finished source tree is `9087a7f7796671ddec0f176aa5931be73c514624`. +The finished source tree is `2806f9ebe7de5001094b06ee6f38a5ead98b81c1`. It retains the published `91b6968` checkpoint, where a player confirmed walking, camera control, conversation and mouth movement on an Xbox Wireless Controller. The texture and scheduling update changed five files. The latest @@ -189,41 +189,17 @@ with the original source patch at commit `4331d2b`. Its matched checkpoint runs measured 5.17 FPS on the historical baseline and 5.19 FPS with PR927. [Historical source kit](https://github.com/ThomasHFWright/LinVxtory/tree/4331d2b95ab2a56af74884c1b62a2966a35588b3/docs/pr995-candidate) · [Linux integration notes](../pr927-integration.md) -## Optional frame-rate patches +## Small buffer copies in GPU memory -These patches apply to the finished source that `build.sh` leaves in -the external directory. All three switches are off by default, so a build with -none of them set behaves like the tested renderer. See [Linux notes from a second RTX 5090](../linux-notes-5090.md) -for the measurements. +The standard build includes the small-buffer threshold port from fxceless. +The default floor stays at 1 MiB. For an opt-in run, set +`VICTORY_CARD_BUFFERS_MIN_KB=64` and `VICTORY_CARD_BUFFERS_MB=1536` in the +launch environment. Smaller copies then qualify for GPU memory within the +renderer’s residency budget. The build verifies the patched source before +invoking Cargo. [Upstream threshold port](https://github.com/fxceless/victory-fork/commit/c36971b213770e48f513f0d6e3ced3f1f65a32b2) -```sh -src=../linvxtory-renderer # the directory given to build.sh -git -C "$src" apply --check docs/pr995-candidate/back-quiet.patch.txt -git -C "$src" apply docs/pr995-candidate/back-quiet.patch.txt -git -C "$src" apply --check docs/pr995-candidate/dynamic-slots.patch.txt -git -C "$src" apply docs/pr995-candidate/dynamic-slots.patch.txt -git -C "$src" apply --check docs/pr995-candidate/card-buffers-min-kb.patch.txt -git -C "$src" apply docs/pr995-candidate/card-buffers-min-kb.patch.txt -``` - -Then run the same `cargo build` command as the last line of `build.sh`, from the source directory. -Rerunning `build.sh` stops at `verify.sh`, because the patched files -no longer match the lock. - -- `back-quiet.patch.txt`: `VICTORY_BACK_QUIET=1` from - [fork PR 1188](https://github.com/fxceless/victory-fork/pull/1188) by Yorivel. - After a copy-back, the pages' write-watch bits are reset, so the copy-back's - own writes no longer count as title writes. -- `dynamic-slots.patch.txt`: `VICTORY_DYNAMIC_SLOTS=` (2^18 up to half the - heap; we use 524288). NVIDIA caps the host view heap at 1,000,000 slots, and - the 2^18 dynamic slots can run full, which drops draws. This patch enlarges - that ring and takes the extra slots from the title's slots kept in place. The - idea comes from [trustno1-coder/VIctory-NVIDIA a9632bc](https://github.com/trustno1-coder/VIctory-NVIDIA/commit/a9632bc8de343aa20adf4f1123f16445f5b1b21b). -- `card-buffers-min-kb.patch.txt`: `VICTORY_CARD_BUFFERS_MIN_KB=`, from - fxceless's [c36971b](https://github.com/fxceless/victory-fork/commit/c36971b213770e48f513f0d6e3ced3f1f65a32b2). - It lowers the 1 MiB floor for title-buffer copies in the card's memory, so - small buffers that shaders hammer stop crossing the bus. We use `64` together - with `VICTORY_CARD_BUFFERS_MB=1536`. +OctoAlgo measured the threshold on their fork and ran a combined experiment +on PR995. [RTX 5090 measurements](../linux-notes-5090.md) · [Local RTX 5090 comparison](validation.md#small-buffer-eligibility-on-an-rtx-5090) ## Linux preset and runtime diff --git a/docs/pr995-candidate/back-quiet.patch.txt b/docs/pr995-candidate/back-quiet.patch.txt deleted file mode 100644 index d94ca5f26de..00000000000 --- a/docs/pr995-candidate/back-quiet.patch.txt +++ /dev/null @@ -1,134 +0,0 @@ -diff --git a/crates/victory-gpu/src/shadow.rs b/crates/victory-gpu/src/shadow.rs -index 8e21c4871..bf1deb5b6 100644 ---- a/crates/victory-gpu/src/shadow.rs -+++ b/crates/victory-gpu/src/shadow.rs -@@ -4596,7 +4596,9 @@ impl Shadow { - // stretch is the title's as read, and a title write landing - // there since stays. - for &(off, len) in &runs { -- crate::host::write_mapped((start + at + off) as *mut u8, title[off..].as_ptr(), len); -+ if !self.put_back_quiet(start + at + off, &title[off..off + len]) { -+ crate::host::write_mapped((start + at + off) as *mut u8, title[off..].as_ptr(), len); -+ } - written += len; - } - } -@@ -4689,6 +4691,9 @@ impl Shadow { - } - count_skinned(skinned::MERGED, (start + at) as u64, (start + at + title.len()) as u64); - crate::host::shaders_write(start + at, &title[..]); -+ if self.put_back_quiet(start + at, &title[..]) { -+ return n; -+ } - if self.put_back_own(start + at, &title[..]) { - return n; - } -@@ -4698,6 +4703,66 @@ impl Shadow { - n - } - -+ /// With `VICTORY_BACK_QUIET=1`: what a merge made of private, -+ /// write-watched title memory `[at, at + bytes.len())` is written as -+ /// before, then the kernel's write-watch bits of those pages are reset, -+ /// so the write does not read as the title's; the journal is told the -+ /// pages changed (as [`Self::put_back_own`] does for view memory), so -+ /// every other copy that holds them takes them again, and this copy, -+ /// which holds them already, notes itself current instead of taking -+ /// its own output in again. The read census on the fork (#1169) found -+ /// about 92% of the layer's touches of copied-back pages were that. -+ /// False with nothing written if the switch is off, the pages are not -+ /// write-watched, or the title wrote one of them since the last asking -+ /// (its bit would be reset too): the caller writes as before. -+ /// shortcut: a title write to one of the pages between the write and -+ /// the reset is lost to the write-watch. -+ fn put_back_quiet(&self, at: usize, bytes: &[u8]) -> bool { -+ use windows_sys::Win32::System::Memory::{GetWriteWatch, ResetWriteWatch}; -+ if !quiet_back() || bytes.is_empty() { -+ return false; -+ } -+ let first = at & !4095; -+ let end = (at + bytes.len()).next_multiple_of(4096); -+ let mut found = [std::ptr::null_mut::(); 32]; -+ let mut count = found.len(); -+ let mut granularity = 0u32; -+ // SAFETY: a query of title memory into arrays of ours. -+ let asked = unsafe { -+ GetWriteWatch(0, first as _, end - first, found.as_mut_ptr(), &mut count, &mut granularity) -+ }; -+ if asked != 0 || count != 0 { -+ QUIET[1].fetch_add(1, Ordering::Relaxed); -+ return false; -+ } -+ crate::watch::writing(at, bytes.len()); -+ crate::host::write_mapped(at as *mut u8, bytes.as_ptr(), bytes.len()); -+ // SAFETY: the same write-watched pages. -+ unsafe { ResetWriteWatch(first as _, end - first) }; -+ crate::descriptor::host::remapped(at, bytes.len()); -+ let base = self.start as usize / PAGE; -+ for page in at / PAGE..(at + bytes.len()).div_ceil(PAGE) { -+ let (before, now) = crate::watch::wrote_own(page, &[]); -+ let mut copied = self.copied.lock().unwrap_or_else(|e| e.into_inner()); -+ if let Some(taken) = page.checked_sub(base).and_then(|i| copied.get_mut(i)) -+ && *taken != 0 -+ && *taken >= before -+ { -+ *taken = (*taken).max(now); -+ } -+ } -+ QUIET[0].fetch_add(bytes.len() as u64, Ordering::Relaxed); -+ let n = QUIET[2].fetch_add(1, Ordering::Relaxed) + 1; -+ if n.is_multiple_of(16384) { -+ tracing::info!( -+ "copy-backs written quietly (VICTORY_BACK_QUIET=1) since the start: {n} stretches {} MB; written the old way (not write-watched, or the title had written there): {}", -+ QUIET[0].load(Ordering::Relaxed) >> 20, -+ QUIET[1].load(Ordering::Relaxed) -+ ); -+ } -+ true -+ } -+ - /// With `crate::inplace::back_own` (`VICTORY_BACK_OWN_VIEW=1`): stores - /// what a merge made of title memory `[at, at + bytes.len())` (inside - /// one 64 KiB page, as every merged stretch is) through a view of our -@@ -6025,9 +6090,11 @@ impl Shadow { - if differs != 0 { - count_skinned(skinned::MERGED, (start + at) as u64, (start + at + title.len()) as u64); - crate::host::shaders_write(start + at, &title[..]); -- crate::watch::writing_exact(start + at, n); -- merge_race(as_read.as_deref(), (self.start, self.len), start + at, &title[..], "card"); -- crate::host::write_mapped((start + at) as *mut u8, title.as_ptr(), n); -+ if !self.put_back_quiet(start + at, &title[..]) { -+ crate::watch::writing_exact(start + at, n); -+ merge_race(as_read.as_deref(), (self.start, self.len), start + at, &title[..], "card"); -+ crate::host::write_mapped((start + at) as *mut u8, title.as_ptr(), n); -+ } - written = n; - } - } else { -@@ -6117,6 +6184,9 @@ impl Shadow { - } - count_skinned(skinned::MERGED, (start + at) as u64, (start + at + title.len()) as u64); - crate::host::shaders_write(start + at, &title[..]); -+ if self.put_back_quiet(start + at, &title[..]) { -+ return n; -+ } - if self.put_back_own(start + at, &title[..]) { - return n; - } -@@ -6487,6 +6557,16 @@ fn window_of(address: u64, end: u64, grid: u64) -> (u64, u64) { - /// together with `VICTORY_WINDOW_KB` below 4096: on the 4 MiB grid an ask - /// with a length in the same cell makes the whole cell's window, and the - /// tail is that. -+/// `VICTORY_BACK_QUIET=1`: see [`Shadow::put_back_quiet`]. Off by default. -+fn quiet_back() -> bool { -+ static ON: std::sync::OnceLock = std::sync::OnceLock::new(); -+ *ON.get_or_init(|| std::env::var_os("VICTORY_BACK_QUIET").is_some_and(|v| v == "1")) -+} -+ -+/// Quiet copy-backs since the start: bytes, stretches written the old way, -+/// stretches written quietly. -+static QUIET: [AtomicU64; 3] = [const { AtomicU64::new(0) }; 3]; -+ - fn tails() -> bool { - static ON: std::sync::OnceLock = std::sync::OnceLock::new(); - *ON.get_or_init(|| std::env::var_os("VICTORY_WINDOW_TAILS").is_some_and(|v| v == "1")) diff --git a/docs/pr995-candidate/card-buffers-files.json b/docs/pr995-candidate/card-buffers-files.json new file mode 100644 index 00000000000..ec38c8a45a2 --- /dev/null +++ b/docs/pr995-candidate/card-buffers-files.json @@ -0,0 +1,3 @@ +{ + "crates/victory-gpu/src/shadow.rs": "e2138ce61a669dcce5b756dd6a85d464c2f8b5a845fe57e22908bb8aaba19620" +} diff --git a/docs/pr995-candidate/card-buffers-min-kb.patch.txt b/docs/pr995-candidate/card-buffers-min-kb.patch.txt index bee2201230d..17921611f43 100644 --- a/docs/pr995-candidate/card-buffers-min-kb.patch.txt +++ b/docs/pr995-candidate/card-buffers-min-kb.patch.txt @@ -1,8 +1,6 @@ -diff --git a/crates/victory-gpu/src/shadow.rs b/crates/victory-gpu/src/shadow.rs -index 8a0ab5807..0d86e5608 100644 --- a/crates/victory-gpu/src/shadow.rs +++ b/crates/victory-gpu/src/shadow.rs -@@ -188,7 +188,21 @@ fn card_limits() -> (u64, u64) { +@@ -188,7 +188,27 @@ // the shader writes of the smaller buffers are then found by the // card's hashes too, and with that the first room's walls were // drawn in every run. @@ -14,10 +12,16 @@ index 8a0ab5807..0d86e5608 100644 + // store and atomic a shader does on them crosses the bus. What it + // costs: 64 KiB of the card's memory a copy, and as much again for + // one that shaders write (fxceless/victory-fork c36971b). -+ let least = match std::env::var("VICTORY_CARD_BUFFERS_MIN_KB").ok().and_then(|v| v.trim().parse::().ok()) { -+ Some(kib) if kib > 0 => { -+ tracing::info!(kib, "title buffers from this size get copies in the card's memory (VICTORY_CARD_BUFFERS_MIN_KB)"); -+ kib << 10 ++ let least_kib = std::env::var("VICTORY_CARD_BUFFERS_MIN_KB") ++ .ok() ++ .and_then(|v| v.trim().parse::().ok()); ++ let least = match least_kib.and_then(|kib| kib.checked_mul(1024)) { ++ Some(bytes) if bytes > 0 => { ++ tracing::info!( ++ kib = bytes / 1024, ++ "title buffers from this size are eligible for copies in the card's memory (VICTORY_CARD_BUFFERS_MIN_KB)" ++ ); ++ bytes + } + _ => mb("VICTORY_CARD_BUFFERS_MIN_MB", 1).max(1 << 20), + }; diff --git a/docs/pr995-candidate/check_inputs.py b/docs/pr995-candidate/check_inputs.py index c28c0bb4d1c..d95e08cc361 100644 --- a/docs/pr995-candidate/check_inputs.py +++ b/docs/pr995-candidate/check_inputs.py @@ -7,8 +7,8 @@ kit = Path(__file__).resolve().parent source = Path(sys.argv[1]) expected = json.loads((kit / 'source-lock.json').read_text())['source_files_sha256'] -if len(sys.argv) == 3: - expected.update(json.loads(Path(sys.argv[2]).read_text())) +for overlay in sys.argv[2:]: + expected.update(json.loads(Path(overlay).read_text())) extra = {str(p.relative_to(source)) for folder in ('apps', 'crates', '.cargo') for p in (source / folder).rglob('*') if p.is_file()} - expected.keys() diff --git a/docs/pr995-candidate/dynamic-slots.patch.txt b/docs/pr995-candidate/dynamic-slots.patch.txt deleted file mode 100644 index 253767e7a7e..00000000000 --- a/docs/pr995-candidate/dynamic-slots.patch.txt +++ /dev/null @@ -1,63 +0,0 @@ -diff --git a/crates/victory-gpu/src/descriptor/host.rs b/crates/victory-gpu/src/descriptor/host.rs -index c215b2cb4..896de448b 100644 ---- a/crates/victory-gpu/src/descriptor/host.rs -+++ b/crates/victory-gpu/src/descriptor/host.rs -@@ -942,6 +942,20 @@ pub(crate) fn probe_view_limit() { - /// table past them is made afresh in these slots like any other. - pub(crate) const DYNAMIC: u32 = 1 << 18; - -+/// The dynamic slots of a capped view heap whose null slot is `null` -+/// (`VICTORY_DYNAMIC_SLOTS`, read once; [`DYNAMIC`] when unset). -+fn dynamic_slots_capped(null: u32) -> u32 { -+ static SLOTS: std::sync::OnceLock = std::sync::OnceLock::new(); -+ *SLOTS.get_or_init(|| { -+ let asked = std::env::var("VICTORY_DYNAMIC_SLOTS").ok().and_then(|v| v.trim().parse::().ok()); -+ let slots = asked.map_or(DYNAMIC, |n| n.clamp(DYNAMIC, (null / 2).max(DYNAMIC))); -+ if slots != DYNAMIC { -+ tracing::info!(slots, title_slots_in_place = null - slots, "dynamic view slots on a capped host heap (VICTORY_DYNAMIC_SLOTS)"); -+ } -+ slots -+ }) -+} -+ - impl HostHeap { - pub(crate) fn new(sampler: bool, count: u32) -> Option { - let host = host()?; -@@ -974,6 +988,17 @@ impl HostHeap { - } else { - victory_shader::emit::view_heap_limit() - }; -+ // After trustno1-coder/VIctory-NVIDIA a9632bc's finding: on a host that caps view heaps (NVIDIA: 1,000,000 for -+ // the title's 1,245,184) the title's slots past the cap are not kept in -+ // place anyway, and the ring of dynamic slots (2^18) can run full: a -+ // table that finds no room is a dropped draw. `VICTORY_DYNAMIC_SLOTS=` -+ // gives the ring n slots there (at least 2^18, at most half the heap), -+ // taken from the title's slots kept in place. Unset: as before. -+ let extra = if !sampler && null != 0 && count + extra > null { -+ dynamic_slots_capped(null) -+ } else { -+ extra -+ }; - let (heap, count, size) = if null == 0 { - match make(count + extra) { - Ok(heap) => (heap, count, count + extra), -@@ -1052,8 +1077,8 @@ impl HostHeap { - .map(|_| std::sync::atomic::AtomicU64::new(0)) - .collect(), - kept: Mutex::new(vec![None; (count + extra) as usize]), -- next: Mutex::new((0, vec![false; DYNAMIC as usize])), -- free: std::sync::atomic::AtomicU32::new(DYNAMIC), -+ next: Mutex::new((0, vec![false; if sampler { DYNAMIC } else { extra } as usize])), -+ free: std::sync::atomic::AtomicU32::new(if sampler { DYNAMIC } else { extra }), - too_long: std::sync::atomic::AtomicU32::new(u32::MAX), - strides, - buffers: Mutex::default(), -@@ -1197,7 +1222,7 @@ impl HostHeap { - crate::copystat::add(crate::copystat::C::DynamicNs, started.elapsed().as_nanos() as u64); - taken[first..first + n].fill(true); - self.free.fetch_sub(n as u32, std::sync::atomic::Ordering::Relaxed); -- *next = ((first + n) % DYNAMIC as usize) as u32; -+ *next = ((first + n) % self.dynamic.max(1) as usize) as u32; - Some(self.count + first as u32) - } - diff --git a/docs/pr995-candidate/validation.md b/docs/pr995-candidate/validation.md index a89614e50f3..db0deb8791c 100644 --- a/docs/pr995-candidate/validation.md +++ b/docs/pr995-candidate/validation.md @@ -38,15 +38,17 @@ OctoAlgo's unpublished combined renderer. ## Updated source verification The public pin is `7406afbbd9cef0dcddef0b0a23b4855437715eb5`. All rebuild -and upgrade paths must reach Git tree `9087a7f7796671ddec0f176aa5931be73c514624`. -The final lock contains 190 full-file digests when the 13 final overrides are -combined with the 188-input Linux baseline. [Original lock](source-lock.json) · [Final overrides](followup-files.json) +and upgrade paths must reach Git tree `2806f9ebe7de5001094b06ee6f38a5ead98b81c1`. +The final lock verifies 190 full-file digests. The small-buffer overlay +replaces the digest for the already tracked `shadow.rs`. +[Original lock](source-lock.json) · [Previous overrides](followup-files.json) · [Small-buffer overlay](card-buffers-files.json) | Layer | Source tree after applying | Patch SHA-256 | | --- | --- | --- | | Published three-PR checkpoint `91b6968` | `cc6e33fe99572a2d433e82a49e8429678b70ca5a` | `c47ca445f08f13a27d4b9b9a98b4d4e0d22ed510613ca4ad1bd50836c48b28c2` | | Five-file follow-up `f0ca006` | `0c158597c6af5254c2d29422bda9ddd9b6b34065` | `fb1113a16121e61d9ec59e3cbcf5f01b05b01f684935c453417fe4616cc596ac` | | Three-file performance follow-up | `9087a7f7796671ddec0f176aa5931be73c514624` | `2bd39cdda0174091632022ad0e075510beaa91014fa397cd6d12932fba025d36` | +| Small-buffer eligibility | `2806f9ebe7de5001094b06ee6f38a5ead98b81c1` | `d1e5ea6eafafc6794fb6903b768eb5fc80cfa12b5f97e37f6a6f944b9c1fafd0` | The five-file patch changes `crates/victory-gpu/src/descriptor/host.rs`, `shadow.rs` and `texture.rs` in the GPU crate, and `lower.rs` and `mod.rs` in @@ -59,6 +61,26 @@ verifies the Linux baseline and the published checkpoint in sequence. Each verif checkout keeps its source intact. Extra arguments and edited build inputs were rejected before Cargo in the packaging checks. +### Small-buffer eligibility on an RTX 5090 + +Two cold replays used the same Windows diagnostics build, indexed GE-Proton +11-14, checkpoint, scripted inputs and 1536 MiB buffer-copy budget. Each run +used a separate cache. The sample contains presents 301–600 after the first +world shader bind. + +| Eligibility floor | FPS | Median present interval | 95th percentile | Peak GPU-resident buffer copies | +| --- | ---: | ---: | ---: | ---: | +| 1 MiB (default) | 2.61 | 330 ms | 687 ms | 98 | +| 64 KiB | 3.24 | 272.5 ms | 498 ms | 3,726 | + +The observed difference was 0.63 FPS (+24%) in this part of the replay. +The 64 KiB run presented more slowly during the first 90 seconds after the +bind (0.64 FPS vs 1.14 FPS). Both runs showed the same cell, with the wire +mesh and yard visible in overlapping views. Over the sample, the default run +turned toward the door and bunks, while the 64 KiB run remained window-facing. +The different visual workload limits what this pair can say about the setting's +effect. The 1 MiB floor remains the default. [Contributor measurements on the separate fork](../linux-notes-5090.md) + ### Published checkpoint provenance The controller-tested `three-pr.exe` from checkpoint `91b6968` has SHA-256 diff --git a/docs/pr995-candidate/verify.sh b/docs/pr995-candidate/verify.sh index 941e80d2f02..4213fe455de 100644 --- a/docs/pr995-candidate/verify.sh +++ b/docs/pr995-candidate/verify.sh @@ -5,4 +5,4 @@ if [ "$#" -ne 1 ] || [ -z "$1" ]; then exit 1 fi kit=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) -exec python3 "$kit/check_inputs.py" "$1" "$kit/followup-files.json" +exec python3 "$kit/check_inputs.py" "$1" "$kit/followup-files.json" "$kit/card-buffers-files.json" From 18a103ae61b981b8776aa7515e4c735cb40a236f Mon Sep 17 00:00:00 2001 From: Thomas Wright Date: Thu, 26 Nov 2026 14:03:51 +0000 Subject: [PATCH 6/6] Trim empty patch context for source-kit checks --- docs/pr995-candidate/card-buffers-min-kb.patch.txt | 4 +--- docs/pr995-candidate/validation.md | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/pr995-candidate/card-buffers-min-kb.patch.txt b/docs/pr995-candidate/card-buffers-min-kb.patch.txt index 17921611f43..6a9994f38cf 100644 --- a/docs/pr995-candidate/card-buffers-min-kb.patch.txt +++ b/docs/pr995-candidate/card-buffers-min-kb.patch.txt @@ -1,7 +1,6 @@ --- a/crates/victory-gpu/src/shadow.rs +++ b/crates/victory-gpu/src/shadow.rs -@@ -188,7 +188,27 @@ - // the shader writes of the smaller buffers are then found by the +@@ -189,5 +189,25 @@ // card's hashes too, and with that the first room's walls were // drawn in every run. - (mb("VICTORY_CARD_BUFFERS_MIN_MB", 1).max(1 << 20), mb("VICTORY_CARD_BUFFERS_MB", 1024)) @@ -28,4 +27,3 @@ + (least, mb("VICTORY_CARD_BUFFERS_MB", 1024)) }) } - diff --git a/docs/pr995-candidate/validation.md b/docs/pr995-candidate/validation.md index db0deb8791c..3abdd776d19 100644 --- a/docs/pr995-candidate/validation.md +++ b/docs/pr995-candidate/validation.md @@ -48,7 +48,7 @@ replaces the digest for the already tracked `shadow.rs`. | Published three-PR checkpoint `91b6968` | `cc6e33fe99572a2d433e82a49e8429678b70ca5a` | `c47ca445f08f13a27d4b9b9a98b4d4e0d22ed510613ca4ad1bd50836c48b28c2` | | Five-file follow-up `f0ca006` | `0c158597c6af5254c2d29422bda9ddd9b6b34065` | `fb1113a16121e61d9ec59e3cbcf5f01b05b01f684935c453417fe4616cc596ac` | | Three-file performance follow-up | `9087a7f7796671ddec0f176aa5931be73c514624` | `2bd39cdda0174091632022ad0e075510beaa91014fa397cd6d12932fba025d36` | -| Small-buffer eligibility | `2806f9ebe7de5001094b06ee6f38a5ead98b81c1` | `d1e5ea6eafafc6794fb6903b768eb5fc80cfa12b5f97e37f6a6f944b9c1fafd0` | +| Small-buffer eligibility | `2806f9ebe7de5001094b06ee6f38a5ead98b81c1` | `072321b791027cfcf33e768951ce6a64368d3bce33da05756756885ffbc7001a` | The five-file patch changes `crates/victory-gpu/src/descriptor/host.rs`, `shadow.rs` and `texture.rs` in the GPU crate, and `lower.rs` and `mod.rs` in