diff --git a/crates/xcl/src/hle/d3d12x/bind.rs b/crates/xcl/src/hle/d3d12x/bind.rs index 3f31c48b43..ed975dae00 100644 --- a/crates/xcl/src/hle/d3d12x/bind.rs +++ b/crates/xcl/src/hle/d3d12x/bind.rs @@ -121,11 +121,6 @@ pub(super) fn inherit_for_split(from: *mut c_void, to: *mut c_void, allocator: u console_list::hold_until_reset(old, blocks); } -/// A submit is about to wait for the pipeline `this` has bound. -pub(super) fn want_bound(this: *mut c_void) { - super::pso_async::want(with(this, |s| s.pso)); -} - /// A put-off dispatch that could not be recorded. pub(super) fn dispatch_dropped() { count(DISPATCHES_SKIPPED); diff --git a/crates/xcl/src/hle/d3d12x/list_x.rs b/crates/xcl/src/hle/d3d12x/list_x.rs index ee544dec22..ae986ab716 100644 --- a/crates/xcl/src/hle/d3d12x/list_x.rs +++ b/crates/xcl/src/hle/d3d12x/list_x.rs @@ -2661,9 +2661,6 @@ pub(super) unsafe fn defer(list: *mut c_void, what: Deferred) -> bool { true } -/// Builds of a submit's put-off calls that go on without the commit headroom, as a title thread's own do: about what the title's threads had in the driver at once before. -const WANTED_AT_ONCE: usize = 4; - /// Records the deferred dispatches of `wrapper`'s recording, waiting for their pipelines as a bind did. pub(super) unsafe fn record_deferred(wrapper: *mut c_void) { let mut segs = Vec::new(); @@ -2671,10 +2668,7 @@ pub(super) unsafe fn record_deferred(wrapper: *mut c_void) { let Some(&first) = segs.first() else { return }; segs.retain(|&seg| seg == first || LISTS.lock().unwrap().as_ref().and_then(|m| m.get(&(seg as usize))).is_some_and(|s| s.deferred.is_some())); let mut last: Option<*mut c_void> = None; - for (i, &seg) in segs.iter().enumerate().skip(1) { - for &ahead in segs[i..].iter().take(WANTED_AT_ONCE) { - super::bind::want_bound(ahead); - } + for &seg in segs.iter().skip(1) { let Some((what, ty, heaps)) = LISTS.lock().unwrap().as_mut().and_then(|m| m.get_mut(&(seg as usize))).and_then(|s| Some((s.deferred.take()?, s.list_type?, s.bindings.heaps.clone()))) else { continue; }; diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs index 63d62a7df4..29938ed0fb 100644 --- a/crates/xcl/src/hle/d3d12x/pso_async.rs +++ b/crates/xcl/src/hle/d3d12x/pso_async.rs @@ -760,6 +760,28 @@ mod used_tests { let _ = released(standin); } + #[test] + fn a_build_a_submit_needs_is_wanted() { + let standin = 0x7E57_B006usize; + let (started_tx, started) = mpsc::channel(); + submit(standin, true, Box::new(move || { + started_tx.send(()).unwrap(); + let t = std::time::Instant::now(); + while !build_is_wanted() && t.elapsed() < std::time::Duration::from_secs(10) { + std::thread::sleep(std::time::Duration::from_millis(1)); + } + if build_is_wanted() { 0x5757 } else { 0 } + })); + started.recv().unwrap(); + need_by_submit(standin); + let t = std::time::Instant::now(); + while is_pending(standin) && t.elapsed() < std::time::Duration::from_secs(15) { + std::thread::sleep(std::time::Duration::from_millis(5)); + } + assert_eq!(resolve(standin), 0x5757, "the build did not hear that a submit waits for it"); + let _ = released(standin); + } + /// A worker's build hears that a bind waits for it (and only its own build does). #[test] fn a_waiting_bind_makes_the_build_wanted() { @@ -1212,17 +1234,12 @@ pub fn is_pending(pso: usize) -> bool { entry(pso).is_some_and(|p| !*p.done.lock().unwrap()) } -/// One of the title's threads is about to wait for `pso`. -pub fn want(pso: usize) { - if let Some(p) = entry(pso) { - p.want(); - } -} - -/// A call with `pso` was put off to the submit: its build goes before the workers' queue. +/// A call with `pso` was put off to the submit, which will wait for it: its build goes before the +/// workers' queue, as a wanted one. pub fn need_by_submit(pso: usize) { let Some(p) = entry(pso) else { return }; if !std::mem::replace(&mut p.demand.lock().unwrap().by_submit, true) { + p.want(); NEEDED.lock().unwrap().push_back(p); let _ = queue().lock().unwrap().send(Box::new(|| ())); }