VICTORY_SHOW_NEW_LATER=1: slots show a texture made while earlier lists run only once those ran (off)

Ported from Belobug/VIctory-Belobug-AMD 4cd2d13 and 91018a5, where it is on
by default. Every device loss with the texture pool in that fork's report
(n08, n11, n15, steps-ab2, start-3, a user's play-1125-2107 without ray
tracing) was a page fault at the first byte of a texture in a block made
that millisecond, its title slot changed "at once" (`mirror`) while lists
sent before read that slot by index; VICTORY_SHOW_AFTER covers only some
paths (a draw's table, the texture pass's own uploads). We run the pool.

With the switch, `HostHeap::mirror` holds a slot whose new view shows a
pooled texture made while a submission begun before it may still run
(`pool::begun_before`: the submissions begun when it was made, noted in
`pool::made_now`) on what it showed, or the neutral texture if that cannot
stand for it (`keep_shown`), and flips it when every such submission has
finished (`FLIPS`, `texture_slots_flip`); a slot held back is held once, not
again at each draw or pass that reads it (`NEW_PENDING`, 91018a5). A line
says how many slots were held back since the start (with the switch on).
Also an A/B switch in diag builds (VICTORY_AB).

Off by default (not behaviour-neutral: a slot shows its new texture one or
more submissions later); with it off, `made_now` notes nothing more than
before and nothing else changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
readmet3xt-labandClaude Opus 5.5 committed 2026-11-27 01:08:54 +05:30
1 parent 185bc4cc84
commit ee3fb5201a
3 files changed
+156 -4

No files matched your search

+50 -4
View File
@@ -568,11 +568,57 @@ pub(crate) fn fresh(texture: &ID3D12Resource) -> bool {
fn made_now(texture: &ID3D12Resource) {
let now = now();
let mut recent = RECENT.lock().unwrap_or_else(|e| e.into_inner());
while recent.front().is_some_and(|r| r.1 + 1000 < now) {
recent.pop_front();
let raw = texture.as_raw() as usize;
{
let mut recent = RECENT.lock().unwrap_or_else(|e| e.into_inner());
while recent.front().is_some_and(|r| r.1 + 1000 < now) {
recent.pop_front();
}
recent.push_back((raw, now));
}
recent.push_back((texture.as_raw() as usize, now));
if !crate::descriptor::host::show_new_later() {
return;
}
let begun = crate::host::submissions().0;
NEWEST_BEGUN.fetch_max(begun, Ordering::Relaxed);
let mut unseen = UNSEEN.lock().unwrap_or_else(|e| e.into_inner());
let finished = crate::host::submissions().1;
// Those every submission begun before them has left behind are no
// one's concern any more (and a raw pointer may come again).
unseen.retain(|_, b| *b > finished);
unseen.insert(raw, begun);
}
/// Pooled textures made while submissions begun before them may still run:
/// the submissions begun when each was made (with
/// `crate::descriptor::host::show_new_later` only). Ported from
/// Belobug/VIctory-Belobug-AMD 4cd2d13.
static UNSEEN: std::sync::LazyLock<Mutex<std::collections::HashMap<usize, u64>>> = std::sync::LazyLock::new(Default::default);
/// The newest of those numbers (nothing to look up once it has finished).
static NEWEST_BEGUN: AtomicU64 = AtomicU64::new(0);
/// Whether a texture was made in a block while a submission begun before
/// it may still run ([`begun_before`]).
fn any_unseen() -> bool {
NEWEST_BEGUN.load(Ordering::Relaxed) > crate::host::submissions().1
}
/// The submissions begun when `texture` was made in a block, if one of
/// those may still be on the card: lists already sent then must not find it
/// in a slot they read by index (`crate::descriptor::host::show_new_later`).
/// Every device loss with the pool in the report of
/// Belobug/VIctory-Belobug-AMD (runs n08, n11, n15, steps-ab2, start-3 and a
/// user's play-1125-2107) was a page fault at the first byte of a texture
/// made that very millisecond, its title slot changed "at once" while lists
/// sent before it read that slot by index.
pub(crate) fn begun_before(texture: &ID3D12Resource) -> Option<u64> {
if !any_unseen() {
return None;
}
let finished = crate::host::submissions().1;
let raw = texture.as_raw() as usize;
let unseen = UNSEEN.lock().unwrap_or_else(|e| e.into_inner());
unseen.get(&raw).copied().filter(|&begun| begun > finished)
}
/// Makes `texture` give `piece` back when the last reference to it goes.