diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp index e76f95294..8b5637f01 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp @@ -348,7 +348,7 @@ VkPresentModeKHR SwapchainInfoVk::ChoosePresentMode(const std::vector= chainInfo.m_maxQueued) - { - uint64 waitFrameId = chainInfo.m_presentId - chainInfo.m_queueDepth; - vkWaitForPresentKHR(m_logicalDevice, chainInfo.m_swapchain, waitFrameId, 40'000'000); - chainInfo.m_queueDepth--; - } - } - bool result = chainInfo.AcquireImage(); if (!result) return false; @@ -2687,11 +2677,6 @@ void VulkanRenderer::RecreateSwapchain(bool mainWindow, bool skipCreate) ImguiInit(); } -bool VulkanRenderer::UsePresentWait(const SwapchainInfoVk& chain) const -{ - return m_featureControl.deviceExtensions.present_wait && chain.m_maxQueued > 0; -} - bool VulkanRenderer::UpdateSwapchainProperties(bool mainWindow) { auto& chainInfo = GetChainInfo(mainWindow); @@ -2764,13 +2749,21 @@ void VulkanRenderer::SwapBuffer(bool mainWindow) presentInfo.pWaitSemaphores = &presentSemaphore; // if present_wait is available and enabled, add frame markers to present requests - if (UsePresentWait(chainInfo)) + // and limit the number of queued present operations + if (m_featureControl.deviceExtensions.present_wait && chainInfo.m_maxQueued > 0) { presentId.sType = VK_STRUCTURE_TYPE_PRESENT_ID_KHR; presentId.swapchainCount = 1; presentId.pPresentIds = &chainInfo.m_presentId; presentInfo.pNext = &presentId; + + if(chainInfo.m_queueDepth >= chainInfo.m_maxQueued) + { + uint64 waitFrameId = chainInfo.m_presentId - chainInfo.m_queueDepth; + vkWaitForPresentKHR(m_logicalDevice, chainInfo.m_swapchain, waitFrameId, 40'000'000); + chainInfo.m_queueDepth--; + } } VkResult result = vkQueuePresentKHR(m_presentQueue, &presentInfo); @@ -2787,7 +2780,6 @@ void VulkanRenderer::SwapBuffer(bool mainWindow) chainInfo.m_presentId++; } - chainInfo.hasDefinedSwapchainImage = false; chainInfo.swapchainImageIndex = -1; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index f92048b5f..4111db532 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -552,7 +552,6 @@ class VulkanRenderer : public Renderer VkPipeline backbufferBlit_createGraphicsPipeline(VkDescriptorSetLayout descriptorLayout, bool padView, RendererOutputShader* shader); bool AcquireNextSwapchainImage(bool mainWindow); void RecreateSwapchain(bool mainWindow, bool skipCreate = false); - bool UsePresentWait(const SwapchainInfoVk& chain) const; // streamout void streamout_setupXfbBuffer(uint32 bufferIndex, sint32 ringBufferOffset, uint32 rangeAddr, uint32 rangeSize) override;