diff options
author | Joshua Ashton <joshua@froggi.es> | 2021-04-11 09:46:28 +0200 |
---|---|---|
committer | Joshua Ashton <joshua@froggi.es> | 2021-04-11 10:27:50 +0200 |
commit | bcf58c82108c32aa3e2118be152bdc728bf4744e (patch) | |
tree | 0c607a634db7077157101f9f703a6f77c0a48d86 | |
parent | Merge pull request #6167 from Morph1984/time-fix (diff) | |
download | yuzu-bcf58c82108c32aa3e2118be152bdc728bf4744e.tar yuzu-bcf58c82108c32aa3e2118be152bdc728bf4744e.tar.gz yuzu-bcf58c82108c32aa3e2118be152bdc728bf4744e.tar.bz2 yuzu-bcf58c82108c32aa3e2118be152bdc728bf4744e.tar.lz yuzu-bcf58c82108c32aa3e2118be152bdc728bf4744e.tar.xz yuzu-bcf58c82108c32aa3e2118be152bdc728bf4744e.tar.zst yuzu-bcf58c82108c32aa3e2118be152bdc728bf4744e.zip |
-rw-r--r-- | src/video_core/renderer_vulkan/renderer_vulkan.cpp | 5 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_swapchain.cpp | 8 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_swapchain.h | 2 |
3 files changed, 10 insertions, 5 deletions
diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index 1cc720ddd..14e5f36e2 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -143,7 +143,10 @@ void RendererVulkan::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { scheduler.WaitWorker(); - swapchain.AcquireNextImage(); + while (!swapchain.AcquireNextImage()) { + swapchain.Create(layout.width, layout.height, is_srgb); + blit_screen.Recreate(); + } const VkSemaphore render_semaphore = blit_screen.Draw(*framebuffer, use_accelerated); scheduler.Flush(render_semaphore); diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp index 0b63bd6c8..dfd5c65ba 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.cpp +++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp @@ -82,11 +82,13 @@ void VKSwapchain::Create(u32 width, u32 height, bool srgb) { resource_ticks.resize(image_count); } -void VKSwapchain::AcquireNextImage() { - device.GetLogical().AcquireNextImageKHR(*swapchain, std::numeric_limits<u64>::max(), - *present_semaphores[frame_index], {}, &image_index); +bool VKSwapchain::AcquireNextImage() { + const VkResult result = + device.GetLogical().AcquireNextImageKHR(*swapchain, std::numeric_limits<u64>::max(), + *present_semaphores[frame_index], {}, &image_index); scheduler.Wait(resource_ticks[image_index]); + return result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR; } bool VKSwapchain::Present(VkSemaphore render_semaphore) { diff --git a/src/video_core/renderer_vulkan/vk_swapchain.h b/src/video_core/renderer_vulkan/vk_swapchain.h index a728511e0..adc8d27cf 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.h +++ b/src/video_core/renderer_vulkan/vk_swapchain.h @@ -28,7 +28,7 @@ public: void Create(u32 width, u32 height, bool srgb); /// Acquires the next image in the swapchain, waits as needed. - void AcquireNextImage(); + bool AcquireNextImage(); /// Presents the rendered image to the swapchain. Returns true when the swapchains had to be /// recreated. Takes responsability for the ownership of fence. |