summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/RenderBase.cpp
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2018-01-26 16:23:24 +1000
committerStenzek <stenzek@gmail.com>2018-02-20 01:15:55 +1000
commitde632fc9c8d7d026ccad1afc2f72224ee9639023 (patch)
treecf182d393ccde05c26d3fa27bc7007e134fbadda /Source/Core/VideoCommon/RenderBase.cpp
parent5baf3bbe2e2fb62cac9c1bb4cded45644ebfd3bb (diff)
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.
Diffstat (limited to 'Source/Core/VideoCommon/RenderBase.cpp')
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp20
1 files changed, 19 insertions, 1 deletions
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<std::mutex> 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<std::mutex> lock(m_swap_mutex);
+ m_new_backbuffer_width = new_width;
+ m_new_backbuffer_height = new_height;
+ m_surface_resized.Set();
+}
+
std::tuple<float, float> 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<std::mutex> 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.