How do you delete VkDevice if it was lost (VK_ERROR_DEVICE_LOST)? I use vkDeviceWaitIdle to wait until device finishes all the work to safely delete it. But if device is lost, vkDeviceWaitIdle does nothing, returns immediately VK_ERROR_DEVICE_LOST, so deleting vkDevice leads to crash inside library (MoltenVK). I don't want to create async which will delete vkDevice after 10 seconds of waiting or something like that. Is there any other way to wait until vkDevice is ready to be deleted?
But if device is lost, vkDeviceWaitIdle does nothing, returns immediately VK_ERROR_DEVICE_LOST, so deleting vkDevice leads to crash inside library (MoltenVK).
Then that's a bug inside MoltenVK.
The specification is very specific:
For any command that may return
VK_ERROR_DEVICE_LOST, for the purpose of determining whether a command buffer is in the pending state, or whether resources are considered in-use by the device, a return value ofVK_ERROR_DEVICE_LOSTis equivalent toVK_SUCCESS.
If vkDeviceWaitIdle returns VK_SUCCESS, then this means that all command buffers submitted to the device have finished executing and resources are no longer in use. A return of VK_ERROR_DEVICE_LOST, given the above, should mean the exact same thing.
As such, you should be able to delete all objects associated with the VkDevice handle and then the device handle itself. Note that you still need to delete the objects before you delete the device handle. But these are the normal device shutdown rules.