From de632fc9c8d7d026ccad1afc2f72224ee9639023 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 26 Jan 2018 16:23:24 +1000 Subject: Renderer: Handle resize events on-demand instead of polling We now differentiate between a resize event and surface change/destroyed event, reducing the overhead for resizes in the Vulkan backend. It is also now now safe to change the surface multiple times if the video thread is lagging behind. --- Source/Core/VideoCommon/RenderBase.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/RenderBase.cpp') diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 9179fe0fa6..1f0da14269 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -400,6 +400,21 @@ bool Renderer::IsHeadless() const return !m_surface_handle; } +void Renderer::ChangeSurface(void* new_surface_handle) +{ + std::lock_guard lock(m_swap_mutex); + m_new_surface_handle = new_surface_handle; + m_surface_changed.Set(); +} + +void Renderer::ResizeSurface(int new_width, int new_height) +{ + std::lock_guard lock(m_swap_mutex); + m_new_backbuffer_width = new_width; + m_new_backbuffer_height = new_height; + m_surface_resized.Set(); +} + std::tuple Renderer::ScaleToDisplayAspectRatio(const int width, const int height) const { @@ -651,7 +666,10 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const m_last_xfb_region = xfb_rect; // TODO: merge more generic parts into VideoCommon - g_renderer->SwapImpl(xfb_entry->texture.get(), xfb_rect, ticks, xfb_entry->gamma); + { + std::lock_guard guard(m_swap_mutex); + g_renderer->SwapImpl(xfb_entry->texture.get(), xfb_rect, ticks, xfb_entry->gamma); + } // Update the window size based on the frame that was just rendered. // Due to depending on guest state, we need to call this every frame. -- cgit v1.2.3