I have spent a couple days to figuring this out, I think it might help somebody.
I am doing this on MacBook pro via MoltenVK.
vkCreateInstance was returning VK_ERROR_INCOMPATIBLE_DRIVER and I had no clue why
eventually on the LunarG getting started on MacOS I found an env var that you could set when running your app to see debug logs.
VK_LOADER_DEBUG=all
ERROR | DRIVER: vkCreateInstance: Found drivers that contain devices which support the portability subset, but the portability enumeration bit was not set!. Applications that wish to enumerate portability drivers must set the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo flags and enable the VK_KHR_portability_enumeration instance extension. ERROR | DRIVER: vkCreateInstance: Found no drivers! ERROR: vkDestroyInstance: Invalid instance [VUID-vkDestroyInstance-instance-parameter]
This is something to do with MoltenVK and how its not actually Vulkan but a translation layer to Apple’s Metal API, thus for the device to be created you need do the following:
createInfo.flags = VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
and the following something equivalent to load the VK_KHR_portability_enumeration extension in addition to the GLFW extensions:
uint32_t glfwExtensionCount = 0; const char** glfwExtensions; glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount); std::vector<const char*=""> instanceExtensions(glfwExtensionCount); memcpy(instanceExtensions.data(), glfwExtensions, sizeof(const char*) * glfwExtensionCount); instanceExtensions.push_back("VK_KHR_portability_enumeration"); createInfo.enabledExtensionCount = static_cast<uint32_t>(instanceExtensions.size()); createInfo.ppEnabledExtensionNames = instanceExtensions.data();
you will need to add the portability subset to your device extensions when you get there
const std::vector<const char*=""> deviceExtensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME, "VK_KHR_portability_subset" };
I’m not sure why it happens, but I found that people can see this problem on Intel and M1 macbooks.
If you want to collaborate with us on learning, join Discord, I’ll be happy to answer.