-
Notifications
You must be signed in to change notification settings - Fork 868
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
[vulkan] Recreate the surface on surface loss. #991
Conversation
According to the Vulkan spec: > Several WSI functions return `VK_ERROR_SURFACE_LOST_KHR` if the > surface becomes no longer available. After such an error, the surface > (and any child swapchain, if one exists) **should** be destroyed, as > there is no way to restore them to a not-lost state. So if we get this error, we need to recreate the surface in addition to the swapchain.
Does this actually fix anything? Asking because this should really not happen in any application that isn't broken on Windows. |
On Mac, the system will sometimes recreate any |
If the surface is lost in a way that can't be recovered by recreating the surface from the window, the previous change would wind up looping forever. Just retry 5 times before giving up.
src/vulkan/vulkan_presenter.cpp
Outdated
m_device.adapter, m_surface, &caps)) != VK_SUCCESS) | ||
return status; | ||
m_device.adapter, m_surface, &caps)) != VK_SUCCESS) { | ||
for (uint32_t i = 0; i < 5 && status == VK_ERROR_SURFACE_LOST_KHR; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a valid scenario where this can fail an arbitrary number of times in a row? I'd prefer a solution with no more than one attempt if that is reasonable, since any functions that affect the window should have completed at this point.
Slightly unrelated note, and I might be wrong here but: I have a feeling this will probably break lots of things (on the mvk side.) If typical games treat that in the same way they treat d3d device loss, or lack thereof, then I'd think twice about not doing that transparently. |
According to the Vulkan spec:
So if we get this error, we need to recreate the surface in addition to
the swapchain.