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]>
66 lines
2.5 KiB
Rust
66 lines
2.5 KiB
Rust
//! Fingerprint of the translator's own source, for the shader cache key
|
|
//! (`victory-gpu`'s `shader_cache`): a rebuilt executable whose translator did
|
|
//! not change keeps its cached translations. Also lists every `VICTORY_*`
|
|
//! switch the translator reads, whose values join the key at run time.
|
|
//! Reads only this crate's `src` folder; writes nothing but cargo directives.
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
fn files(dir: &Path, out: &mut Vec<PathBuf>) {
|
|
let Ok(entries) = std::fs::read_dir(dir) else {
|
|
return;
|
|
};
|
|
for e in entries.flatten() {
|
|
let p = e.path();
|
|
if p.is_dir() {
|
|
files(&p, out);
|
|
} else if p.extension().is_some_and(|x| x == "rs") {
|
|
out.push(p);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// FNV-1a, 64 bits, two lanes with different offsets: a mismatch only costs
|
|
/// a cache miss, so this need not be cryptographic.
|
|
fn fnv(state: &mut [u64; 2], bytes: &[u8]) {
|
|
for &b in bytes {
|
|
for (i, s) in state.iter_mut().enumerate() {
|
|
*s ^= u64::from(b) ^ (i as u64 * 0x9e);
|
|
*s = s.wrapping_mul(0x0000_0100_0000_01b3);
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let src = Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
|
|
println!("cargo:rerun-if-changed=src");
|
|
println!("cargo:rerun-if-changed=Cargo.toml");
|
|
let mut list = Vec::new();
|
|
files(&src, &mut list);
|
|
list.sort();
|
|
let mut state = [0xcbf2_9ce4_8422_2325u64, 0x8422_2325_cbf2_9ce4u64];
|
|
let mut switches = std::collections::BTreeSet::new();
|
|
for p in &list {
|
|
let rel = p.strip_prefix(&src).unwrap_or(p).to_string_lossy().replace('\\', "/");
|
|
let text = std::fs::read(p).unwrap_or_default();
|
|
fnv(&mut state, rel.as_bytes());
|
|
fnv(&mut state, &(text.len() as u64).to_le_bytes());
|
|
fnv(&mut state, &text);
|
|
let s = String::from_utf8_lossy(&text);
|
|
let mut rest = &s[..];
|
|
while let Some(at) = rest.find("\"VICTORY_") {
|
|
let tail = &rest[at + 1..];
|
|
let end = tail
|
|
.find(|c: char| !(c.is_ascii_uppercase() || c.is_ascii_digit() || c == '_'))
|
|
.unwrap_or(tail.len());
|
|
if tail[end..].starts_with('"') {
|
|
switches.insert(tail[..end].to_string());
|
|
}
|
|
rest = &tail[end..];
|
|
}
|
|
}
|
|
println!("cargo:rustc-env=VICTORY_SHADER_SOURCE_HASH={:016x}{:016x}", state[0], state[1]);
|
|
let joined: Vec<_> = switches.into_iter().collect();
|
|
println!("cargo:rustc-env=VICTORY_SHADER_SWITCHES={}", joined.join(","));
|
|
}
|