Streaming, copy queue, texture pools and a shader cache that survives rebuilds

Textures and staging cut from 64 MB blocks; a kept view per page section and
page lists read again until the title has filled them in; the GPU side told
when streamed bytes land; results fetched over the copy queue
(VICTORY_RELAY_COPY=1); the write-watch journal behind a reader-writer lock;
the shader cache keyed by the translator's sources and `victory shaders`;
helper lanes as in upstream 1733 (VICTORY_HELPER_OWN).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-24 18:55:40 -06:00
1 parent 7f166af4f3
commit 9fea7434cd
20 files changed
+1629 -232

No files matched your search

+10
View File
@@ -85,6 +85,15 @@ enum Command {
#[arg(long)]
jobs: Option<usize>,
},
/// Translate every shader found (as `translate` finds them) into the
/// shader cache, so that no run has to: a few minutes, once per change
/// of the translator.
Shaders {
paths: Vec<PathBuf>,
/// Worker threads (default: every logical core).
#[arg(long)]
jobs: Option<usize>,
},
/// Prepare, map and bind a title executable; with --execute, run it.
Run {
exe: PathBuf,
@@ -163,6 +172,7 @@ fn main() -> Result<()> {
}
translate::run(paths, validate, pipelines, list, jobs)
}
Command::Shaders { paths, jobs } => translate::precompile(paths, jobs),
Command::Run {
exe,
unimplemented,
+61
View File
@@ -306,6 +306,67 @@ pub fn run(
Ok(())
}
/// Every shader found into the cache runs translate from.
pub fn precompile(paths: Vec<PathBuf>, jobs: Option<usize>) -> Result<()> {
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_else(|| std::thread::available_parallelism().map_or(4, |n| n.get()));
let started = std::time::Instant::now();
let seen = Mutex::new(HashSet::new());
let done = AtomicUsize::new(0);
let failed = Mutex::new(BTreeMap::<String, (usize, String)>::new());
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);
if !lock(&seen).insert(hash) {
continue;
}
match victory_hle::modules::d3d12x::precompile(&bytes) {
Ok(_) => {
let n = done.fetch_add(1, Ordering::Relaxed) + 1;
if n.is_multiple_of(1000) {
println!("{n} shaders in the cache, {:.0} s", started.elapsed().as_secs_f64());
}
}
Err(why) => {
let mut failed = lock(&failed);
failed.entry(why).or_insert_with(|| (0, hash.to_hex()[..16].to_owned())).0 += 1;
}
}
}
});
}
});
}
}
let failed = failed.into_inner().unwrap_or_else(|e| e.into_inner());
println!(
"{} shaders in the cache, {} do not translate, {:.0} s",
done.load(Ordering::Relaxed),
failed.values().map(|f| f.0).sum::<usize>(),
started.elapsed().as_secs_f64()
);
for (why, (n, hash)) in failed {
println!(" {n:>5} {why} (e.g. {hash})");
}
Ok(())
}
fn translate(
source: &Source,
path: &Path,