Skip to content
Open
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions crates/xcl/src/hle/d3d12x/alloc_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,25 @@ pub(super) fn stand_in_for_test(alloc: usize, pc: usize) {
STATE.lock().unwrap().get_or_insert_with(State::default).cur.insert(alloc, pc);
}

/// Whether STATE still keys anything by the fake id `raw` (a backing or a recording list).
#[cfg(test)]
pub(super) fn tracks_for_test(raw: usize) -> bool {
STATE.lock().unwrap().as_ref().is_some_and(|s| s.backings.contains_key(&raw) || s.of_list.contains_key(&raw))
}

/// Drop the fake backing `raw` and its users' recordings without releasing it: it has no COM
/// object for a later sweep to release.
#[cfg(test)]
pub(super) fn drop_synthetic_for_test(raw: usize) {
let mut g = STATE.lock().unwrap();
let Some(s) = g.as_mut() else { return };
if let Some(gone) = s.backings.remove(&raw) {
for l in gone.users {
s.of_list.remove(&l);
}
}
}

/// The PC allocator the title's allocator `alloc` stands for now.
pub fn current(alloc: usize) -> usize {
if !enabled() {
Expand Down
1 change: 1 addition & 0 deletions crates/xcl/src/hle/d3d12x/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7927,6 +7927,7 @@ void main(uint t : SV_GroupIndex) {
// (before the assertions: nothing of this test stays)
let left = ALLOC_RES.lock().unwrap().as_mut().and_then(|m| m.remove(&busy));
drop(left);
super::super::alloc_pool::drop_synthetic_for_test(busy);
assert!(held_done.is_empty(), "the released allocator's buffers do not wait for a Reset that never comes");
assert_eq!(freed, vec![a_raw], "they are kept for reuse");
assert_eq!(held_busy, vec![b_raw], "a list still records on the other: its buffers stay");
Expand Down
7 changes: 5 additions & 2 deletions crates/xcl/src/hle/d3d12x/list_x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8114,7 +8114,7 @@ mod tests {
);
assert_eq!(super::super::console_list::take_pending_for_test(0x111), vec![0x4444]);

LISTS.lock().unwrap().as_mut().unwrap().remove(&key);
on_release(key);
super::super::bind::remove_state_for_test(list);
unsafe {
super::super::alloc_pool::forget(0x111);
Expand Down Expand Up @@ -8154,14 +8154,17 @@ mod tests {
let held_for_pc = super::super::console_list::take_pending_for_test(pc);
let held_for_title = super::super::console_list::take_pending_for_test(title);

LISTS.lock().unwrap().as_mut().unwrap().remove(&key);
on_release(key);
super::super::bind::remove_state_for_test(list);
super::super::alloc_pool::stand_in_for_test(title, title);
unsafe {
super::super::alloc_pool::forget(title);
super::super::alloc_pool::forget(pc);
super::super::alloc_pool::forget(other);
}
// (a backing left on a fake id is released through it when a reused stack address goes)
let left = [key, title, pc, other].map(super::super::alloc_pool::tracks_for_test);
assert_eq!(left, [false; 4], "the test leaves nothing keyed by its fake ids");
assert_eq!(recording_on, pc, "the recording is on the PC allocator the title's allocator stands for");
assert_eq!(held_for_pc, vec![block]);
assert!(held_for_title.is_empty());
Expand Down
Loading