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:
1 parent
310c6eb6c1
commit
8dd30ab472
25 files changed
+4218
-240
No files matched your search
@@ -353,7 +353,11 @@ struct Views {
|
||||
shape_index: std::collections::BTreeMap<Shape, u32>,
|
||||
}
|
||||
|
||||
static VIEWS: std::sync::Mutex<Views> = std::sync::Mutex::new(Views {
|
||||
/// Read far more often than written: every slot a draw reads through a
|
||||
/// table is looked up here, on several recording threads at once in the
|
||||
/// world. Readers share it; only a view not seen before (a new table entry
|
||||
/// or shape) and a released resource take it alone.
|
||||
static VIEWS: std::sync::RwLock<Views> = std::sync::RwLock::new(Views {
|
||||
list: Vec::new(),
|
||||
index: std::collections::BTreeMap::new(),
|
||||
by_resource: std::collections::BTreeMap::new(),
|
||||
@@ -480,6 +484,12 @@ impl Views {
|
||||
Some(View::Placed(unordered, resource, desc))
|
||||
}
|
||||
|
||||
/// The record words of `view` as a table entry, if it has one.
|
||||
fn entry_of(&self, view: &View) -> Option<[u32; 2]> {
|
||||
let &i = self.index.get(view)?;
|
||||
Some([i, self.list[i as usize].1])
|
||||
}
|
||||
|
||||
/// The record words of `view` as a table entry: its entry (a new or a
|
||||
/// freed one if the view is not there yet) and that entry's generation.
|
||||
fn entry(&mut self, view: View) -> [u32; 2] {
|
||||
@@ -522,8 +532,10 @@ fn words_for(view: View) -> [u32; 2] {
|
||||
View::Placed(unordered, resource, desc) => {
|
||||
let (shape, address) = shape_of(*unordered, resource, desc);
|
||||
if address >> PLACED_ADDRESS_BITS == 0 {
|
||||
let mut views = VIEWS.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if let Some(shape) = views.shape(shape) {
|
||||
// Nearly every placed view has a shape seen before.
|
||||
let known = views_read().shape_index.get(&shape).copied();
|
||||
let shape = known.or_else(|| views_write().shape(shape));
|
||||
if let Some(shape) = shape {
|
||||
NAMED_WHOLE[1].fetch_add(1, Relaxed);
|
||||
return placed_words(shape, address);
|
||||
}
|
||||
@@ -532,7 +544,19 @@ fn words_for(view: View) -> [u32; 2] {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
VIEWS.lock().unwrap_or_else(|e| e.into_inner()).entry(view)
|
||||
// A view written before keeps its entry and generation.
|
||||
if let Some(words) = views_read().entry_of(&view) {
|
||||
return words;
|
||||
}
|
||||
views_write().entry(view)
|
||||
}
|
||||
|
||||
fn views_read() -> std::sync::RwLockReadGuard<'static, Views> {
|
||||
VIEWS.read().unwrap_or_else(|e| e.into_inner())
|
||||
}
|
||||
|
||||
fn views_write() -> std::sync::RwLockWriteGuard<'static, Views> {
|
||||
VIEWS.write().unwrap_or_else(|e| e.into_inner())
|
||||
}
|
||||
|
||||
/// For the memory line: the distinct views kept ([`Views`]), those of them
|
||||
@@ -546,7 +570,7 @@ fn words_for(view: View) -> [u32; 2] {
|
||||
#[cfg(all(windows, feature = "diagnostics"))]
|
||||
pub(crate) fn views_kept() -> [u64; 8] {
|
||||
use std::sync::atomic::Ordering::Relaxed;
|
||||
let views = VIEWS.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let views = views_read();
|
||||
let each = size_of::<(View, u32)>() as u64;
|
||||
let shape = size_of::<Shape>() as u64;
|
||||
let (mut constants, mut placed) = (0, 0);
|
||||
@@ -697,7 +721,7 @@ pub(crate) fn forget(resource: usize) {
|
||||
.lock()
|
||||
.unwrap_or_else(|e| e.into_inner())
|
||||
.remove(&resource);
|
||||
let mut views = VIEWS.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let mut views = views_write();
|
||||
let Some(entries) = views.by_resource.remove(&resource) else {
|
||||
return;
|
||||
};
|
||||
@@ -722,12 +746,12 @@ pub(crate) fn forget(resource: usize) {
|
||||
fn view_at(i: u32, generation: u32) -> Option<View> {
|
||||
match generation >> KIND_SHIFT {
|
||||
0 => {
|
||||
let views = VIEWS.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let views = views_read();
|
||||
let (view, current) = views.list.get(i as usize)?;
|
||||
(*current == generation).then(|| view.clone())
|
||||
}
|
||||
CONSTANT => Some(constant_of(i, generation)),
|
||||
PLACED => VIEWS.lock().unwrap_or_else(|e| e.into_inner()).placed_of(i, generation),
|
||||
PLACED => views_read().placed_of(i, generation),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -1104,8 +1128,8 @@ mod tests {
|
||||
View::Placed(_, r, _) => *r == resource,
|
||||
_ => false,
|
||||
};
|
||||
let entries = || VIEWS.lock().unwrap().list.iter().filter(|(v, _)| mine(v)).count();
|
||||
let shapes = || VIEWS.lock().unwrap().shapes.iter().filter(|s| s.1 == resource).count();
|
||||
let entries = || VIEWS.read().unwrap().list.iter().filter(|(v, _)| mine(v)).count();
|
||||
let shapes = || VIEWS.read().unwrap().shapes.iter().filter(|s| s.1 == resource).count();
|
||||
for n in 0..20_000u64 {
|
||||
let address = 0x6_0000_0000 + n * 0x100;
|
||||
create_cbv(null, &[address as u32, (address >> 32) as u32, 512, 0], at);
|
||||
|
||||
Reference in new issue
Block a user