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
30 changes: 27 additions & 3 deletions crates/xcl/src/hle/d3d12x/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,25 @@ pub(super) fn note_signature_dispatches(sig: usize, dispatches: bool) {
}
}

/// command signatures whose arguments only draw (Draw, DrawIndexed, DispatchMesh): an
/// ExecuteIndirect of one leaves no state behind, so it can be recorded at the submit (noted at
/// every creation, as `DISPATCH_SIGNATURES`)
static DRAW_ONLY_SIGNATURES: Mutex<Option<std::collections::HashSet<usize>>> = Mutex::new(None);

pub(super) fn note_signature_draws_only(sig: usize, draws_only: bool) {
let mut s = DRAW_ONLY_SIGNATURES.lock().unwrap();
let s = s.get_or_insert_with(Default::default);
if draws_only {
s.insert(sig);
} else {
s.remove(&sig);
}
}

fn signature_draws_only(sig: usize) -> bool {
DRAW_ONLY_SIGNATURES.lock().unwrap().as_ref().is_some_and(|s| s.contains(&sig))
}

fn signature_dispatches(sig: usize) -> bool {
DISPATCH_SIGNATURES.lock().unwrap().as_ref().is_some_and(|s| s.contains(&sig))
}
Expand All @@ -270,8 +289,13 @@ pub(super) unsafe extern "system" fn execute_indirect(this: *mut c_void, sig: us
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 raw_pso = with(this, |s| s.pso);
let unbuilt_compute = signature_dispatches(sig) && super::pso_async::is_pending(raw_pso) && super::real::is_console_compute(raw_pso);
if unbuilt_compute && super::list_x::defer(this, super::list_x::Deferred::Indirect(sig, max, args, args_off, count_buf, count_off)) {
let pending = super::pso_async::is_pending(raw_pso);
let unbuilt_compute = signature_dispatches(sig) && pending && super::real::is_console_compute(raw_pso);
// a graphics one too: the title's thread goes on to its next binds, whose builds then run on
// the workers at once instead of one after another here (only a signature that just draws:
// vertex / index buffer views and root arguments it sets would stay on the list after it)
let unbuilt_graphics = signature_draws_only(sig) && pending && !super::real::is_console_compute(raw_pso);
if (unbuilt_compute || unbuilt_graphics) && 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(raw_pso);
}
let pso = super::pso_async::resolve_wait(raw_pso);
Expand Down Expand Up @@ -1073,7 +1097,7 @@ pub(super) fn counts_snapshot() -> [u64; 5] {
std::array::from_fn(|k| COUNTS[k].load(Ordering::Relaxed))
}

#[cfg(test)]
/// The pipeline `list` has bound (as the title made it; 0: none).
pub(super) fn tracked_pso(list: *mut c_void) -> usize {
STATES
.lock()
Expand Down
2 changes: 2 additions & 0 deletions crates/xcl/src/hle/d3d12x/device_x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,8 @@ pub(super) unsafe extern "system" fn create_command_signature_x(this: *mut c_voi
}
if hr >= 0 && !ppv.is_null() && !(*ppv).is_null() {
super::bind::note_signature_dispatches(*ppv as usize, list.iter().any(|a| a[0] == D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH.0 as u32));
let draws = [D3D12_INDIRECT_ARGUMENT_TYPE_DRAW, D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED, D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH].map(|t| t.0 as u32);
super::bind::note_signature_draws_only(*ppv as usize, !list.is_empty() && list.iter().all(|a| draws.contains(&a[0])));
}
hr
}
Expand Down
Loading
Loading