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
9 changes: 9 additions & 0 deletions crates/xcl/src/hle/d3d12x/alloc_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ pub unsafe fn executed(queue: *mut c_void, lists: &[*mut c_void]) {
}
}

/// Whether the GPU may still run a recording made on the title's allocator `alloc`.
pub(super) unsafe fn in_flight(alloc: usize) -> bool {
let g = STATE.lock().unwrap();
let Some(s) = g.as_ref() else { return false };
let mine = s.cur.get(&alloc).into_iter().chain(s.aside.get(&alloc).into_iter().flatten()).chain([&alloc]);
let busy = mine.filter_map(|b| s.backings.get(b)).any(|b| b.marks.values().any(|(f, v)| f.GetCompletedValue() < *v));
busy
}

/// The title's allocator `alloc` is gone (its last Release): nothing of it stays here – a later
/// allocator may get its address, and must not go on with this one's PC allocators. The ones
/// made here go with it (those lists still record on are left alone: not freed, not tracked).
Expand Down
29 changes: 27 additions & 2 deletions crates/xcl/src/hle/d3d12x/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,22 @@ pub(super) fn inherit_for_split(from: *mut c_void, to: *mut c_void, allocator: u
console_list::hold_until_reset(old, blocks);
}

/// A submit is about to wait for the pipeline `this` has bound.
pub(super) fn want_bound(this: *mut c_void) {
super::pso_async::want(with(this, |s| s.pso));
}

/// A put-off dispatch that could not be recorded.
pub(super) fn dispatch_dropped() {
count(DISPATCHES_SKIPPED);
}

/// `to` goes on in the arena `from` took its pieces from (`from` takes no more).
pub(super) fn pass_arena(from: *mut c_void, to: *mut c_void) {
let arena = with(from, |s| std::mem::take(&mut s.arena));
with(to, |s| s.arena = arena);
}

/// 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 Expand Up @@ -253,7 +269,12 @@ fn signature_dispatches(sig: usize) -> bool {
pub(super) unsafe extern "system" fn execute_indirect(this: *mut c_void, sig: usize, max: u32, args: usize, args_off: u64, count_buf: usize, count_off: u64) {
type F = unsafe extern "system" fn(*mut c_void, usize, u32, usize, u64, usize, u64);
let pc: F = std::mem::transmute(super::real::orig_fn(this, 59));
let pso = super::pso_async::resolve_wait(with(this, |s| s.pso));
let pso = with(this, |s| s.pso);
let unbuilt_compute = signature_dispatches(sig) && super::pso_async::is_pending(pso) && super::real::is_console_compute(pso);
if unbuilt_compute && super::list_x::defer(this, super::list_x::Deferred::Indirect(sig, max, args, args_off, count_buf, count_off)) {
return super::pso_async::need_by_submit(pso);
}
let pso = super::pso_async::resolve_wait(pso);
let (gfx, compute) = (super::real::is_translated_graphics(pso), super::real::is_translated_compute(pso));
let (args_off, count_off) = (args_off + super::real::buffer_delta(args), count_off + super::real::buffer_delta(count_buf));
if !gfx && !compute {
Expand Down Expand Up @@ -801,7 +822,11 @@ pub(super) unsafe extern "system" fn set_pipeline_state(this: *mut c_void, pso:

/// #14 Dispatch: with a translated pipeline, on XCL's ABI with the kept root arguments
pub(super) unsafe extern "system" fn dispatch(this: *mut c_void, x: u32, y: u32, z: u32) {
let pso = super::pso_async::resolve_wait(with(this, |s| s.pso));
let pso = with(this, |s| s.pso);
if super::pso_async::is_pending(pso) && super::list_x::defer(this, super::list_x::Deferred::Dispatch(x, y, z)) {
return super::pso_async::need_by_submit(pso);
}
let pso = super::pso_async::resolve_wait(pso);
let Some(list) = ID3D12GraphicsCommandList::from_raw_borrowed(&this) else { return };
if !super::real::is_translated_compute(pso) {
// a console pipeline without a translation (including a background build that
Expand Down
Loading
Loading