Retrieve VkInstance for VkSurface


can someone tell me if there is a function that, for a given VkSurface, gives me the VkInstance object that was used to create the VkSurface?


Additional info:
I experiment with qt and vulkan and when trying to use a surface I get the following errors from the validation layer:

vkDebug: Validation: 0: Validation Error: [ VUID-vkGetPhysicalDeviceSurfaceSupportKHR-surface-parameter ] Object 0: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0x801f247e | Invalid VkSurfaceKHR Object 0x55555777b560. The Vulkan spec states: surface must be a valid VkSurfaceKHR handle (

vkDebug: Validation: 0: Validation Error: [ UNASSIGNED-Threading-Info ] Object 0: handle = 0x55555777b560, type = VK_OBJECT_TYPE_SURFACE_KHR; | MessageID = 0x5d6b67e2 | Couldn’t find VkSurfaceKHR Object 0x55555777b560. This should not happen and may indicate a bug in the application.

I would like to know if this error can happen if a VkSurface is not used with the VkInstance it was created from.

Broadly speaking, Vulkan expects you to keep track of things. Since creating a surface requires an instance, you clearly had both in your possession at some point. So Vulkan has no API to query information you possess.

However, the principle problem, given that error, is that the surface isn’t valid, not that it was created with a different instance.

Problem is I don’t really possess the surface because I have to use qt and the window+surface creation is buried deep within the platform specific components. Do you have any other ideas on how to debug this?

Hmm, I’ll assume you are doing something off the beaten path here, because the example for QVulkanWindow shows that the application is creating and passing in the instance.
Also, to me there is no obvious function to get the VkSurface, only VkImage/VkImageView of the swapchain images, where do you get the VkSurface from? Do you really need to query for presentation support, after all if it comes from a QVulkanWindow it should be presentable to that window, no?

Maybe you can include a bit more background what you are trying to do? Otherwise I think your options are to try to align your usage more closely with the QVulkanWindow example or (as hinted in the docs) your use case may require to use a plain QWindow and implement all things Vulkan yourself.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.