4

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 ?

Krupip
  • 4,404
  • 2
  • 32
  • 54
Benzait Sofiane
  • 107
  • 1
  • 12
  • What version of `glfw`? – trojanfoe Nov 06 '19 at 15:11
  • The version of glfw is 3.3 – Benzait Sofiane Nov 06 '19 at 15:14
  • Are you using MoltenVK? @trojanfoe OP does not mention this, does not tag this, and I don't see it anywhere. – Krupip Nov 06 '19 at 15:16
  • @opa The OP and me have [history](https://stackoverflow.com/questions/58728757/how-to-add-mac-os-framework-on-cmake-file-for-c-project). Of course looking at *that* question seems to indicate a non-standard MoltenVK library being used... – trojanfoe Nov 06 '19 at 15:16
  • Indeed I do not use MoltenVK Wrapper – Benzait Sofiane Nov 06 '19 at 15:21
  • Yeah you do, you just don't set it up properly. – trojanfoe Nov 06 '19 at 15:22
  • Ah ok, I did not know, I follow the tutorial of [vulkan tutorial](https://vulkan-tutorial.com/#page_E-book) and the tutorial does not mention MoltenVK – Benzait Sofiane Nov 06 '19 at 15:24
  • 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 :) – trojanfoe Nov 06 '19 at 15:26
  • 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 :} – Benzait Sofiane Nov 06 '19 at 15:37

4 Answers4

5

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

sudo ./install_vulkan.py --force-install
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Kay
  • 51
  • 1
  • 2
4

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.

Nathan Reed
  • 3,583
  • 1
  • 26
  • 33
  • 2
    Oh my god, this saved me hours of frustration. How is one supposed to know these things without Stack Overflow? :) – toastie Oct 11 '22 at 04:00
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.

Benzait Sofiane
  • 107
  • 1
  • 12
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.

Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169