From 001e37d400c5591b59b3f23a4f7090301b1e6d20 Mon Sep 17 00:00:00 2001 From: Xavi Fortes Date: Tue, 24 Nov 2026 08:50:00 +0100 Subject: [PATCH] D3D12.X: bound async compute PSO waits on dedicated workers Compute pipeline first-bind and ExecuteIndirect resolution previously ran uncached DXC + driver builds inline via resolve_wait on the title's render thread with no timeout, tripping retail watchdog aborts when large compute shaders take 20+ s to compile. Move compute pipeline builds onto a dedicated xcl-pso-compute-* worker pool so graphics backlogs cannot starve compute builds, bound total compute wait time with a shared per-frame budget (XCL_COMPUTE_PSO_WAIT_MS, default 4000 ms, 0 = unbounded) reset at PresentX, recover sent on channel send failure, and skip pending compute stand-ins in ExecuteIndirect cleanly (matching Dispatch) until the background build finishes. Assisted-by: Antigravity (Gemini 4 Neon) # Conflicts: # crates/xcl/src/hle/d3d12x/bind.rs # Conflicts: # crates/xcl/src/hle/d3d12x/pso_async.rs --- crates/xcl/src/hle/d3d12x/bind.rs | 57 +++- crates/xcl/src/hle/d3d12x/present.rs | 1 + crates/xcl/src/hle/d3d12x/pso_async.rs | 381 +++++++++++++++++++++++-- 3 files changed, 408 insertions(+), 31 deletions(-) diff --git a/crates/xcl/src/hle/d3d12x/bind.rs b/crates/xcl/src/hle/d3d12x/bind.rs index e0c1518fa..6e39746e8 100644 --- a/crates/xcl/src/hle/d3d12x/bind.rs +++ b/crates/xcl/src/hle/d3d12x/bind.rs @@ -235,7 +235,8 @@ pub(super) fn note_root_changing_signature(sig: usize) { pub(super) unsafe extern "system" fn execute_indirect(this: *mut c_void, sig: usize, max: u32, args: usize, args_off: u64, count_buf: usize, count_off: u64) { type F = unsafe extern "system" fn(*mut c_void, usize, u32, usize, u64, usize, u64); let pc: F = std::mem::transmute(super::real::orig_fn(this, 59)); - let pso = super::pso_async::resolve_wait(with(this, |s| s.pso)); + let raw_pso = with(this, |s| s.pso); + let pso = super::pso_async::resolve_for_indirect(raw_pso); let (gfx, compute) = (super::real::is_translated_graphics(pso), super::real::is_translated_compute(pso)); let (args_off, count_off) = (args_off + super::real::buffer_delta(args), count_off + super::real::buffer_delta(count_buf)); if !gfx && !compute { @@ -244,8 +245,8 @@ pub(super) unsafe extern "system" fn execute_indirect(this: *mut c_void, sig: us // call with that pair is invalid (debug layer 953, "the currently set Root Signature // doesn't match the currently set Pipeline State Object"; a retail title's world then // hung the GPU, 0x887a0006). Skipped, like a draw or dispatch of such a pipeline. - if super::pso_async::is_pending(with(this, |s| s.pso)) { - count(DRAWS_SKIPPED); + if super::pso_async::is_pending(raw_pso) { + count(if super::pso_async::is_pending_compute(raw_pso) { DISPATCHES_SKIPPED } else { DRAWS_SKIPPED }); static N: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0); if N.fetch_add(1, Ordering::Relaxed) < 4 { crate::xlog_warn!("D3D12.X: ExecuteIndirect with a pipeline that is still being built skipped"); @@ -406,8 +407,9 @@ pub(super) unsafe fn emit_prepared_indexed_draw( unsafe fn graphics_bound(this: *mut c_void) -> Option { let list = ID3D12GraphicsCommandList::from_raw_borrowed(&this)?.clone(); let pso = with(this, |s| s.pso); - // a pipeline still being built in the background is waited for (its stand-in draws nothing) - if !super::real::is_translated_graphics(super::pso_async::resolve_wait(pso)) { + // a pipeline still being built in the background is waited for up to the frame's budget, + // then drawn with its stand-in (nothing) while the build goes on + if !super::real::is_translated_graphics(super::pso_async::resolve_bounded(pso)) { count(DRAWS_PC); if super::present::trace_frame() { // which pipelines draw without a translation (first 12 distinct) @@ -712,7 +714,7 @@ pub(super) unsafe extern "system" fn set_pipeline_state(this: *mut c_void, pso: /// #14 Dispatch: with a translated pipeline, on XCL's ABI with the kept root arguments pub(super) unsafe extern "system" fn dispatch(this: *mut c_void, x: u32, y: u32, z: u32) { - let pso = super::pso_async::resolve_wait(with(this, |s| s.pso)); + let pso = super::pso_async::resolve_for_indirect(with(this, |s| s.pso)); let Some(list) = ID3D12GraphicsCommandList::from_raw_borrowed(&this) else { return }; if !super::real::is_translated_compute(pso) { // a console pipeline without a translation (including a background build that @@ -1183,10 +1185,53 @@ mod tests { "failed async compute stand-in must not enter translated ExecuteIndirect path" ); + // 3. Background compute build is still PENDING after timeout: ExecuteIndirect must skip + // cleanly (like Dispatch) rather than forwarding the stand-in to PC ExecuteIndirect. + let standin_pending = 0x7200_0005usize; + let real_pending = 0x7200_0006usize; + let (tx, rx) = std::sync::mpsc::channel::<()>(); + pso_async::submit_lazy( + standin_pending, + true, + Box::new(move || { + let _ = rx.recv_timeout(std::time::Duration::from_secs(5)); + real::register_translated_compute_for_test(real_pending); + real_pending + }), + 0, + ); + assert_eq!( + pso_async::resolve_compute_with_limit_for_test(standin_pending, std::time::Duration::from_millis(20)), + standin_pending + ); + assert!(pso_async::is_pending_compute(standin_pending)); + + reset(list_ptr, 0x7200_0100, standin_pending); + let before_pending = counts_snapshot(); + unsafe { + execute_indirect(list_ptr, 0x7200_00F1, 1, 0, 0, 0, 0); + } + let after_pending = counts_snapshot(); + assert!(after_pending[DISPATCHES_SKIPPED] > before_pending[DISPATCHES_SKIPPED]); + assert_eq!( + fake.execute_indirect_calls.load(Ordering::Relaxed), + 1, + "pending async compute stand-in must be skipped, not forwarded to PC ExecuteIndirect" + ); + + tx.send(()).unwrap(); + let wait = std::time::Instant::now(); + while pso_async::is_pending_compute(standin_pending) { + assert!(wait.elapsed() < std::time::Duration::from_secs(5), "pending compute PSO never completed"); + std::thread::sleep(std::time::Duration::from_millis(10)); + } + forget(list_ptr); let _ = pso_async::released(standin_ok); let _ = pso_async::released(standin_fail); + let _ = pso_async::released(standin_pending); real::forget_pso_for_test(real_ok); + real::forget_pso_for_test(real_pending); } #[test] diff --git a/crates/xcl/src/hle/d3d12x/present.rs b/crates/xcl/src/hle/d3d12x/present.rs index 01b3c92a4..aeb32589e 100644 --- a/crates/xcl/src/hle/d3d12x/present.rs +++ b/crates/xcl/src/hle/d3d12x/present.rs @@ -62,6 +62,7 @@ pub unsafe extern "system" fn present_x(queue: *mut c_void, plane_count: u32, pl } unsafe fn present_x_frame(queue: *mut c_void, plane_count: u32, planes: *const u8) { + super::pso_async::reset_frame_budget(); let frames = BOUNDARIES.fetch_add(1, Ordering::Relaxed) + 1; if frames % 300 == 0 { // the title's frame rate, for comparing runs (every 300 frames) diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs index b303cf55e..32be94861 100644 --- a/crates/xcl/src/hle/d3d12x/pso_async.rs +++ b/crates/xcl/src/hle/d3d12x/pso_async.rs @@ -25,6 +25,8 @@ struct Pending { key: u64, /// it was used (`used::note` is told once) used: std::sync::atomic::AtomicBool, + /// a bounded wait already timed out; subsequent binds skip waiting until `real` lands + timed_out: std::sync::atomic::AtomicBool, /// the stand-in was released before the real pipeline was built orphan: std::sync::atomic::AtomicBool, } @@ -72,27 +74,49 @@ pub fn enabled() -> bool { /// Builds the real pipeline: its raw pointer, 0 = failed. pub type Job = Box usize + Send>; +fn spawn_pool(prefix: &str, threads: usize) -> Mutex>> { + let (tx, rx) = mpsc::channel::>(); + let rx = Arc::new(Mutex::new(rx)); + // translation recurses deeply on big programs; DXC itself runs on its own pool + for k in 0..threads { + let rx = rx.clone(); + let _ = std::thread::Builder::new().name(format!("{prefix}-{k}")).stack_size(64 << 20).spawn(move || loop { + let next = rx.lock().unwrap().recv(); + let Ok(p) = next else { return }; + // (None: a bind took it and builds it itself) + let job = p.job.lock().unwrap().take(); + if let Some(job) = job { + complete(&p, job()); + } + }); + } + Mutex::new(tx) +} + fn queue() -> &'static Mutex>> { static Q: OnceLock>>> = OnceLock::new(); - Q.get_or_init(|| { - let (tx, rx) = mpsc::channel::>(); - let rx = Arc::new(Mutex::new(rx)); - // translation recurses deeply on big programs; DXC itself runs on its own pool - let n = crate::gpu::recomp::dxc::compile_threads(); - for k in 0..n { - let rx = rx.clone(); - let _ = std::thread::Builder::new().name(format!("xcl-pso-{k}")).stack_size(64 << 20).spawn(move || loop { - let next = rx.lock().unwrap().recv(); - let Ok(p) = next else { return }; - // (None: a bind took it and builds it itself) - let job = p.job.lock().unwrap().take(); - if let Some(job) = job { - complete(&p, job()); - } - }); + Q.get_or_init(|| spawn_pool("xcl-pso", crate::gpu::recomp::dxc::compile_threads())) +} + +/// Dedicated worker pool for compute pipelines so a backlog (or driver stall, #156) of graphics +/// builds cannot starve compute dispatches indefinitely. Keeps at least two workers so one slow +/// compute shader cannot head-of-line block faster compute shaders on low-core hosts. +fn compute_queue() -> &'static Mutex>> { + static Q: OnceLock>>> = OnceLock::new(); + Q.get_or_init(|| spawn_pool("xcl-pso-compute", (crate::gpu::recomp::dxc::compile_threads() / 2).clamp(2, 4))) +} + +/// Send `p` to its worker pool if not already sent; clears `sent` on failure so a later bind +/// can retry instead of stalling forever. +fn enqueue(p: &Arc) -> bool { + if !p.sent.swap(true, Ordering::AcqRel) { + let q = if p.compute { compute_queue() } else { queue() }; + if q.lock().unwrap().send(p.clone()).is_err() { + p.sent.store(false, Ordering::Release); + return false; } - Mutex::new(tx) - }) + } + true } /// Release a pipeline state XCL owns (raw pointer, 0 = none). @@ -126,13 +150,14 @@ pub fn submit_lazy(standin: usize, compute: bool, job: Job, key: u64) { fn submit_as(standin: usize, compute: bool, job: Job, send: bool, key: u64) { let p = Arc::new(Pending { job: Mutex::new(Some(job)), - sent: std::sync::atomic::AtomicBool::new(send), + sent: std::sync::atomic::AtomicBool::new(false), real: AtomicUsize::new(0), done: Mutex::new(false), cv: Condvar::new(), compute, key, used: Default::default(), + timed_out: Default::default(), orphan: Default::default(), }); PENDING.lock().unwrap().get_or_insert_with(HashMap::new).insert(standin, p.clone()); @@ -141,7 +166,7 @@ fn submit_as(standin: usize, compute: bool, job: Job, send: bool, key: u64) { crate::xlog_info!("D3D12.X: pipelines whose shaders are not compiled yet get a stand-in and are built in the background"); }); if send { - let _ = queue().lock().unwrap().send(p); + let _ = enqueue(&p); } else if used::known(key) { if let Some(q) = preload() { q.list.lock().unwrap().push_back(p); @@ -330,9 +355,7 @@ pub fn resolve(pso: usize) -> usize { match p.real.load(Ordering::Acquire) { 0 => { // a lazy one is wanted now: to the workers - if !p.sent.swap(true, Ordering::AcqRel) { - let _ = queue().lock().unwrap().send(p); - } + let _ = enqueue(&p); pso } r => r, @@ -358,15 +381,150 @@ pub fn resolve_wait(pso: usize) -> usize { } } -/// For binding: compute pipelines are waited for, graphics ones are not. +/// Maximum per-frame time title threads wait for uncached compute pipelines on first +/// bind/dispatch (`XCL_COMPUTE_PSO_WAIT_MS`, default 4000 ms; `0` = unbounded). Huge compute +/// shaders can take 20+ s to compile in DXC / the driver, and a loading frame can bind many +/// uncached compute pipelines in a row; sharing one budget per frame keeps the total bounded. +fn compute_wait_timeout() -> Option { + static LIMIT: OnceLock> = OnceLock::new(); + *LIMIT.get_or_init(|| { + let ms = std::env::var("XCL_COMPUTE_PSO_WAIT_MS").ok().and_then(|v| v.trim().parse::().ok()).unwrap_or(4000); + if ms == 0 { None } else { Some(std::time::Duration::from_millis(ms)) } + }) +} + +/// Shared per-frame compute wait budget, reset at each `PresentX` boundary (`reset_frame_budget`). +struct FrameBudget { + spent_ms: std::sync::atomic::AtomicU64, +} + +impl FrameBudget { + const fn new() -> Self { + Self { spent_ms: std::sync::atomic::AtomicU64::new(0) } + } + + fn remaining(&self, limit: std::time::Duration) -> std::time::Duration { + let limit_ms = limit.as_millis().min(u64::MAX as u128) as u64; + let spent = self.spent_ms.load(Ordering::Relaxed); + std::time::Duration::from_millis(limit_ms.saturating_sub(spent)) + } + + fn consume(&self, elapsed: std::time::Duration) { + let ms = elapsed.as_millis().min(u64::MAX as u128) as u64; + if ms > 0 { + self.spent_ms.fetch_add(ms, Ordering::Relaxed); + } + } + + fn reset(&self) { + self.spent_ms.store(0, Ordering::Relaxed); + } +} + +static FRAME_BUDGET: FrameBudget = FrameBudget::new(); + +/// Reset the per-frame compute pipeline wait budget (called at `PresentX`). +pub fn reset_frame_budget() { + FRAME_BUDGET.reset(); +} + +/// Bounded wait for a compute pipeline: always builds on `xcl-pso-compute-*` workers (never +/// stalling the title's thread inside DXC/driver), waits at most the remaining per-frame `budget` +/// up to `limit`, and returns the stand-in immediately once timed out or once the frame budget is +/// exhausted until the worker finishes. +fn resolve_compute_within(pso: usize, limit: Option, budget: &FrameBudget) -> usize { + let Some(limit) = limit else { + return resolve_wait(pso); + }; + let Some(p) = entry(pso) else { return pso }; + p.note_use(); + if let r @ 1.. = p.real.load(Ordering::Acquire) { + return r; + } + if !enqueue(&p) { + return pso; + } + if p.timed_out.load(Ordering::Acquire) { + return match p.real.load(Ordering::Acquire) { + 0 => pso, + r => r, + }; + } + let rem_budget = budget.remaining(limit); + if rem_budget.is_zero() { + return match p.real.load(Ordering::Acquire) { + 0 => pso, + r => r, + }; + } + let started = std::time::Instant::now(); + let deadline = started + rem_budget; + let mut done = p.done.lock().unwrap(); + while !*done { + let rem = deadline.saturating_duration_since(std::time::Instant::now()); + if rem.is_zero() { + break; + } + let (g, res) = p.cv.wait_timeout(done, rem).unwrap(); + done = g; + if res.timed_out() { + break; + } + } + let elapsed = started.elapsed(); + if !*done { + budget.consume(elapsed.max(rem_budget)); + if rem_budget >= limit / 2 && !p.timed_out.swap(true, Ordering::AcqRel) { + static LOGGED: AtomicUsize = AtomicUsize::new(0); + if LOGGED.fetch_add(1, Ordering::Relaxed) < 16 { + crate::xlog_warn!( + "D3D12.X: {} pipeline {pso:#x} still building after {} ms – proceeding with stand-in (continues in background)", + if p.compute { "compute" } else { "graphics" }, + elapsed.as_millis() + ); + } + } + return pso; + } + budget.consume(elapsed); + match p.real.load(Ordering::Acquire) { + 0 => pso, + r => r, + } +} + +/// Resolve a compute pipeline with `XCL_COMPUTE_PSO_WAIT_MS` per-frame bounding. +pub fn resolve_compute(pso: usize) -> usize { + resolve_compute_within(pso, compute_wait_timeout(), &FRAME_BUDGET) +} + +/// For binding: compute pipelines wait up to `XCL_COMPUTE_PSO_WAIT_MS` on background workers; +/// graphics pipelines are queued without blocking. pub fn resolve_for_bind(pso: usize) -> usize { match entry(pso) { - Some(p) if p.compute => resolve_wait(pso), + Some(p) if p.compute => resolve_compute(pso), Some(_) => resolve(pso), None => pso, } } +/// For `ExecuteIndirect`: compute and graphics pipelines alike wait up to the frame's budget +/// (`XCL_COMPUTE_PSO_WAIT_MS`), then the call is skipped while the build goes on in the +/// background (`bind::execute_indirect`). +pub fn resolve_for_indirect(pso: usize) -> usize { + resolve_bounded(pso) +} + +/// Resolve a pipeline of either kind with `XCL_COMPUTE_PSO_WAIT_MS` per-frame bounding: +/// returns the real pipeline if its build finishes in time, else the stand-in while the build +/// continues in the background. +pub fn resolve_bounded(pso: usize) -> usize { + match entry(pso) { + Some(_) => resolve_compute(pso), + None => pso, + } +} + /// The title released stand-in `pso` for good: forget it (its address may come back for /// another object) and return its real pipeline to release (0: none, or still being built – /// the worker's result is then released when it arrives). @@ -387,8 +545,181 @@ pub fn is_pending(pso: usize) -> bool { entry(pso).is_some_and(|p| !*p.done.lock().unwrap()) } +/// `pso` is a compute stand-in whose real pipeline is still being built. +pub fn is_pending_compute(pso: usize) -> bool { + entry(pso).is_some_and(|p| p.compute && !*p.done.lock().unwrap()) +} + +#[cfg(test)] +pub(crate) fn resolve_compute_with_limit_for_test(pso: usize, limit: std::time::Duration) -> usize { + resolve_compute_within(pso, Some(limit), &FrameBudget::new()) +} + /// (built in the background, failed, still building) pub fn counts() -> (usize, usize, usize) { let pending = PENDING.lock().unwrap().as_ref().map_or(0, |m| m.values().filter(|p| !*p.done.lock().unwrap()).count()); (BUILT.load(Ordering::Relaxed), FAILED.load(Ordering::Relaxed), pending) } + +#[cfg(test)] +mod tests { + use super::*; + use std::time::{Duration, Instant}; + + #[test] + fn bounded_compute_wait_times_out_then_resolves_once_worker_finishes() { + let standin = 0x7300_0001usize; + let real_pso = 0x7300_0002usize; + let budget = FrameBudget::new(); + let (tx, rx) = mpsc::channel::<()>(); + submit_lazy( + standin, + true, + Box::new(move || { + let _ = rx.recv_timeout(Duration::from_secs(5)); + real_pso + }), + 0, + ); + + // First call sends the lazy build to the compute worker pool and returns the stand-in after ~limit. + let t0 = Instant::now(); + assert_eq!(resolve_compute_within(standin, Some(Duration::from_millis(60)), &budget), standin); + assert!(t0.elapsed() < Duration::from_secs(1), "bounded wait must not block indefinitely"); + assert!(is_pending_compute(standin)); + + // Subsequent calls while still building return immediately (even on a fresh frame budget). + budget.reset(); + let t1 = Instant::now(); + assert_eq!(resolve_compute_within(standin, Some(Duration::from_secs(2)), &budget), standin); + assert!(t1.elapsed() < Duration::from_millis(200), "post-timeout calls must return immediately"); + + // Unblock the background worker; once complete, resolution immediately returns the real PSO. + tx.send(()).unwrap(); + let wait = Instant::now(); + while resolve_compute_within(standin, Some(Duration::from_millis(50)), &budget) != real_pso { + assert!(wait.elapsed() < Duration::from_secs(5), "background compute PSO never completed"); + std::thread::sleep(Duration::from_millis(10)); + } + assert!(!is_pending_compute(standin)); + assert_eq!(released(standin), real_pso); + } + + #[test] + fn bounded_compute_wait_returns_real_when_build_finishes_in_time() { + let standin = 0x7300_0003usize; + let real_pso = 0x7300_0004usize; + let budget = FrameBudget::new(); + let (name_tx, name_rx) = mpsc::channel::(); + submit_lazy( + standin, + true, + Box::new(move || { + let _ = name_tx.send(std::thread::current().name().unwrap_or("").to_string()); + real_pso + }), + 0, + ); + assert_eq!(resolve_compute_within(standin, Some(Duration::from_secs(4)), &budget), real_pso); + let worker_name = name_rx.recv_timeout(Duration::from_secs(1)).unwrap(); + assert!( + worker_name.starts_with("xcl-pso-compute-"), + "compute pipelines must run on dedicated compute workers, got {worker_name:?}" + ); + assert_eq!(released(standin), real_pso); + } + + #[test] + fn bounded_compute_wait_shares_per_frame_budget_across_pipelines() { + let standin_a = 0x7300_0005usize; + let real_a = 0x7300_0006usize; + let standin_b = 0x7300_0007usize; + let real_b = 0x7300_0008usize; + let budget = FrameBudget::new(); + let (tx_a, rx_a) = mpsc::channel::<()>(); + let (tx_b, rx_b) = mpsc::channel::<()>(); + submit_lazy( + standin_a, + true, + Box::new(move || { + let _ = rx_a.recv_timeout(Duration::from_secs(5)); + real_a + }), + 0, + ); + submit_lazy( + standin_b, + true, + Box::new(move || { + let _ = rx_b.recv_timeout(Duration::from_secs(5)); + real_b + }), + 0, + ); + + // First slow pipeline consumes the entire 60 ms frame budget. + assert_eq!(resolve_compute_within(standin_a, Some(Duration::from_millis(60)), &budget), standin_a); + + // Second uncached pipeline in the same frame is queued but does NOT stall for another 60 ms. + let t_b = Instant::now(); + assert_eq!(resolve_compute_within(standin_b, Some(Duration::from_millis(60)), &budget), standin_b); + assert!( + t_b.elapsed() < Duration::from_millis(20), + "second pipeline in exhausted frame must not multiply wait time" + ); + + // Next frame refreshes the budget; release both workers so `b` cannot be blocked behind + // `a` even when other tests run concurrently on a low-core CI runner. + budget.reset(); + tx_a.send(()).unwrap(); + tx_b.send(()).unwrap(); + assert_eq!(resolve_compute_within(standin_b, Some(Duration::from_secs(4)), &budget), real_b); + + let wait = Instant::now(); + while resolve_compute_within(standin_a, Some(Duration::from_millis(50)), &budget) != real_a { + assert!(wait.elapsed() < Duration::from_secs(5), "background compute PSO A never completed"); + std::thread::sleep(Duration::from_millis(10)); + } + assert_eq!(released(standin_a), real_a); + assert_eq!(released(standin_b), real_b); + } + + #[test] + fn bounded_compute_wait_records_the_pipeline_for_the_next_run() { + let (standin, key) = (0x7300_0101usize, 0x5EED_0000_0000_0101u64); + submit_lazy(standin, true, Box::new(|| 0x7300_0102usize), key); + assert!(!used::noted(key)); + let budget = FrameBudget::new(); + let _ = resolve_compute_within(standin, Some(Duration::from_secs(2)), &budget); + assert!(used::noted(key), "a compute pipeline used through the bounded wait must be recorded for preload"); + let _ = released(standin); + } + + #[test] + fn bounded_wait_covers_graphics_pipelines_too() { + let standin = 0x7300_0103usize; + let real_pso = 0x7300_0104usize; + let budget = FrameBudget::new(); + let (tx, rx) = mpsc::channel::<()>(); + submit_lazy( + standin, + false, + Box::new(move || { + let _ = rx.recv_timeout(Duration::from_secs(5)); + real_pso + }), + 0, + ); + let t0 = Instant::now(); + assert_eq!(resolve_compute_within(standin, Some(Duration::from_millis(60)), &budget), standin); + assert!(t0.elapsed() < Duration::from_secs(1), "a graphics build must not hold the binding thread"); + assert!(is_pending(standin) && !is_pending_compute(standin)); + tx.send(()).unwrap(); + let wait = Instant::now(); + while resolve_compute_within(standin, Some(Duration::from_millis(50)), &budget) != real_pso { + assert!(wait.elapsed() < Duration::from_secs(5), "background graphics PSO never completed"); + std::thread::sleep(Duration::from_millis(10)); + } + assert_eq!(released(standin), real_pso); + } +}