KhronosGroup / Vulkan-Docs

The Vulkan API Specification and related tools
Other
2.75k stars 462 forks source link

Win32 WSI and SendMessage #2290

Open konstantinegorov opened 8 months ago

konstantinegorov commented 8 months ago

Some Vulkan functions may call the SendMessage system API when interacting with a VkSurfaceKHR through a VkSwapchainKHR. In a multithreaded environment, calling SendMessage from a thread that is not the thread associated with pCreateInfo::hwnd will block until the application has processed the window message. Thus, applications should either call these Vulkan functions on the message pump thread, or make sure their message pump is actively running. Failing to do so may result in deadlocks.

Is there an example of what win32 window message can be sent when calling vkCreateSwapchainKHR/vkQueuePresentKHR/vkAcquireNextImageKHR... and in what case?

linyaa-kiwi commented 6 months ago

@nvlduc Can you help with this question? I believe it's related to your internal MR 5792, which touched Win32 WSI multithreaded restrictions.

nvlduc commented 6 months ago

Hi @konstantinegorov,

The main use-case for this change is to allow implementations to safely layer presentation on top of DXGI, which has the same requirements.

Other than that, I expect some implementations would need to tweak some of the window's properties (e.g. extended style) to support a certain set of swapchain features. I cannot really provide specific examples since this is very implementation-specific, and can change from a driver version to the next.