-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Optionally don't call vkDeviceWaitIdle in imgui_impl_vulkan.cpp #7148
Comments
Hello, There are 4 calls to
I don't know but I would be interested if you could investigate this? (preferably in docking branch). It might also make sense to move the wait to caller code. |
Looking at it more closely it does seem like ImGui_ImplVulkan_CreateFontsTexture is the only vkDeviceWaitIdle that matters (I don't use the ImGui swapchain helpers) and this is due to a recent change:
I'll make a PR later to swap the vkDeviceWaitIdle for vkQueueWaitIdle and leave the others as-is. Thanks! |
Now pushed that change as 33d4268 |
Looks good. |
Version/Branch of Dear ImGui:
Version: 089ed30
Branch: master
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_vulkan.cpp
Compiler: all supported compilers
Operating System: all supported OS
My Issue/Question:
In the reference Vulkan implementation, we are sometimes implicitly calling vkQueueWaitIdle, sometimes implicitly calling vkDeviceWaitIdle. For example, in
ImGui_ImplVulkan_CreateFontsTexture
, we call vkQueueWaitIdle before calling ImGui_ImplVulkan_DestroyFontsTexture, but later call vkDeviceWaitIdle after submitting the command buffer. The implicit vkDeviceWaitIdle calls pose difficulties for me as my graphics code is not on the same CPU thread as my async compute code, and the Vulkan spec requires the caller to synchronize CPU access to all queues. So, if I'm doing things by the book, I have to use a mutex to ensure the ImGui code won't run at the same time as my async compute code, even though the two really have nothing to do with each other.The way we solved this in the nvpro_core framework is to by-default use vkDeviceWaitIdle (for backwards compatibility with code that may somehow be relying on this) but allow the caller to opt-into substituting all vkDeviceWaitIdle calls with vkQueueWaitIdle. Alternatively maybe no one is truly relying on vkDeviceWaitIdle at all and we can unconditionally replace all vkDeviceWaitIdle calls with vkQueueWaitIdle.
Example API: https://github.com/nvpro-samples/nvpro_core/blob/26a5a00282641248755cd874b3e94f32a5bafd74/nvvk/swapchain_vk.hpp#L364
Example implementation (replaced all vkDeviceWaitIdle calls with this): https://github.com/nvpro-samples/nvpro_core/blob/26a5a00282641248755cd874b3e94f32a5bafd74/nvvk/swapchain_vk.hpp#L241C12-L241C12
This is an easy-to-make change on my end, but I make the issue anyway as requested by the header comment.
The text was updated successfully, but these errors were encountered: