VK_ERROR_INCOMPATIBLE_DRIVER with Mac OS and Vulkan MoltenVK
Asked Answered
S

4

5

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 ?

Schnauzer answered 6/11, 2019 at 14:32 Comment(9)
What version of glfw?Partin
The version of glfw is 3.3Schnauzer
Are you using MoltenVK? @Partin OP does not mention this, does not tag this, and I don't see it anywhere.Revenant
@opa The OP and me have history. Of course looking at that question seems to indicate a non-standard MoltenVK library being used...Partin
Indeed I do not use MoltenVK WrapperSchnauzer
Yeah you do, you just don't set it up properly.Partin
Ah ok, I did not know, I follow the tutorial of vulkan tutorial and the tutorial does not mention MoltenVKSchnauzer
I am no Vulkan expert but got it running on a macOS app and it needed configuration files and all sorts for it to find its base configuration. It was much easier doing it with Metal :)Partin
I am student and I realy wanted to learn how to use Vulkan, but I think I am gonna have many problem with this API on my mac. I will use Metal or OpenGL for my soft (on my mac), if I make my soft work on Windows or linux I will use Vulkan for my rendering subsystem. Thank you for yours help :}Schnauzer
S
9

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.

Surrealism answered 18/8, 2022 at 19:12 Comment(1)
Oh my god, this saved me hours of frustration. How is one supposed to know these things without Stack Overflow? :)Lombroso
A
5

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

sudo ./install_vulkan.py --force-install
Averett answered 19/1, 2021 at 6:39 Comment(0)
S
0

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.

Schnauzer answered 7/11, 2019 at 9:8 Comment(0)
F
0

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.

Featherstone answered 17/1, 2023 at 15:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.