summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan/vk_swapchain.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-06-03 22:42:24 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:34 +0200
commitf45f7b5c2a869123340591cec6db58c33a5fd3ab (patch)
tree89fbd0df48bc24f3c3e9996ce4f88402debf6e77 /src/video_core/renderer_vulkan/vk_swapchain.cpp
parentshader: Fix VertexA Shaders. (diff)
downloadyuzu-f45f7b5c2a869123340591cec6db58c33a5fd3ab.tar
yuzu-f45f7b5c2a869123340591cec6db58c33a5fd3ab.tar.gz
yuzu-f45f7b5c2a869123340591cec6db58c33a5fd3ab.tar.bz2
yuzu-f45f7b5c2a869123340591cec6db58c33a5fd3ab.tar.lz
yuzu-f45f7b5c2a869123340591cec6db58c33a5fd3ab.tar.xz
yuzu-f45f7b5c2a869123340591cec6db58c33a5fd3ab.tar.zst
yuzu-f45f7b5c2a869123340591cec6db58c33a5fd3ab.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_vulkan/vk_swapchain.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp
index a71b0b01e..d990eefba 100644
--- a/src/video_core/renderer_vulkan/vk_swapchain.cpp
+++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp
@@ -65,7 +65,8 @@ VKSwapchain::VKSwapchain(VkSurfaceKHR surface_, const Device& device_, VKSchedul
VKSwapchain::~VKSwapchain() = default;
void VKSwapchain::Create(u32 width, u32 height, bool srgb) {
- needs_recreate = false;
+ is_outdated = false;
+ is_suboptimal = false;
const auto physical_device = device.GetPhysical();
const auto capabilities{physical_device.GetSurfaceCapabilitiesKHR(surface)};
@@ -85,11 +86,22 @@ void VKSwapchain::Create(u32 width, u32 height, bool srgb) {
}
void VKSwapchain::AcquireNextImage() {
- const VkResult result =
- device.GetLogical().AcquireNextImageKHR(*swapchain, std::numeric_limits<u64>::max(),
- *present_semaphores[frame_index], {}, &image_index);
- needs_recreate |= result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR;
-
+ const VkResult result = device.GetLogical().AcquireNextImageKHR(
+ *swapchain, std::numeric_limits<u64>::max(), *present_semaphores[frame_index],
+ VK_NULL_HANDLE, &image_index);
+ switch (result) {
+ case VK_SUCCESS:
+ break;
+ case VK_SUBOPTIMAL_KHR:
+ is_suboptimal = true;
+ break;
+ case VK_ERROR_OUT_OF_DATE_KHR:
+ is_outdated = true;
+ break;
+ default:
+ LOG_ERROR(Render_Vulkan, "vkAcquireNextImageKHR returned {}", vk::ToString(result));
+ break;
+ }
scheduler.Wait(resource_ticks[image_index]);
resource_ticks[image_index] = scheduler.CurrentTick();
}
@@ -115,7 +127,7 @@ void VKSwapchain::Present(VkSemaphore render_semaphore) {
LOG_DEBUG(Render_Vulkan, "Suboptimal swapchain");
break;
case VK_ERROR_OUT_OF_DATE_KHR:
- needs_recreate = true;
+ is_outdated = true;
break;
default:
LOG_CRITICAL(Render_Vulkan, "Failed to present with error {}", vk::ToString(result));