From a161e6645c892f5cd2d12974a2de28e9d3cb496f Mon Sep 17 00:00:00 2001 From: Prime <215761102+Prime1997@users.noreply.github.com> Date: Fri, 27 Nov 2026 22:26:10 -0800 Subject: [PATCH] Recompiler: charge split shader pieces on NVIDIA cache admission Port main commit f2cb30f8b99750d0d01bf3b2ca4ebfb006423621 by bmjask to nvidia-dev. The cache omits split-piece capacities on insertion while including them on eviction. Related main PR #2475 covers the same accounting gap; this is the narrow already-merged-main repair for the NVIDIA branch. The unchanged regression fails before the fix. Five targeted CPU cache tests pass with the fix, no ignored or explicit skipped tests. Full current-head suite and paired clean-head retail smoke remain pending; no gameplay memory reduction is claimed. Assisted-by: Codex (GPT-6) --- crates/xcl/src/gpu/recomp/pso.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/xcl/src/gpu/recomp/pso.rs b/crates/xcl/src/gpu/recomp/pso.rs index fdc25f40ef..29e00230d0 100644 --- a/crates/xcl/src/gpu/recomp/pso.rs +++ b/crates/xcl/src/gpu/recomp/pso.rs @@ -906,6 +906,7 @@ impl ShaderCache { let bytes = blob.len() + key.cache_dir.capacity() + shader.dxil.capacity() + + shader.dispatch_chain.as_ref().map_or(0, |chain| chain.pieces.iter().map(Vec::capacity).sum()) + shader.samplers.capacity() * std::mem::size_of::(); if bytes > self.limit { return; @@ -2024,6 +2025,22 @@ mod shader_cache_tests { assert!(cache.get(&key(0), b"a").is_none()); } + #[test] + fn shader_cache_charges_split_piece_capacity_on_insert() { + let mut split = compiled(7); + split.dispatch_chain = Some(Arc::new(crate::gpu::dxil::kernel::DispatchChain { + dwords_per_group: 8, + pieces: vec![vec![0u8; 4096], vec![0u8; 2048]], + })); + let split = Arc::new(split); + let entry = ShaderEntry { key: key(1), blob: b"split".to_vec(), shader: split.clone(), gen: 0 }; + let piece_bytes: usize = split.dispatch_chain.as_ref().unwrap().pieces.iter().map(Vec::capacity).sum(); + let mut cache = ShaderCache::new(entry.bytes() - piece_bytes); + cache.insert(key(1), b"split", split); + assert!(cache.entries.is_empty(), "a split shader larger than the byte budget is not admitted"); + assert_eq!(cache.bytes, 0); + } + #[test] fn shader_cache_coalesces_concurrent_same_key_compiles() { use std::sync::atomic::{AtomicUsize, Ordering};