From 0488eceb1f4c6a503b5a1559531aba156dad1202 Mon Sep 17 00:00:00 2001 From: gccody Date: Tue, 24 Nov 2026 00:40:17 -0500 Subject: [PATCH] D3D12.X: XCL_BIG_COMPILES sets how many big compute pipelines the driver builds at once Background driver compiles of compute programs of 256 KiB or more of DXIL go through one slot, which keeps the commit of a Windows machine with a small page file in bounds. Under Wine + vkd3d-proton on an RTX 3080 those builds take 25 - 120 s each (dxil-spirv, then the driver), and a retail title's world load queued its backlog behind that single slot: at 234 s, 24 382 of 25 471 dispatches were skipped while their pipelines were still building. XCL_BIG_COMPILES (1 - 16, default 1, unchanged) lets a machine with the memory for it build several at once; with 6, 6 708 of 17 486 were skipped at the same point. Co-Authored-By: Claude Opus 5.5 --- crates/xcl/src/hle/d3d12x/real.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs index aed907586..3f0b5add8 100644 --- a/crates/xcl/src/hle/d3d12x/real.rs +++ b/crates/xcl/src/hle/d3d12x/real.rs @@ -3293,7 +3293,7 @@ const BIG_DRIVER_COMPILE: usize = 256 << 10; struct Slots { n: Mutex, cv: std::sync::Condvar, - most: usize, + most: fn() -> usize, } struct SlotGuard(&'static Slots); @@ -3301,7 +3301,8 @@ struct SlotGuard(&'static Slots); impl Slots { fn acquire(&'static self) -> SlotGuard { let mut n = self.n.lock().unwrap(); - while *n >= self.most { + let most = (self.most)(); + while *n >= most { n = self.cv.wait(n).unwrap(); } *n += 1; @@ -3316,7 +3317,22 @@ impl Drop for SlotGuard { } } -static BIG_COMPILES: Slots = Slots { n: Mutex::new(0), cv: std::sync::Condvar::new(), most: 1 }; +static BIG_COMPILES: Slots = Slots { n: Mutex::new(0), cv: std::sync::Condvar::new(), most: big_compiles }; + +/// Big background driver compiles at once: 1, or `XCL_BIG_COMPILES` (1 – 16). One at a time keeps +/// the commit of a Windows machine with a small page file in bounds; with the RAM for it more can +/// run – under Wine + vkd3d-proton each big compute program takes 50 – 120 s through dxil-spirv and +/// the driver, so a retail title's world-load backlog of them queued behind a single slot. +fn big_compiles() -> usize { + static N: OnceLock = OnceLock::new(); + *N.get_or_init(|| { + let n = std::env::var("XCL_BIG_COMPILES").ok().and_then(|v| v.trim().parse::().ok()).unwrap_or(1).clamp(1, 16); + if n > 1 { + crate::xlog_info!("D3D12.X: XCL_BIG_COMPILES={n}: up to {n} big compute pipelines built by the driver at once"); + } + n + }) +} /// Before a big driver compile in the background: until 3 GB of commit are free (each takes /// ~1.5 GB; the title loading next to it must not run out – no minute's grace as for DXC).