mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-26 21:34:16 +01:00
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:
parent
bcd96ac77d
commit
14af383238
@ -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))
|
||||
|
@ -41,8 +41,9 @@ namespace skyline::gpu {
|
||||
static constexpr size_t MaxSwapchainImageCount{6}; //!< The maximum amount of swapchain textures, this affects the amount of images that can be in the swapchain
|
||||
std::array<std::shared_ptr<Texture>, MaxSwapchainImageCount> images; //!< All the swapchain textures in the same order as supplied by the host swapchain
|
||||
std::array<vk::raii::Semaphore, MaxSwapchainImageCount> presentSemaphores; //!< Array of semaphores used to signal that swapchain images are ready to be completed, indexed by Vulkan swapchain index
|
||||
std::array<vk::raii::Semaphore, MaxSwapchainImageCount> acquireSemaphores; //!< Array of semaphores used to wait on the GPU for swapchain images to be acquired, indexed by `acquireSemaphoreIndex`
|
||||
size_t acquireSemaphoreIndex{}; //!< The index of the next semaphore to be used for acquiring swapchain images
|
||||
std::array<vk::raii::Semaphore, MaxSwapchainImageCount> acquireSemaphores; //!< Array of semaphores used to wait on the GPU for swapchain images to be acquired, indexed by `frameIndex`
|
||||
std::array<std::shared_ptr<FenceCycle>, MaxSwapchainImageCount> frameFences{}; //!< Array of fences used to wait on the GPU for copying of swapchain images to be completed, indexed by `frameIndex`
|
||||
size_t frameIndex{}; //!< The index of the next semaphore/fence to be used for acquiring swapchain images
|
||||
size_t swapchainImageCount{}; //!< The number of images in the current swapchain
|
||||
|
||||
i64 frameTimestamp{}; //!< The timestamp of the last frame being shown in nanoseconds
|
||||
|
Loading…
Reference in New Issue
Block a user