-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Vulkan backend (docking): Fix VUIDs 03868/00067 (unsafe render semaphore usage) #8842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: docking
Are you sure you want to change the base?
Conversation
- Remove ImGui_ImplVulkanH_FrameSemaphores structure - Integrate ImageAcquiredSemaphore VkSemaphore into ImGui_ImplVulkanH_Frame struct, as it is a current-frame specific feature - Make RenderSemaphores independent, indexed by the current SwapchainImageIndex (this avoids the validation error) - This fix does NOT require the use of any new extensions More info on the issue with examples: https://docs.vulkan.org/guide/latest/swapchain_semaphore_reuse.html
|
Thank you! Tagging @NostraMagister for possible feedback? (following #7236 (comment)) |
|
This is still generating validation errors for me. Specifically an "vkAcquireNextImageKHR(): Semaphore must not have any pending operations" validation error. I added The first two calls are fine, but as soon as we go back to the first frame's data we try to use an in-use semaphore, because we don't wait for the frame's RenderFence. |
|
Hi @Voxeles, yes, you're right. I was fixing that issue too (the #7236), and confusingly I referenced it in this PR that resolves a completely different issue. I removed the reference to that issue from the PR description; this PR only fixes VUIDS 03868 and 00067. Sorry for the mistake. I will share more on issue #7236 when I find time to work on it again. @ocornut could you review this PR again, please? Thank you. |
|
FYI the easiest way of fixing #7236 without moving the vkWaitForFences is to create a second vector of semaphores specifically for use with vkAcquireNextImageKHR. Basically, this is the same solution that is already in use, except instead of the struct you only have the ImageAcquiredSemaphore. |
|
The current modern way to deal with a Vulkan swapchain at the moment is to use a timeline semaphore. There is an implementation of it in vk_minimal_latest; see the Swapchain class. This is also used in nvpro_core2 for NVIDIA pro samples. Unfortunately, on some platforms using older video drivers, the timeline semaphore might not work as expected, and therefore a VkFence might be needed. However, this is an addition that shouldn't be necessary. A migration towards timeline semaphore would be something nice to have. |
Fixes VUID-vkQueueSubmit2-semaphore-03868 + VUID-vkQueueSubmit-pSignalSemaphores-00067 validation errors (external issue KhronosGroup/Vulkan-ValidationLayers#10254):
The fundamental issue is that the original version of vkQueuePresentKHR doesn't support signaling any fence, so we are stuck checking the fence signaled by vkQueueSubmit2, which is a step before the present operation, which involves waiting for a semaphore known as "render semaphore" (signaled by the vkQueueSubmit operation).
If we cannot determine when the "present" operation finishes, then we can't know when it is safe to signal/wait again for the "render semaphore" associated with that swapchain image, because there could be a queued "present operation" that is still waiting on it.
Without any additional extension, we can exploit the behavior of vkAcquireNextImageKHR, which returns a new image index only when it is ready and has already been presented. That's why we index the "render semaphores" using the current swapchain image index.
Another solution is to use the VK_EXT_swapchain_maintenance1 extension (which has recently been promoted to VK_KHR_swapchain_maintenance1), which adds the possibility to specify a fence to be signaled by the vkQueuePresent operation, but vendor adoption could be a little problematic as of now.
More info on the fundamental issue with examples: https://docs.vulkan.org/guide/latest/swapchain_semaphore_reuse.html