Merge fork main 8dd30ab: writes through one view of a page are seen at its other views

The fork's guard over every view of a physical page is kept on our own block
bits, known holes, kernel writes and changing blocks; what both had, ours.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-25 00:38:57 -06:00
commit c45d109380
23 files changed
+4164 -221

No files matched your search

+65
View File
@@ -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(","));
}
+27
View File
@@ -200,6 +200,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 {