Skip to content
Open
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
16 changes: 16 additions & 0 deletions crates/xcl/src/hle/d3d12x/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
Loading