A write through one view of a page is seen at its other views; page writes counted; levels on demand (off); warm-up; card memory numbers

Memory sync:
- The guard over every view of a physical page (code by myokex, victory-amd
  c6dc4d8, after pull request #115 by Spexivus, its correction by joroyt and
  a part of VIctory #1122 by tightfall): the title shows one page at several
  addresses and a copy was guarded at one only. 0.8 to 1.0 million writes
  through another view in a five-minute run on the test machine.
  VICTORY_VIEW_GUARD=0 turns it off.
- Kernel reads into title memory are read beside and copied in (Joshua Odom,
  10ea38e).
- Writes of the storage layer into physical pages are counted where the
  title has the pages mapped and can open the guards there
  (VICTORY_PAGE_WRITES, off: counted only). Failed page-destination reads
  are retried.

Card memory:
- Levels on demand, off unless VICTORY_LEVELS_ON_DEMAND=1: a texture the
  title fills takes card memory for the levels the title holds; held levels
  get memory only while the card has room and are asked for again. Its test
  runs on the software adapter; not run on a card yet.
- Refused texture slots are held back so a pass reaches the slots behind
  them; room can be kept for card copies of title buffers (off).

Tools: translate --warm all; the shader cache is keyed on the translator's
source; counters for copy-back races, page writes and the copies the
texture sweep never lets go; a walls trace.

Game runs of these changes on an RTX 4070: five five-minute runs without a
device loss or a failed request. This merged tree was built; its test
suites were run on the tree the changes come from (gpu 129, hle 97).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
fxcelessandClaude Fable 5.2 committed 2026-11-25 00:44:25 -05:00
1 parent 8d3ce0190f
commit 847a0af35e
25 files changed
+4218 -240

No files matched your search

+46 -5
View File
@@ -385,6 +385,20 @@ pub(crate) static HEAP_TEXTURES_RECHECKED: [AtomicU64; 2] = [AtomicU64::new(0),
/// new ones, since the start.
pub(crate) static HEAP_TEXTURES_REUPLOADED_FULL: AtomicU64 = AtomicU64::new(0);
/// Whether a pass over the textures picked by index on a full card holds
/// back the slots that need a new host copy (`VICTORY_FULL_CARD_PASS=0`:
/// no, as before: they stay due, each pass looks at the same ones again
/// and stops at the 257th). Held back, such a slot is looked at again
/// after about four seconds or as soon as the card has room, and the pass
/// goes on to the slots behind it: the ones whose host copy exists and
/// only wants bringing up to date, and the ones whose memory went (letting
/// their host copies go is what makes room). What is uploaded while the
/// card has room is the same either way.
fn full_card_pass() -> bool {
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
*ON.get_or_init(|| std::env::var_os("VICTORY_FULL_CARD_PASS").is_none_or(|v| v != "0"))
}
/// Whether a texture that has its host copy is still brought up to date
/// while the card has no room for new ones (`VICTORY_REUPLOAD_WHEN_FULL=0`:
/// no).
@@ -1587,7 +1601,10 @@ impl State {
static NEXT: AtomicU64 = AtomicU64::new(0);
let now = crate::host::now_ms().max(1);
let next = NEXT.load(Ordering::Relaxed);
let due_now = if next == 0 { !room } else { now >= next };
// (With levels on demand the card may never be without room: the
// lines then start with the first texture made that way.)
let by_level = crate::tiles::STATS[4].load(Ordering::Relaxed) > 0;
let due_now = if next == 0 { !room || by_level } else { now >= next };
if !due_now || NEXT.compare_exchange(next, now + 5000, Ordering::Relaxed, Ordering::Relaxed).is_err() {
return;
}
@@ -1687,9 +1704,22 @@ impl State {
once!("textures picked by index: the card has no room for more; they wait");
}
let mut refused = 0;
// Room again: the slots held back while the card was full are due
// now (`full_card_pass`).
if room {
host.texture_slots_room(frame);
}
// Slots whose texture's memory the runtime mapped, unmapped or
// wrote since the last pass are due again.
host.texture_slots_remapped(frame);
// Levels on demand: the slots of textures whose first level with
// memory changed since the last pass are made again from it.
host.texture_views_remade();
// And with room, the textures whose upload left a held level
// without the card's memory are uploaded again.
if room {
host.texture_slots_waiting(frame);
}
let (due, census) = host.texture_slots_due(frame, 4096);
HEAP_TEXTURES_WAITING.store(census[0], Ordering::Relaxed);
for (count, now) in HEAP_TEXTURES_QUEUE.iter().zip(census) {
@@ -1844,7 +1874,15 @@ impl State {
&& heap.handle(index).is_some_and(|handle| host.texture_slot_made_from(index, handle));
if !has_its_texture {
refused += 1;
if refused > 256 {
if full_card_pass() {
// Held back for the frames of about four seconds
// (`most`), or until the card has room; the pass
// goes on, within a count that bounds one pass.
host.texture_slot_held(index, write, frame + most);
if refused > 1024 {
break;
}
} else if refused > 256 {
break;
}
continue;
@@ -3258,13 +3296,16 @@ fn view_state(view: Option<&View>) -> String {
memory_state(address, crate::resource::placed_bytes(r).unwrap_or(0))
),
};
format!("placed texture view_format={} {state}", d[0])
// (Last, so that readers of the older lines still find
// theirs: the level the view starts at, and how many it shows.)
format!("placed texture view_format={} {state} view_levels={}+{}", d[0], d[4], d[5] as i32)
}
Some(View::Shader(r, d)) if crate::resource::texture_memory(*r as This).is_some() => {
format!(
"texture object {r:#x} view_format={} {}",
"texture object {r:#x} view_format={} {} view_levels={}",
d.as_ref().map_or(0, |d| d[0]),
texture_state(*r as This)
texture_state(*r as This),
d.as_ref().map_or("all".to_owned(), |d| format!("{}+{}", d[4], d[5] as i32))
)
}
Some(v) => format!("{v:?}").chars().take(80).collect(),