From ec8f46b02c21fec9b24518e6788a4df413baf8f9 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Tue, 31 Jan 2023 01:03:46 +1300 Subject: [PATCH] Expose Renderer's Framecount We don't want to move it, because we want to complete this refactor without changing savestate version --- Source/Core/VideoCommon/Present.cpp | 8 ++++---- Source/Core/VideoCommon/Present.h | 1 - Source/Core/VideoCommon/RenderBase.h | 5 ++++- Source/Core/VideoCommon/TextureCacheBase.cpp | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Source/Core/VideoCommon/Present.cpp b/Source/Core/VideoCommon/Present.cpp index 73532367f9..0612d96d3b 100644 --- a/Source/Core/VideoCommon/Present.cpp +++ b/Source/Core/VideoCommon/Present.cpp @@ -84,12 +84,12 @@ void Presenter::ViSwap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, present_info.emulated_timestamp = ticks; if (unique) { - present_info.frame_count = m_frame_count++; + present_info.frame_count = g_renderer->FrameCountIncrement(); present_info.reason = PresentInfo::PresentReason::VideoInterface; } else { - present_info.frame_count = m_frame_count - 1; + present_info.frame_count = g_renderer->FrameCount() - 1; // Previous frame present_info.reason = PresentInfo::PresentReason::VideoInterfaceDuplicate; } present_info.present_count = m_present_count; @@ -115,7 +115,7 @@ void Presenter::ImmediateSwap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_ PresentInfo present_info; present_info.emulated_timestamp = ticks; - present_info.frame_count = m_frame_count++; + present_info.frame_count = g_renderer->FrameCountIncrement(); present_info.reason = PresentInfo::PresentReason::Immediate; present_info.present_count = m_present_count++; @@ -145,7 +145,7 @@ void Presenter::ProcessFrameDumping(u64 ticks) const } g_frame_dumper->DumpCurrentFrame(m_xfb_entry->texture.get(), m_xfb_rect, target_rect, ticks, - m_frame_count); + g_renderer->FrameCount()); } } diff --git a/Source/Core/VideoCommon/Present.h b/Source/Core/VideoCommon/Present.h index 4c870c93b0..5e84d5aada 100644 --- a/Source/Core/VideoCommon/Present.h +++ b/Source/Core/VideoCommon/Present.h @@ -128,7 +128,6 @@ private: std::unique_ptr m_post_processor; std::unique_ptr m_onscreen_ui; - u64 m_frame_count = 0; u64 m_present_count = 0; }; diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index cceddea638..209d915975 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -104,7 +104,8 @@ public: bool CalculateTargetSize(); - int m_frame_count = 0; + int FrameCount() const { return m_frame_count; } + int FrameCountIncrement() { return m_frame_count++; } void OnConfigChanged(u32 bits); @@ -131,6 +132,8 @@ private: u32 m_last_xfb_stride = 0; u32 m_last_xfb_height = 0; + int m_frame_count = 0; + EventHook m_update_widescreen_handle; EventHook m_config_changed_handle; }; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 6029f09c5c..947b2e5965 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -783,7 +783,7 @@ void TextureCacheBase::OnFrameEnd() g_texture_cache->FlushEFBCopies(); } - g_texture_cache->Cleanup(g_renderer->m_frame_count); + g_texture_cache->Cleanup(g_renderer->FrameCount()); } void TCacheEntry::DoState(PointerWrap& p)