From 90deb0959ab3a15f639c92ddc61505a8915de75f Mon Sep 17 00:00:00 2001 From: Michel Lesoinne Date: Mon, 7 Jun 2021 20:09:49 -0600 Subject: [PATCH] Backends, Viewports: Vulkan: Fix the use of the incorrect fence in wait for fence. (#4208) The fence being waited upon was not the one associated with the current frame. This results in validation error detecting a reset of command buffers still in use and resetting fences while still in use. Read more details in #4208 --- backends/imgui_impl_vulkan.cpp | 10 +++++----- docs/CHANGELOG.txt | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backends/imgui_impl_vulkan.cpp b/backends/imgui_impl_vulkan.cpp index 888a52d32..0ad2f3bf7 100644 --- a/backends/imgui_impl_vulkan.cpp +++ b/backends/imgui_impl_vulkan.cpp @@ -1551,6 +1551,11 @@ static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*) ImGui_ImplVulkanH_Frame* fd = &wd->Frames[wd->FrameIndex]; ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[wd->SemaphoreIndex]; { + { + err = vkAcquireNextImageKHR(v->Device, wd->Swapchain, UINT64_MAX, fsd->ImageAcquiredSemaphore, VK_NULL_HANDLE, &wd->FrameIndex); + check_vk_result(err); + fd = &wd->Frames[wd->FrameIndex]; + } for (;;) { err = vkWaitForFences(v->Device, 1, &fd->Fence, VK_TRUE, 100); @@ -1558,11 +1563,6 @@ static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*) if (err == VK_TIMEOUT) continue; check_vk_result(err); } - { - err = vkAcquireNextImageKHR(v->Device, wd->Swapchain, UINT64_MAX, fsd->ImageAcquiredSemaphore, VK_NULL_HANDLE, &wd->FrameIndex); - check_vk_result(err); - fd = &wd->Frames[wd->FrameIndex]; - } { err = vkResetCommandPool(v->Device, fd->CommandPool, 0); check_vk_result(err); diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 652aa99ec..548105250 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -126,6 +126,7 @@ Docking+Viewports Branch: - Docking: Clicking on the right-most close button of a docking node closes all windows. (#4186) - Docking: Fix IsWindowAppearing() and ImGuiCond_Appearing on docked windows. (#4177, #3982, #1497, #1061) +- Backends: Vulkan: Fix the use of the incorrect fence for secondary viewports. (#4208) [@FunMiles] -----------------------------------------------------------------------