Skip to content
Merged
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
21 changes: 21 additions & 0 deletions crates/xcl/src/hle/d3d12x/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ pub(super) fn clear_state(list: *mut c_void, pso: usize) {
});
}

/// Carry bound pipeline and root-signature / root-argument state from `from` to `to` across a
/// deferred mid-list split (`to` records into `allocator` with its own fresh UMA arena while
/// `from` retains its previously allocated blocks until `allocator` resets).
pub(super) fn inherit_for_split(from: *mut c_void, to: *mut c_void, allocator: usize) {
let (layout, args, layout_gfx, args_gfx, rs_gfx, pso) = with(from, |s| {
(s.layout.clone(), s.args.clone(), s.layout_gfx.clone(), s.args_gfx.clone(), s.rs_gfx, s.pso)
});
let (old, blocks) = with(to, |s| {
let old = std::mem::replace(&mut s.allocator, allocator);
s.arena = Default::default();
s.layout = layout;
s.args = args;
s.layout_gfx = layout_gfx;
s.args_gfx = args_gfx;
s.rs_gfx = rs_gfx;
s.pso = pso;
(old, std::mem::take(&mut s.uma))
});
console_list::hold_until_reset(old, blocks);
}

/// The list is gone.
pub(super) fn forget(list: *mut c_void) {
if let Some(s) = STATES.lock().unwrap().as_mut().and_then(|m| m.remove(&(list as usize))) {
Expand Down
26 changes: 26 additions & 0 deletions crates/xcl/src/hle/d3d12x/fence_x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ struct Fence {
cell: Option<&'static Cell>,
/// the highest value a queue was told to signal
signalled: u64,
/// the highest value a queue was told to wait for
waited: u64,
}

/// (fences are never freed: XCL holds a reference to each)
Expand Down Expand Up @@ -77,6 +79,13 @@ pub(super) unsafe fn note_queue_signal(fence: usize, value: u64) {
}
}

/// A queue was told to wait for `fence` (one of the title's) to reach `value`.
pub(super) fn note_queue_wait(fence: usize, value: u64) {
let mut g = FENCES.lock().unwrap_or_else(|e| e.into_inner());
let f = g.get_or_insert_with(HashMap::new).entry(fence).or_default();
f.waited = f.waited.max(value);
}

/// The CPU signalled `fence`.
pub(super) fn note_cpu_signal(fence: usize) {
let known = FENCES.lock().unwrap_or_else(|e| e.into_inner()).as_ref().is_some_and(|m| m.get(&fence).is_some_and(|f| f.cell.is_some()));
Expand All @@ -85,6 +94,23 @@ pub(super) fn note_cpu_signal(fence: usize) {
}
}

/// Diagnostic summary of title fences whose completed value lags their signalled or waited value.
pub(super) fn pending_summary() -> String {
let g = FENCES.lock().unwrap_or_else(|e| e.into_inner());
let mut parts = Vec::new();
for (&p, f) in g.iter().flatten() {
let done = unsafe { borrowed(p, |f| f.GetCompletedValue()) }.unwrap_or(0);
if done < f.signalled || done < f.waited {
parts.push(format!("{p:#x}(done={done:#x}/sig={:#x}/wait={:#x},cell={})", f.signalled, f.waited, f.cell.is_some()));
}
}
if parts.is_empty() {
"none".into()
} else {
parts.join(", ")
}
}

/// fence #12: the address of its completed value
pub(super) unsafe extern "system" fn completed_value_address(this: *mut c_void) -> *const u64 {
let (cell, pending) = {
Expand Down
Loading
Loading