Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion crates/xcl/src/hle/d3d12x/pso_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12406,6 +12406,27 @@ fn resolve_wait_bound_and_pin(pso: usize) -> ((usize, bool), Option<NativeGenera
((resolved, choice.1 || stale_fallback), generation)
}

/// `resolve_wait_budgets` for a retained Pending: the budget of every pipeline, the one of
/// graphics pipelines (a share of the thread's time, `gfx_wait_left`) and the one of compute
/// pipelines, without looking its title address up again.
fn resolve_wait_pending_budgets(
p: &Arc<Pending>,
pso: usize,
all: Option<std::time::Duration>,
gfx: Option<std::time::Duration>,
cs: Option<std::time::Duration>,
) -> usize {
match gfx.filter(|_| !p.compute) {
Some(budget) => {
let start = std::time::Instant::now();
let r = resolve_wait_pending(p, pso, Some(gfx_wait_left(budget, start)));
gfx_wait_spent(start.elapsed());
r
}
None => resolve_wait_pending(p, pso, budget_for(p.compute, all, gfx, cs)),
}
}

/// Resolve one retained Pending to an exactly owned generation without consulting its title
/// address. One-shot and recipe-backed builds share the same wait policy at this boundary.
fn resolve_retained_for_emission(pso: usize, p: &Arc<Pending>) -> PipelineChoice {
Expand All @@ -12415,7 +12436,7 @@ fn resolve_retained_for_emission(pso: usize, p: &Arc<Pending>) -> PipelineChoice
return PipelineChoice::Unavailable;
}
p.note_use();
let bound = resolve_wait_pending(p, pso, wait_budget());
let bound = resolve_wait_pending_budgets(p, pso, wait_budget(), gfx_wait_budget(), cs_wait_budget());
let bound_unbuilt = p.bound_unbuilt(pso, bound);
let (raw, generation, _) = pin_resolved(pso, p, bound, bound_unbuilt);
match generation {
Expand Down Expand Up @@ -12935,4 +12956,42 @@ mod backlog_tests {
released(standin);
}
}

/// A retained bind (`resolve_retained_for_emission`) waits for a pipeline still being built
/// by the budget of its kind, as `resolve_wait` does: `XCL_GFX_PSO_WAIT_MS` for a graphics
/// one, `XCL_CS_PSO_WAIT_MS` for a compute one. Before, it waited by `XCL_PSO_WAIT_MS` alone
/// (unset: until the pipeline was built).
#[test]
fn a_retained_bind_waits_by_the_budget_of_its_kind() {
use std::time::{Duration, Instant};
let (short, long) = (Some(Duration::from_millis(20)), Some(Duration::from_secs(30)));
let mut builds = Vec::new();
for (standin, compute, built) in [(0x7E57_C090usize, false, 0x6F6Fusize), (0x7E57_C091, true, 0x6F70)] {
let (go, finish) = mpsc::channel::<()>();
submit_lazy(
standin,
compute,
Box::new(move || {
let _ = finish.recv_timeout(Duration::from_secs(5));
built
}),
0x5EED_C090 + compute as u64,
);
let p = entry(standin).expect("pending pipeline registered");
let (gfx, cs) = if compute { (long, short) } else { (short, long) };
let t0 = Instant::now();
assert_eq!(resolve_wait_pending_budgets(&p, standin, None, gfx, cs), standin, "compute {compute}: the stand-in past its budget");
assert!(t0.elapsed() < Duration::from_secs(1), "compute {compute}: waited {:?}", t0.elapsed());
builds.push((standin, built, go));
}
for (standin, built, go) in builds {
let _ = go.send(());
// (built before it is released: the worker does not release the made-up pipeline)
let deadline = Instant::now() + Duration::from_secs(5);
while is_pending(standin) && Instant::now() < deadline {
std::thread::sleep(Duration::from_millis(5));
}
assert_eq!(released(standin), built);
}
}
}
Loading