This commit is contained in:
TheLastRar 2025-12-16 02:17:55 +03:00 committed by GitHub
commit db528a5fa0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -1266,7 +1266,8 @@ void GSDeviceVK::SubmitCommandBuffer(VKSwapChain* present_swap_chain)
{
// VK_ERROR_OUT_OF_DATE_KHR is not fatal, just means we need to recreate our swap chain.
if (res == VK_ERROR_OUT_OF_DATE_KHR)
ResizeWindow(0, 0, m_window_info.surface_scale);
// Defer until next frame, otherwise resizing would invalidate swapchain before next present.
m_resize_requested = true;
else
LOG_VULKAN_ERROR(res, "vkQueuePresentKHR failed: ");
@ -2183,6 +2184,8 @@ bool GSDeviceVK::UpdateWindow()
void GSDeviceVK::ResizeWindow(s32 new_window_width, s32 new_window_height, float new_window_scale)
{
m_resize_requested = false;
if (!m_swap_chain || (m_swap_chain->GetWidth() == static_cast<u32>(new_window_width) &&
m_swap_chain->GetHeight() == static_cast<u32>(new_window_height)))
{
@ -2290,10 +2293,9 @@ GSDevice::PresentResult GSDeviceVK::BeginPresent(bool frame_skip)
return PresentResult::FrameSkipped;
}
VkResult res = m_swap_chain->AcquireNextImage();
VkResult res = m_resize_requested ? VK_ERROR_OUT_OF_DATE_KHR : m_swap_chain->AcquireNextImage();
if (res != VK_SUCCESS)
{
LOG_VULKAN_ERROR(res, "vkAcquireNextImageKHR() failed: ");
m_swap_chain->ReleaseCurrentImage();
if (res == VK_SUBOPTIMAL_KHR || res == VK_ERROR_OUT_OF_DATE_KHR)
@ -2313,6 +2315,8 @@ GSDevice::PresentResult GSDeviceVK::BeginPresent(bool frame_skip)
res = m_swap_chain->AcquireNextImage();
}
else
LOG_VULKAN_ERROR(res, "vkAcquireNextImageKHR() failed: ");
// This can happen when multiple resize events happen in quick succession.
// In this case, just wait until the next frame to try again.

View File

@ -367,6 +367,7 @@ public:
private:
std::unique_ptr<VKSwapChain> m_swap_chain;
bool m_resize_requested = false;
VkDescriptorSetLayout m_utility_ds_layout = VK_NULL_HANDLE;
VkPipelineLayout m_utility_pipeline_layout = VK_NULL_HANDLE;