vkGetPhysicalDevice SurfaceCapabilitiesKHR returns VK_ERROR_UNKNOWN (-13)

Not sure it’s the right place to ask, but let’s give it a try.

I am getting VK_ERROR_UNKNOWN (-13) return value from vkGetPhysicalDeviceSurfaceCapabilitiesKHR and I have no idea how to work on this problem.

I am using 1.2.162.0 Vulkan SDK, working on and AMD-based machine, RX 580 GPU.
One thing that concerns me is that Radeon Software tool tells me that:
Vulkan API Version: 1.2.152.
Can this be the reason? Or this is a bug in Vulkan?

Thanks.

Vulkan SDK and driver versions do not need to match, that’s fine. VK_ERROR_UNKNOWN is not an error that the function should return (see spec), so it’s likely that you either passed an invalid object (e.g. the surface) or some structure or memory wasn’t properly initialized or went out of scope, and the implementation doesn’t know how to handle it.

Without any code, this is hard to diagnose, but I’d start with checking proper values in the debugger, and then continue with using the validation layers.

Thanks Sascha!
Your answer hinted me something.
I did not fill the hwnd member of the VkWin32SurfaceCreateInfoKHR structure when creating the surface.

Hey there!
It would be interesting to keep your mistake for a moment and to add validation layers to your application.
You will see that they likely catch this mistake (and many more issues) :slight_smile:

It’s simple: all you need to do is to att VK_LAYER_KHRONOS_validation to VkInstanceCreateInfo::ppEnabledLayerNames. You must however check if they are supported by the system using vkEnumerateInstanceExtensionProperties.Then you need to set your custom callback using CreateDebugUtilsMessengerEXT.

best regards,
Johannes

Actually, I have the validation layer active. That’s another reason I was confused.
So, I can confirm that such a case (hwnd member of the VkWin32SurfaceCreateInfoKHR structure not filled) is not caught by the validation layer.
Thanks for the responses!