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
@@ -0,0 +1,65 @@
|
||||
//! 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(","));
|
||||
}
|
||||
@@ -188,6 +188,33 @@ pub fn shader_opt() -> u32 {
|
||||
*PASSES.get_or_init(|| parse_shader_opt(std::env::var("VICTORY_SHADER_OPT").ok().as_deref()))
|
||||
}
|
||||
|
||||
/// Everything a translation depends on besides the container: the
|
||||
/// translator's own source (hashed at build time), the value of every
|
||||
/// `VICTORY_*` switch it reads, the host facts the device hands it (widest
|
||||
/// wave, view heap limit) and the settings above. The shader cache keys on
|
||||
/// this instead of on the whole executable, so a rebuild that leaves the
|
||||
/// translator alone keeps its translations. Call it after the device is made.
|
||||
pub fn translation_fingerprint() -> Vec<u8> {
|
||||
let mut out = Vec::new();
|
||||
out.extend_from_slice(env!("VICTORY_SHADER_SOURCE_HASH").as_bytes());
|
||||
out.push(u8::from(cfg!(feature = "diagnostics")));
|
||||
out.push(u8::from(cfg!(debug_assertions)));
|
||||
for name in env!("VICTORY_SHADER_SWITCHES").split(',').filter(|n| !n.is_empty()) {
|
||||
out.extend_from_slice(name.as_bytes());
|
||||
out.push(b'=');
|
||||
if let Some(value) = std::env::var_os(name) {
|
||||
out.extend_from_slice(value.as_encoded_bytes());
|
||||
}
|
||||
out.push(0);
|
||||
}
|
||||
out.extend_from_slice(&lower::host_max_wave().to_le_bytes());
|
||||
out.extend_from_slice(&shader::view_heap_limit().to_le_bytes());
|
||||
out.extend_from_slice(&loop_limit().to_le_bytes());
|
||||
out.push(group_sync());
|
||||
out.extend_from_slice(&shader_opt().to_le_bytes());
|
||||
out
|
||||
}
|
||||
|
||||
/// `VICTORY_SHADER_OPT`'s value; every pass when it is unset or
|
||||
/// unreadable. Pure, for testing.
|
||||
fn parse_shader_opt(value: Option<&str>) -> u32 {
|
||||
|
||||
Reference in new issue
Block a user