From 1fe6d92970737a6d7d74db7ddce41fa7677a550c Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sat, 6 Aug 2022 19:11:37 +0100 Subject: [PATCH] Wait on Swapchain Image copy to complete Certain titles can have a display frames out of order due to not waiting on the copy from the final RT to the swapchain image to occur. Although `PresentFrame` does wait on the syncpoint, that isn't enough to ensure the source texture is up-to-date due to us signalling syncpoints early. By waiting on the swapchain texture after the copy is submitted, we now implicitly wait on the source texture's cycle to be signalled thus waiting on the frame to be done which fixes the issue. --- app/src/main/cpp/skyline/gpu/presentation_engine.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/skyline/gpu/presentation_engine.cpp b/app/src/main/cpp/skyline/gpu/presentation_engine.cpp index c5c48a30..1337e6e5 100644 --- a/app/src/main/cpp/skyline/gpu/presentation_engine.cpp +++ b/app/src/main/cpp/skyline/gpu/presentation_engine.cpp @@ -129,16 +129,20 @@ namespace skyline::gpu { else throw exception("vkAcquireNextImageKHR returned an unhandled result '{}'", vk::to_string(nextImage.first)); } + auto &nextImageTexture{images.at(nextImage.second)}; std::ignore = gpu.vkDevice.waitForFences(*acquireFence, true, std::numeric_limits::max()); texture->SynchronizeHost(); - images.at(nextImage.second)->CopyFrom(texture, vk::ImageSubresourceRange{ + nextImageTexture->CopyFrom(texture, vk::ImageSubresourceRange{ .aspectMask = vk::ImageAspectFlagBits::eColor, .levelCount = 1, .layerCount = 1, }); + // Wait on the copy to the swapchain image to complete before submitting for presentation + nextImageTexture->WaitOnFence(); + auto getMonotonicNsNow{[]() -> i64 { timespec time; if (clock_gettime(CLOCK_MONOTONIC, &time))