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
17 changes: 15 additions & 2 deletions crates/xcl/src/hle/api_cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,25 @@ pub enum Call {
Submit,
/// PresentX, or a present of the fallback's at a console method
Present,
/// a present's wait for the copy of the frame before
/// a present's wait for the copy of the frame before (this one and the parts below run
/// inside `Present`, or inside `Submit` when the fallback presents on a submission)
PresentCopyWait,
/// a present's wait for the one before it (`PresentX`'s lock and the presenter's)
PresentLockWait,
/// a present's copy (or composite) of the frame, recorded and submitted
PresentRecord,
/// the swap chain's Present (DXGI holds it while the frames before it are queued)
PresentSwap,
/// a present's wait for the copy of a frame dump (`XCL_FRAME_DUMP`, `XCL_DUMP_TARGETS`)
PresentDumpWait,
WaitFrameEvent,
/// the title's blocking waits for a fence (SetEventOnCompletion without an event)
FenceWait,
/// copies back landed for the title's look at a fence (`sparse::settle_readbacks_within`)
FenceSettle,
}

pub const CALLS: [(Call, &str); 12] = [
pub const CALLS: [(Call, &str); 16] = [
(Call::PlacedTexture, "placed textures"),
(Call::PlacedBuffer, "placed buffers"),
(Call::PhysicalPages, "physical page calls"),
Expand All @@ -41,6 +50,10 @@ pub const CALLS: [(Call, &str); 12] = [
(Call::Submit, "ExecuteCommandLists"),
(Call::Present, "presents"),
(Call::PresentCopyWait, "waits of a present for the last frame's copy"),
(Call::PresentLockWait, "waits of a present for the one before"),
(Call::PresentRecord, "copies of a present recorded and submitted"),
(Call::PresentSwap, "swap chain Presents"),
(Call::PresentDumpWait, "waits of a present for a frame dump's copy"),
(Call::WaitFrameEvent, "WaitFrameEventX"),
(Call::FenceWait, "blocking fence waits"),
(Call::FenceSettle, "copies back settled at fence looks"),
Expand Down
16 changes: 14 additions & 2 deletions crates/xcl/src/hle/d3d12x/present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ pub unsafe extern "system" fn present_x(queue: *mut c_void, plane_count: u32, pl
return 0;
}
let token = (planes as *const u64).read_unaligned();
let _present = PRESENTX_LOCK.lock().unwrap();
let _present = {
let _cost = super::look_stats::deep().then(|| crate::hle::api_cost::time(crate::hle::api_cost::Call::PresentLockWait));
PRESENTX_LOCK.lock().unwrap()
};
present_x_frame(queue, plane_count, planes);
// The title can use flip statistics to decide when to reuse its buffer.
// Queue our copy before reporting the flip.
Expand Down Expand Up @@ -1058,6 +1061,7 @@ unsafe fn present_now(min_interval: Duration, frame: Option<(usize, Vec<(usize,
let _reset = Reset;
let is_frame = frame.is_some();
let (queue, raw_planes, mut guard) = if let Some((queue, planes)) = frame {
let _cost = super::look_stats::deep().then(|| crate::hle::api_cost::time(crate::hle::api_cost::Call::PresentLockWait));
(queue, planes, PRESENTER.lock().unwrap())
} else {
let Ok(guard) = PRESENTER.try_lock() else { return };
Expand Down Expand Up @@ -1129,6 +1133,8 @@ unsafe fn present_now(min_interval: Duration, frame: Option<(usize, Vec<(usize,
}
let Some(sc) = p.sc.clone() else { return };
let Ok(bb) = sc.GetBuffer::<ID3D12Resource>(sc.GetCurrentBackBufferIndex()) else { return };
// (up to its Signal: what is left of a present besides the waits and the swap chain's call)
let recording = super::look_stats::deep().then(|| crate::hle::api_cost::time(crate::hle::api_cost::Call::PresentRecord));
if p.alloc.Reset().is_err() || p.list.Reset(&p.alloc, None).is_err() {
return;
}
Expand Down Expand Up @@ -1279,10 +1285,12 @@ unsafe fn present_now(min_interval: Duration, frame: Option<(usize, Vec<(usize,
crate::xlog_error!("present: submit copy: {e}");
return;
}
drop(recording);
if dumping_targets {
super::targets::submitted();
}
let presented = {
let _cost = super::look_stats::deep().then(|| crate::hle::api_cost::time(crate::hle::api_cost::Call::PresentSwap));
let _in_driver = super::watch::in_driver(super::watch::Call::Present);
sc.Present(0, DXGI_PRESENT(0)).ok()
};
Expand All @@ -1294,7 +1302,11 @@ unsafe fn present_now(min_interval: Duration, frame: Option<(usize, Vec<(usize,
}
p.last = Instant::now();
if !p.dumps.is_empty() {
match fence::wait(&p.fence, p.value, &p.dev, Some(p.event), 2000) {
let copied = {
let _cost = super::look_stats::deep().then(|| crate::hle::api_cost::time(crate::hle::api_cost::Call::PresentDumpWait));
fence::wait(&p.fence, p.value, &p.dev, Some(p.event), 2000)
};
match copied {
Ok(()) => {
for dump in p.dumps.drain(..) {
if dump.tag.starts_with("twin") {
Expand Down
Loading