diff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs index b7560f861e..06544b31ba 100644 --- a/crates/xcl/src/hle/d3d12x/sparse.rs +++ b/crates/xcl/src/hle/d3d12x/sparse.rs @@ -2205,6 +2205,7 @@ mod tests { assert!(s.value > v, "the unmapping is sent"); assert!(!s.flush_parked(), "nothing left to flush"); s.wait_for(s.value); + wait_for_quarantine(&s); assert!(s.drain_quarantined()); assert!(s.free.contains(&tile)); @@ -2215,6 +2216,7 @@ mod tests { s.free.clear(); assert!(s.flush_parked()); s.wait_for(s.value); + wait_for_quarantine(&s); s.commit_range(base + TILE, TILE); assert!(s.parked.is_empty()); assert_eq!(s.mapped[&(base + TILE)].pool, tile); @@ -2226,6 +2228,19 @@ mod tests { } } + /// Waits until the GPU is past every mark the quarantined tiles wait for. Besides the sparse + /// queue's, those are the marks of every title queue in `present::known_queues`, which in a + /// parallel run includes the queues of other tests that can still have work in flight. + unsafe fn wait_for_quarantine(s: &State) { + let start = std::time::Instant::now(); + for (f, v) in s.quarantined.iter().flat_map(|b| b.marks.iter().flatten()) { + while f.GetCompletedValue() < *v { + assert!(start.elapsed() < std::time::Duration::from_secs(30), "a queue did not pass its quarantine mark in 30 s"); + std::thread::sleep(std::time::Duration::from_millis(1)); + } + } + } + struct SignalOnDrop(ID3D12Fence, u64); impl Drop for SignalOnDrop { @@ -2327,6 +2342,7 @@ mod tests { gate.Signal(1).expect("release sparse queue"); s.wait_for(s.value); + wait_for_quarantine(&s); assert!(s.drain_quarantined(), "completed unmap batch should drain after fence completion"); assert!(s.free.contains(&tile), "unmapped tile must return to free list once unmap fence completes"); drop(_unblock);