From b5a91e1dfaf62924e05421de48987c105546f8ca Mon Sep 17 00:00:00 2001 From: degasus Date: Sat, 8 Oct 2016 00:04:25 +0200 Subject: [PATCH] Framedumps: Add finish() function to limit memory lifetime. --- Source/Core/VideoBackends/D3D/Render.cpp | 1 + Source/Core/VideoBackends/D3D12/Render.cpp | 1 + Source/Core/VideoBackends/OGL/Render.cpp | 1 + Source/Core/VideoBackends/Vulkan/Renderer.cpp | 1 + Source/Core/VideoCommon/RenderBase.cpp | 4 ++++ Source/Core/VideoCommon/RenderBase.h | 1 + 6 files changed, 9 insertions(+) diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index c298287e05..730bd731a8 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -891,6 +891,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, formatBufferDump((u8*)map.pData, image.data(), source_width, source_height, map.RowPitch); DumpFrameData(image.data(), source_width, source_height, AVIDump::DumpFormat::FORMAT_BGR, true); + FinishFrameData(); D3D::context->Unmap(s_screenshot_texture, 0); } diff --git a/Source/Core/VideoBackends/D3D12/Render.cpp b/Source/Core/VideoBackends/D3D12/Render.cpp index 90709bd4eb..0646490044 100644 --- a/Source/Core/VideoBackends/D3D12/Render.cpp +++ b/Source/Core/VideoBackends/D3D12/Render.cpp @@ -869,6 +869,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height source_height, dst_location.PlacedFootprint.Footprint.RowPitch); DumpFrameData(image.data(), source_width, source_height, AVIDump::DumpFormat::FORMAT_BGR, true); + FinishFrameData(); D3D12_RANGE write_range = {}; s_screenshot_texture->Unmap(0, &write_range); diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 39744b5211..27aff46e61 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -1470,6 +1470,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, DumpFrameData(image.data(), flipped_trc.GetWidth(), flipped_trc.GetHeight(), AVIDump::DumpFormat::FORMAT_RGBA, true); + FinishFrameData(); } // Finish up the current frame, print some stats diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index e149e17118..c9721927de 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -497,6 +497,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height static_cast(m_screenshot_render_texture->GetWidth()), static_cast(m_screenshot_render_texture->GetHeight()), AVIDump::DumpFormat::FORMAT_RGBA); + FinishFrameData(); } } diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 0d7d44622b..6f1a581b6e 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -605,6 +605,10 @@ void Renderer::DumpFrameData(const u8* data, int w, int h, AVIDump::DumpFormat f #endif } +void Renderer::FinishFrameData() +{ +} + void Renderer::FlipImageData(u8* data, int w, int h, int pixel_width) { for (int y = 0; y < h / 2; ++y) diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index 074c508a26..9cb957c986 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -150,6 +150,7 @@ protected: bool IsFrameDumping(); void DumpFrameData(const u8* data, int w, int h, AVIDump::DumpFormat format, bool swap_upside_down = false); + void FinishFrameData(); static volatile bool s_bScreenshot; static std::mutex s_criticalScreenshot;