Problem with semaphore and validation layer when using multi viewports.
#9349 opened on Apr 6, 2026
Description
Version/Branch of Dear ImGui:
Version 1.92.7, Branch: docking
Back-ends:
imgui_impl_vulkan.cpp
Compiler, OS:
MSVC 2026
Full config/build information:
No response
Details:
When I try to use multiveiewports by enabling it trough the flag it always give me a validation layer several times because of bad usage of semaphore. [ERROR: Validation] - VUID-vkQueueSubmit-pSignalSemaphores-00067 vkQueueSubmit(): pSubmits[0].pSignalSemaphores[0] (VkSemaphore 0x790000000079) is being signaled by VkQueue 0x1c2761050e0, but it may still be in use by VkSwapchainKHR 0x670000000067. Most recently acquired image indices: 2, 1, 0, [1], 0, 0, 0, 0. (Brackets mark the last use of VkSemaphore 0x790000000079 in a presentation operation.) Swapchain image 1 was presented but was not re-acquired, so VkSemaphore 0x790000000079 may still be in use and cannot be safely reused with image index 0. Vulkan insight: See https://docs.vulkan.org/guide/latest/swapchain_semaphore_reuse.html for details on swapchain semaphore reuse. Examples of possible approaches: a) Use a separate semaphore per swapchain image. Index these semaphores using the index of the acquired image. b) Consider the VK_KHR_swapchain_maintenance1 extension. It allows using a VkFence with the presentation operation. The Vulkan spec states: Each binary semaphore element of the pSignalSemaphores member of any element of pSubmits must be unsignaled when the semaphore signal operation it defines is executed on the device (https://vulkan.lunarg.com/doc/view/1.4.328.1/windows/antora/spec/latest/chapters/cmdbuffers.html#VUID-vkQueueSubmit-pSignalSemaphores-00067). this seems to be fixed by substituting something in the imgui_impl_vulkan.cpp: instead of indexing the presentation semaphore with: wd->semaphoreIndex I use present_index:§ FROM: ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[wd->SemaphoreIndex]; VkPresentInfoKHR info = {}; info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; info.waitSemaphoreCount = 1; info.pWaitSemaphores = &fsd->RenderCompleteSemaphore; info.swapchainCount = 1; info.pSwapchains = &wd->Swapchain; info.pImageIndices = &present_index; err = vkQueuePresentKHR(v->Queue, &info); TO ImGui_ImplVulkanH_FrameSemaphores* fsd_render = &wd->FrameSemaphores[present_index]; VkPresentInfoKHR info = {}; info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; info.waitSemaphoreCount = 1; info.pWaitSemaphores = &fsd_render->RenderCompleteSemaphore; info.swapchainCount = 1; info.pSwapchains = &wd->Swapchain; info.pImageIndices = &present_index; err = vkQueuePresentKHR(v->Queue, &info);
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
MoreCodeToExplainMyIssue();
ImGui::End();