summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Present.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2025-10-27 18:14:57 -0500
committerJordan Woyak <jordan.woyak@gmail.com>2025-11-11 20:01:52 -0600
commitcc331feb020d71f109d41b7f841bd69caa96bbb3 (patch)
treed3e40a1a211a5d2e477bfe0d15d91e2f8302a0e8 /Source/Core/VideoCommon/Present.cpp
parentd4f68cb1647ca87e5364431f09ab38b3178ed3cd (diff)
VideoCommon: Make Presenter aware of the next swap time to eliminate unsafe usage of GetTicks() with ImmediateXFB + DualCore.
Diffstat (limited to 'Source/Core/VideoCommon/Present.cpp')
-rw-r--r--Source/Core/VideoCommon/Present.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/Present.cpp b/Source/Core/VideoCommon/Present.cpp
index ce4b62a85b..bedc1c128f 100644
--- a/Source/Core/VideoCommon/Present.cpp
+++ b/Source/Core/VideoCommon/Present.cpp
@@ -215,12 +215,14 @@ void Presenter::ViSwap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height,
}
}
-void Presenter::ImmediateSwap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u64 ticks)
+void Presenter::ImmediateSwap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height)
{
+ const u64 ticks = m_next_swap_estimated_ticks;
+
FetchXFB(xfb_addr, fb_width, fb_stride, fb_height, ticks);
PresentInfo present_info;
- present_info.emulated_timestamp = ticks; // TODO: This should be the time of the next VI field
+ present_info.emulated_timestamp = ticks;
present_info.frame_count = m_frame_count++;
present_info.reason = PresentInfo::PresentReason::Immediate;
present_info.present_count = m_present_count++;
@@ -235,6 +237,12 @@ void Presenter::ImmediateSwap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_
video_events.after_present_event.Trigger(present_info);
}
+void Presenter::SetNextSwapEstimatedTime(u64 ticks, TimePoint host_time)
+{
+ m_next_swap_estimated_ticks = ticks;
+ m_next_swap_estimated_time = host_time;
+}
+
void Presenter::ProcessFrameDumping(u64 ticks) const
{
if (g_frame_dumper->IsFrameDumping() && m_xfb_entry)
@@ -938,8 +946,10 @@ void Presenter::DoState(PointerWrap& p)
// This technically counts as the end of the frame
GetVideoEvents().after_frame_event.Trigger(Core::System::GetInstance());
- ImmediateSwap(m_last_xfb_addr, m_last_xfb_width, m_last_xfb_stride, m_last_xfb_height,
- m_last_xfb_ticks);
+ m_next_swap_estimated_ticks = m_last_xfb_ticks;
+ m_next_swap_estimated_time = Clock::now();
+
+ ImmediateSwap(m_last_xfb_addr, m_last_xfb_width, m_last_xfb_stride, m_last_xfb_height);
}
}