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
8d3ce0190f
commit
847a0af35e
25 files changed
+4218
-240
No files matched your search
@@ -267,11 +267,17 @@ pub(crate) fn place(device: &ID3D12Device, heap: &ID3D12Heap, offset: u64, size:
|
||||
struct Views {
|
||||
/// By address: bytes, the section's handle, the offset in it.
|
||||
views: BTreeMap<usize, (usize, usize, u64)>,
|
||||
/// By section and byte offset of a 64 KiB page: the address of that
|
||||
/// page in every view that shows it. A write through one view of a
|
||||
/// page is a write of the bytes every other view shows
|
||||
/// (`crate::watch` guards them all).
|
||||
pages: BTreeMap<(usize, u64), Vec<usize>>,
|
||||
/// Sections by handle: bytes, and whether made committed.
|
||||
sections: Vec<(usize, u64, bool)>,
|
||||
}
|
||||
|
||||
static VIEWS: Mutex<Views> = Mutex::new(Views { views: BTreeMap::new(), sections: Vec::new() });
|
||||
static VIEWS: Mutex<Views> =
|
||||
Mutex::new(Views { views: BTreeMap::new(), pages: BTreeMap::new(), sections: Vec::new() });
|
||||
|
||||
fn views() -> std::sync::MutexGuard<'static, Views> {
|
||||
VIEWS.lock().unwrap_or_else(|e| e.into_inner())
|
||||
@@ -288,7 +294,17 @@ pub fn title_memory_section(section: usize, bytes: u64, committed: bool) {
|
||||
/// The runtime mapped `[at, at + len)` as a view of `section` from
|
||||
/// `offset` on. Call after [`crate::title_memory_remapped`] of the range.
|
||||
pub fn title_memory_view(at: usize, len: usize, section: usize, offset: u64) {
|
||||
views().views.insert(at, (len, section, offset));
|
||||
{
|
||||
let mut v = views();
|
||||
v.views.insert(at, (len, section, offset));
|
||||
for k in 0..len.div_ceil(K64) {
|
||||
v.pages.entry((section, offset + (k * K64) as u64)).or_default().push(at + k * K64);
|
||||
}
|
||||
}
|
||||
// This view is writable from now on: a guard over the same bytes at
|
||||
// another view must look at them again, and the pages are noted written
|
||||
// there (`crate::watch`).
|
||||
crate::watch::views_mapped(section, offset, len);
|
||||
}
|
||||
|
||||
/// What `[at, at + len)` showed is gone ([`crate::title_memory_remapped`]):
|
||||
@@ -303,10 +319,88 @@ pub(crate) fn views_gone(at: usize, len: usize) {
|
||||
let first = v.views.range(..=at).next_back().filter(|(base, view)| *base + view.0 > at).map(|(base, _)| *base);
|
||||
let gone: Vec<usize> = first.into_iter().chain(v.views.range(at.saturating_add(1)..end).map(|(base, _)| *base)).collect();
|
||||
for base in gone {
|
||||
v.views.remove(&base);
|
||||
let Some((bytes, section, offset)) = v.views.remove(&base) else {
|
||||
continue;
|
||||
};
|
||||
for k in 0..bytes.div_ceil(K64) {
|
||||
let key = (section, offset + (k * K64) as u64);
|
||||
if let Some(pages) = v.pages.get_mut(&key) {
|
||||
let page = base + k * K64;
|
||||
pages.retain(|&shown| shown != page);
|
||||
if pages.is_empty() {
|
||||
v.pages.remove(&key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The title views that overlap `[start, end)`, as `(address, bytes)`.
|
||||
pub(crate) fn views_between(start: usize, end: usize) -> Vec<(usize, usize)> {
|
||||
if start >= end {
|
||||
return Vec::new();
|
||||
}
|
||||
let v = views();
|
||||
let mut out = Vec::new();
|
||||
if let Some((&base, &(bytes, _, _))) = v.views.range(..=start).next_back()
|
||||
&& base + bytes > start
|
||||
{
|
||||
out.push((base, bytes));
|
||||
}
|
||||
for (&base, &(bytes, _, _)) in v.views.range(start.saturating_add(1)..end) {
|
||||
out.push((base, bytes));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The address of the 64 KiB page shown at `page` in every title view that
|
||||
/// shows it, `page`'s own address included; empty if `page` is not a view.
|
||||
pub(crate) fn pages_of(page: usize) -> Vec<usize> {
|
||||
let v = views();
|
||||
let Some((&base, &(bytes, section, offset))) = v.views.range(..=page).next_back() else {
|
||||
return Vec::new();
|
||||
};
|
||||
let within = page.wrapping_sub(base);
|
||||
if within >= bytes || !within.is_multiple_of(K64) {
|
||||
return Vec::new();
|
||||
}
|
||||
v.pages.get(&(section, offset + within as u64)).cloned().unwrap_or_default()
|
||||
}
|
||||
|
||||
/// The title views that show any of the physical bytes `[offset, offset +
|
||||
/// len)` of `section`, as `(address, bytes)` ranges in address order; not
|
||||
/// those of a page shown in very many views (`MANY_VIEWS`).
|
||||
pub(crate) fn views_of_section(section: usize, offset: u64, len: usize) -> Vec<(usize, usize)> {
|
||||
if len == 0 {
|
||||
return Vec::new();
|
||||
}
|
||||
let v = views();
|
||||
let end = offset.saturating_add(len as u64);
|
||||
let mut pages: Vec<usize> = Vec::new();
|
||||
let mut at = offset - offset % K64 as u64;
|
||||
while at < end {
|
||||
if let Some(shown) = v.pages.get(&(section, at))
|
||||
&& shown.len() <= crate::watch::MANY_VIEWS
|
||||
{
|
||||
pages.extend(shown.iter().copied());
|
||||
}
|
||||
match at.checked_add(K64 as u64) {
|
||||
Some(next) => at = next,
|
||||
None => break,
|
||||
}
|
||||
}
|
||||
pages.sort_unstable();
|
||||
pages.dedup();
|
||||
let mut runs: Vec<(usize, usize)> = Vec::with_capacity(pages.len());
|
||||
for page in pages {
|
||||
match runs.last_mut() {
|
||||
Some((first, bytes)) if *first + *bytes == page => *bytes += K64,
|
||||
_ => runs.push((page, K64)),
|
||||
}
|
||||
}
|
||||
runs
|
||||
}
|
||||
|
||||
/// How the views cover `[at, at + len)`.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub(crate) enum Cover {
|
||||
|
||||
Reference in new issue
Block a user