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
@@ -152,6 +152,87 @@ struct Checks {
|
||||
host: Option<(Host, emit::HostShader)>,
|
||||
}
|
||||
|
||||
/// `translate --warm <file>`: the containers whose hash the file names are
|
||||
/// translated into the run's shader cache, on `jobs` threads; nothing is
|
||||
/// made on the GPU. A run of the title then finds them there instead of
|
||||
/// translating each at its first use.
|
||||
pub fn warm(paths: Vec<PathBuf>, file: &Path, jobs: Option<usize>) -> Result<()> {
|
||||
// `--warm all`: every container found, whatever its hash.
|
||||
let all = file.as_os_str() == "all";
|
||||
let mut wanted: HashSet<String> = HashSet::new();
|
||||
if !all {
|
||||
let text = std::fs::read_to_string(file)?;
|
||||
for line in text.lines() {
|
||||
for word in line.split(|c: char| !c.is_ascii_hexdigit()) {
|
||||
if word.len() == 16 {
|
||||
wanted.insert(word.to_ascii_lowercase());
|
||||
}
|
||||
}
|
||||
}
|
||||
anyhow::ensure!(!wanted.is_empty(), "no 16-digit shader hash in {}", file.display());
|
||||
}
|
||||
// `VICTORY_WARM_SECONDS=<n>`: stop taking new shaders after n seconds
|
||||
// (what is done stays in the cache; the next warm-up goes on from there).
|
||||
let limit = std::env::var("VICTORY_WARM_SECONDS").ok().and_then(|v| v.trim().parse::<u64>().ok());
|
||||
let cfg = victory_core::Config::load()?;
|
||||
victory_hle::modules::d3d12x::use_shader_cache(cfg.cache_subdir("shaders")?);
|
||||
let paths = crate::default_paths(paths)?;
|
||||
let threads = jobs.unwrap_or(4).max(1);
|
||||
let began = std::time::Instant::now();
|
||||
let done = Mutex::new(HashSet::new());
|
||||
let counts = [const { AtomicUsize::new(0) }; 5];
|
||||
for root in &paths {
|
||||
for entry in walkdir::WalkDir::new(root).into_iter().filter_map(Result::ok) {
|
||||
if !entry.file_type().is_file() || entry.metadata().map_or(0, |m| m.len()) > MAX_FILE {
|
||||
continue;
|
||||
}
|
||||
let Ok(data) = std::fs::read(entry.path()) else {
|
||||
continue;
|
||||
};
|
||||
let jobs = sources(&data);
|
||||
let next = AtomicUsize::new(0);
|
||||
std::thread::scope(|s| {
|
||||
for _ in 0..threads.min(jobs.len()) {
|
||||
s.spawn(|| {
|
||||
while let Some(job) = jobs.get(next.fetch_add(1, Ordering::Relaxed)) {
|
||||
let Some(bytes) = job.bytes() else {
|
||||
continue;
|
||||
};
|
||||
let hash = blake3::hash(&bytes).to_hex()[..16].to_owned();
|
||||
if limit.is_some_and(|n| began.elapsed().as_secs() >= n) {
|
||||
counts[3].fetch_add(1, Ordering::Relaxed);
|
||||
break;
|
||||
}
|
||||
if (!all && !wanted.contains(&hash)) || !lock(&done).insert(hash) {
|
||||
continue;
|
||||
}
|
||||
let n = counts[4].fetch_add(1, Ordering::Relaxed) + 1;
|
||||
if n.is_multiple_of(1000) {
|
||||
println!("warm-up {n} shaders so far, {:.0} s", began.elapsed().as_secs_f64());
|
||||
}
|
||||
let which = match victory_hle::modules::d3d12x::warm_shader(&bytes) {
|
||||
Ok(true) => 0,
|
||||
Ok(false) => 1,
|
||||
Err(_) => 2,
|
||||
};
|
||||
counts[which].fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
let [translated, there, failed] = [0, 1, 2].map(|i| counts[i].load(Ordering::Relaxed));
|
||||
let asked = if all { "all".to_owned() } else { wanted.len().to_string() };
|
||||
let stopped = if counts[3].load(Ordering::Relaxed) > 0 { " (stopped at the time limit)" } else { "" };
|
||||
println!(
|
||||
"warm-up {asked} hashes asked, {} found: {translated} translated now, {there} in the cache already, {failed} do not translate; {:.1} s on {threads} threads{stopped}",
|
||||
translated + there + failed,
|
||||
began.elapsed().as_secs_f64()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn run(
|
||||
paths: Vec<PathBuf>,
|
||||
validate: bool,
|
||||
|
||||
Reference in new issue
Block a user