Only allow submitting swapchainImageCount images for host present at a time

Prevents situations where nothing would otherwise be waiting on the GPU and since presentation no longer blocks too many images would be submitted for presentation.
This commit is contained in:
Billy Laws
2022-10-21 21:58:52 +01:00
parent bcd96ac77d
commit 14af383238
2 changed files with 11 additions and 4 deletions

View File

@ -121,8 +121,12 @@ namespace skyline::gpu {
throw exception("Setting the buffer transform to '{}' failed with {}", ToString(frame.transform), result);
windowTransform = frame.transform;
auto &acquireSemaphore{acquireSemaphores[acquireSemaphoreIndex]};
acquireSemaphoreIndex = (acquireSemaphoreIndex + 1) % swapchainImageCount;
auto &acquireSemaphore{acquireSemaphores[frameIndex]};
auto &frameFence{frameFences[frameIndex]};
if (frameFence)
frameFence->Wait();
frameIndex = (frameIndex + 1) % swapchainImageCount;
std::pair<vk::Result, u32> nextImage;
while (nextImage = vkSwapchain->acquireNextImage(std::numeric_limits<u64>::max(), *acquireSemaphore, {}), nextImage.first != vk::Result::eSuccess) [[unlikely]] {
@ -142,6 +146,8 @@ namespace skyline::gpu {
.layerCount = 1,
});
frameFence = nextImageTexture->cycle;
auto getMonotonicNsNow{[]() -> i64 {
timespec time;
if (clock_gettime(CLOCK_MONOTONIC, &time))