Merge pull request #13087 from TellowKrinkle/PresentSkip

VideoBackends:Vulkan: Prevent freezes during window resize on Linux
This commit is contained in:
JMC47
2024-10-02 21:09:25 -04:00
committed by GitHub
18 changed files with 76 additions and 34 deletions

View File

@ -101,7 +101,10 @@ public:
// Binds the backbuffer for rendering. The buffer will be cleared immediately after binding.
// This is where any window size changes are detected, therefore m_backbuffer_width and/or
// m_backbuffer_height may change after this function returns.
virtual void BindBackbuffer(const ClearColor& clear_color = {}) {}
// If this returns false, a problem occurred binding the backbuffer.
// Don't render anything to it, but still call `PresentBackbuffer`, which will reset any
// per-frame resources and prepare for the next frame.
virtual bool BindBackbuffer(const ClearColor& clear_color = {}) { return true; }
// Presents the backbuffer to the window system, or "swaps buffers".
virtual void PresentBackbuffer() {}

View File

@ -844,10 +844,10 @@ void Presenter::Present()
UpdateDrawRectangle();
g_gfx->BeginUtilityDrawing();
g_gfx->BindBackbuffer({{0.0f, 0.0f, 0.0f, 1.0f}});
const bool backbuffer_bound = g_gfx->BindBackbuffer({{0.0f, 0.0f, 0.0f, 1.0f}});
// Render the XFB to the screen.
if (m_xfb_entry)
if (backbuffer_bound && m_xfb_entry)
{
// Adjust the source rectangle instead of using an oversized viewport to render the XFB.
auto render_target_rc = GetTargetRectangle();
@ -860,7 +860,8 @@ void Presenter::Present()
if (m_onscreen_ui)
{
m_onscreen_ui->Finalize();
m_onscreen_ui->DrawImGui();
if (backbuffer_bound)
m_onscreen_ui->DrawImGui();
}
// Present to the window system.