From d5d694b04b3e26abdef656af21c03d30a5027d9b Mon Sep 17 00:00:00 2001 From: nog <177071794+brothernog@users.noreply.github.com> Date: Wed, 25 Nov 2026 20:35:27 -0300 Subject: [PATCH] D3D12.X: with bounded pipeline waits, dispatches are not put off to the submit With XCL_PSO_WAIT_MS set, a dispatch whose pipeline is still being built is recorded at once instead of being put off to the submit (#2118): its bind waits at most XCL_PSO_WAIT_MS on the title's thread, as before. The submit's wait has the same bound, so the put-off only moved it. With XCL_PSO_WAIT_MS=1 a retail title's world start put off thousands of calls, a segment each; its command lists ran out of memory (Close: E_OUTOFMEMORY) and the device was removed (0x887a0001). Unset (the default), nothing changes. --- crates/xcl/src/hle/d3d12x/list_x.rs | 7 +++++++ crates/xcl/src/hle/d3d12x/pso_async.rs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/crates/xcl/src/hle/d3d12x/list_x.rs b/crates/xcl/src/hle/d3d12x/list_x.rs index ee544dec22..009f491543 100644 --- a/crates/xcl/src/hle/d3d12x/list_x.rs +++ b/crates/xcl/src/hle/d3d12x/list_x.rs @@ -2650,6 +2650,13 @@ unsafe fn try_split_for_wait(list: *mut c_void) -> Option<*mut c_void> { /// Gives a dispatch whose pipeline is still being built a segment of its own, recorded at the submit. pub(super) unsafe fn defer(list: *mut c_void, what: Deferred) -> bool { + // With bounded waits (`XCL_PSO_WAIT_MS`) the call is recorded now and its bind waits at most + // that long, as before calls were put off: a segment per unbuilt call ran a retail title out + // of command list memory (Close: E_OUTOFMEMORY, then the device was removed, 0x887a0001) + // when its world start bound thousands of them with `XCL_PSO_WAIT_MS=1`. + if super::pso_async::waits_bounded() { + return false; + } if split(list, Some(what)).is_none() { return false; } diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs index 63d62a7df4..a9f55a01a4 100644 --- a/crates/xcl/src/hle/d3d12x/pso_async.rs +++ b/crates/xcl/src/hle/d3d12x/pso_async.rs @@ -1106,6 +1106,12 @@ fn wait_budget() -> Option { *B.get_or_init(|| std::env::var("XCL_PSO_WAIT_MS").ok().and_then(|v| v.trim().parse::().ok()).filter(|&ms| ms > 0).map(std::time::Duration::from_millis)) } +/// Binds wait at most `XCL_PSO_WAIT_MS`: a dispatch is then not put off to the submit +/// (`list_x::defer`), where it would only wait as long. +pub fn waits_bounded() -> bool { + wait_budget().is_some() +} + /// `resolve_wait` for at most `budget`: the build goes to the workers (not this thread), and a /// pipeline not built by then is `late` – it and later binds of it get the stand-in (their /// dispatches are skipped) until a worker has built it.