VK_ERROR_INCOMPATIBLE_DRIVER with Mac OS and Vulkan MoltenVK

4k Views Asked by At

I am trying to use Vulkan API on my mac OS (with my Intel HD Graphics 5000 1536 Mo). But when I create an Instance With a VkCreateInstance(...)

the result of VkCreateInstance(...) is VK_ERROR_INCOMPATIBLE_DRIVER.

Here my code for initialize my VkInstance :

    VkApplicationInfo vkAppInfo    = {};
    vkAppInfo.sType                = VK_STRUCTURE_TYPE_APPLICATION_INFO;
    vkAppInfo.pApplicationName     = "S2Engine";
    vkAppInfo.applicationVersion   = VK_MAKE_VERSION(1, 0, 0);
    vkAppInfo.pEngineName          = "No Engine"; //TODO plus tard
    vkAppInfo.engineVersion        = VK_MAKE_VERSION(1, 0, 0);
    vkAppInfo.apiVersion           = VK_API_VERSION_1_0;



    //Obligatoire
    VkInstanceCreateInfo vkInstanceCreateInfo = {};
    vkInstanceCreateInfo.sType                = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
    vkInstanceCreateInfo.pApplicationInfo     = &vkAppInfo;

    uint32_t glfwExtensionCount               = 0;
    const char** glfwExtensions                  ;

    glfwExtensions                            = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);

    vkInstanceCreateInfo.enabledExtensionCount      = glfwExtensionCount;
    vkInstanceCreateInfo.ppEnabledExtensionNames    = glfwExtensions;

    vkInstanceCreateInfo.enabledLayerCount = 0;


    if (vkCreateInstance(&vkInstanceCreateInfo, nullptr /*custom allocator*/, &_vkInstance) != VK_SUCCESS) {
        throw std::runtime_error("failed to create instance!");
    }

So my question is do the vulkan API is available on my Mac OS with MoltenVK ? If yes, what can I do in order to make my app work ?

4

There are 4 best solutions below

0
On

It can be solved by adding a path to MoltenVK_icd.json to VK_ICD_FILENAMES environment variable. MoltenVK_icd.json in turn should point to libMoltenVK.dylib.

1
On

As of Vulkan SDK 1.3.216, we also must enable the VK_KHR_portability_enumeration extension, and set the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR flag when creating the instance, in order to use MoltenVK. Without this, I've observed that the loader will return VK_ERROR_INCOMPATIBLE_DRIVER.

0
On

I met the same problem, and I solved it by running this command in the SDK:

sudo ./install_vulkan.py --force-install
0
On

Here an answer from the vulkan forum, hope it will help for other people who try to developed with Vulkan on Mac OS:

You can check link for hardware support - on a quick glance I don’t see your GPU in there. However, if you are on macOS (as opposed to e.g. running a different OS on the hardware) you cannot access Vulkan directly because it is not supported by the OS. You can use MoltenVK (which is part of the Vulkan SDK, so you may already have it), a translation layer that turns Vulkan API calls into corresponding Metal API calls.