Vulkan: If acquiring a frame fails (happens sometimes during window resize), skip swapping the frame. Should help #10063

This commit is contained in:
Henrik Rydgård 2017-11-07 09:56:41 +01:00
parent 4cee442b0f
commit 7922a2ab5c
2 changed files with 22 additions and 15 deletions

View file

@ -701,6 +701,8 @@ void VulkanRenderManager::BeginSubmitFrame(int frame) {
VkResult res = vkAcquireNextImageKHR(vulkan_->GetDevice(), vulkan_->GetSwapchain(), UINT64_MAX, acquireSemaphore_, (VkFence)VK_NULL_HANDLE, &frameData.curSwapchainImage);
if (res == VK_SUBOPTIMAL_KHR) {
// Hopefully the resize will happen shortly. Ignore.
} else if (res == VK_ERROR_OUT_OF_DATE_KHR) {
frameData.skipSwap = true;
} else {
assert(res == VK_SUCCESS);
}
@ -751,7 +753,7 @@ void VulkanRenderManager::Submit(int frame, bool triggerFence) {
cmdBufs[numCmdBufs++] = frameData.mainCmd;
VkSubmitInfo submit_info{ VK_STRUCTURE_TYPE_SUBMIT_INFO };
if (triggerFence) {
if (triggerFence && !frameData.skipSwap) {
submit_info.waitSemaphoreCount = 1;
submit_info.pWaitSemaphores = &acquireSemaphore_;
VkPipelineStageFlags waitStage[1]{ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT };
@ -759,7 +761,7 @@ void VulkanRenderManager::Submit(int frame, bool triggerFence) {
}
submit_info.commandBufferCount = (uint32_t)numCmdBufs;
submit_info.pCommandBuffers = cmdBufs;
if (triggerFence) {
if (triggerFence && !frameData.skipSwap) {
submit_info.signalSemaphoreCount = 1;
submit_info.pSignalSemaphores = &renderingCompleteSemaphore_;
}
@ -785,6 +787,7 @@ void VulkanRenderManager::EndSubmitFrame(int frame) {
Submit(frame, true);
if (!frameData.skipSwap) {
VkSwapchainKHR swapchain = vulkan_->GetSwapchain();
VkPresentInfoKHR present = { VK_STRUCTURE_TYPE_PRESENT_INFO_KHR };
present.swapchainCount = 1;
@ -801,6 +804,9 @@ void VulkanRenderManager::EndSubmitFrame(int frame) {
} else {
assert(res == VK_SUCCESS);
}
} else {
frameData.skipSwap = false;
}
}
void VulkanRenderManager::Run(int frame) {

View file

@ -238,6 +238,7 @@ private:
bool readyForFence = true;
bool readyForRun = false;
bool skipSwap = false;
VKRRunType type = VKRRunType::END;
VkFence fence;