diff --git a/crates/xcl/src/hle/api_cost.rs b/crates/xcl/src/hle/api_cost.rs index 8178e3b93e..dd2771cd70 100644 --- a/crates/xcl/src/hle/api_cost.rs +++ b/crates/xcl/src/hle/api_cost.rs @@ -22,8 +22,17 @@ 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, @@ -31,7 +40,7 @@ pub enum Call { 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"), @@ -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"), diff --git a/crates/xcl/src/hle/d3d12x/present.rs b/crates/xcl/src/hle/d3d12x/present.rs index d6daec1221..ab73084e39 100644 --- a/crates/xcl/src/hle/d3d12x/present.rs +++ b/crates/xcl/src/hle/d3d12x/present.rs @@ -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. @@ -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 }; @@ -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::(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; } @@ -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() }; @@ -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") {