From 3be63221c7a1003ce6177e823da5ec399cd51015 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Tue, 31 Jan 2023 00:59:17 +1300 Subject: [PATCH] Renderer still needs to track swaps for savestates --- Source/Core/VideoCommon/AsyncRequests.cpp | 2 ++ Source/Core/VideoCommon/BPStructs.cpp | 5 +++-- Source/Core/VideoCommon/RenderBase.cpp | 13 +++++++------ Source/Core/VideoCommon/RenderBase.h | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Source/Core/VideoCommon/AsyncRequests.cpp b/Source/Core/VideoCommon/AsyncRequests.cpp index 8c254d4e71..7cbb134f7e 100644 --- a/Source/Core/VideoCommon/AsyncRequests.cpp +++ b/Source/Core/VideoCommon/AsyncRequests.cpp @@ -158,6 +158,8 @@ void AsyncRequests::HandleEvent(const AsyncRequests::Event& e) case Event::SWAP_EVENT: g_presenter->ViSwap(e.swap_event.xfbAddr, e.swap_event.fbWidth, e.swap_event.fbStride, e.swap_event.fbHeight, e.time); + g_renderer->TrackSwaps(e.swap_event.xfbAddr, e.swap_event.fbWidth, e.swap_event.fbStride, + e.swap_event.fbHeight, e.time); break; case Event::BBOX_READ: diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index 865d73dbed..1985ac6527 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -350,8 +350,9 @@ static void BPWritten(PixelShaderManager& pixel_shader_manager, if (g_ActiveConfig.bImmediateXFB) { // below div two to convert from bytes to pixels - it expects width, not stride - g_presenter->ImmediateSwap(destAddr, destStride / 2, destStride, height, - Core::System::GetInstance().GetCoreTiming().GetTicks()); + u64 ticks = Core::System::GetInstance().GetCoreTiming().GetTicks(); + g_presenter->ImmediateSwap(destAddr, destStride / 2, destStride, height, ticks); + g_renderer->TrackSwaps(destAddr, destStride / 2, destStride, height, ticks); } else { diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 0e8bb41393..e252921c9f 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -365,7 +365,7 @@ void Renderer::OnConfigChanged(u32 bits) UpdateWidescreen(); } -void Renderer::Swap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u64 ticks) +void Renderer::TrackSwaps(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u64 ticks) { if (xfb_addr && fb_width && fb_stride && fb_height) { @@ -412,13 +412,14 @@ void Renderer::DoState(PointerWrap& p) if (p.IsReadMode()) { - // Force the next xfb to be displayed. - g_presenter->ClearLastXfbId(); - m_was_orthographically_anamorphic = false; - // And actually display it. - Swap(m_last_xfb_addr, m_last_xfb_width, m_last_xfb_stride, m_last_xfb_height, m_last_xfb_ticks); + // This technically counts as the end of the frame + AfterFrameEvent::Trigger(); + + // re-display the most recent XFB + g_presenter->ImmediateSwap(m_last_xfb_addr, m_last_xfb_width, m_last_xfb_stride, + m_last_xfb_height, m_last_xfb_ticks); } #if defined(HAVE_FFMPEG) diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index 520acdb8e4..cceddea638 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -91,8 +91,8 @@ public: virtual u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data); virtual void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points); - // Finish up the current frame, print some stats - void Swap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u64 ticks); + // Track swaps for save-states + void TrackSwaps(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u64 ticks); bool IsGameWidescreen() const { return m_is_game_widescreen; }