KhronosGroup / KhronosGroup/Vulkan-Docs
Clarify success/error behaviour of `vkQueuePresentKHR` with multiple swapchains
- Dominant language
- JavaScript
- Stars
- 3.3k
- Forks
- 549
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 2
Description
`vkQueuePresentKHR` has the ability to present multiple swapchains at once, and you can get a separate `VkResult` value for each swapchain individually if you want. There are two things that seem to be left unspecified currently:
`vkQueuePresentKHR` also returns a single `VkResult` value. How do these two values relate to each other? In [the implementation used by Mesa](https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/vulkan/wsi/wsi_common.c#L1183), the return value is the first value that isn't `VK_SUCCESS`. But this can be `VK_SUBOPTIMAL_KHR`, which is not an error value, while the list of individual results could contain an actual error value. It seems that the single return value is not particularly useful if more than one swapchain is being submitted, so there ought to be recommendation in the spec to not use it in that case.
When the list of results contains some error values and some non-error values, what guarantees does the function provide about each individual present operation? Is it an all-or-nothing affair, or will the successful ones be executed and the errored ones be skipped? Mesa's implementation follows the latter principle, but I noticed this bit in the spec of the `VK_KHR_swapchain` extension:
> 8) Can multiple presents be queued using one [vkQueuePresentKHR](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkQueuePresentKHR.html) call?
> RESOLVED: Yes. [VkPresentInfoKHR](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPresentInfoKHR.html) contains a list of swapchains and corresponding image indices that will be presented. When supported, all presentations queued with a single [vkQueuePresentKHR](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkQueuePresentKHR.html) call will be applied atomically as one operation.
So the actual behaviour is implementation-dependent, but it doesn't seem possible for the user to know the current behaviour? Does the user need to know? How long does each `VkSwapchain` object need to be kept alive for?
Contributor guide
Assessment
This issue has not been assessed yet.