KhronosGroup / glTF-IBL-Sampler

Sampler to create the glTF sample environments
Apache License 2.0
130 stars 18 forks source link

Vulkan 1.3.216+ fails on MacOS with 'Failed to create Vulkan instance 4294967287' #29

Open therealbnut opened 10 months ago

therealbnut commented 10 months ago

I had some errors creating the Vulkan instance on MacOS. The error message was:

Failed to create Vulkan instance 4294967287

I think that error code should be printed as a signed integer instead, so it's just -9, which lines up more nicely with the negative value of errors in VkResult.

In this case it's VK_ERROR_INCOMPATIBLE_DRIVER, and after a bit of searching I fixed it by adding the following code at this line:

static const char *VK_EXTENSION_NAMES[1] = {
    VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME,
};
createInfo.ppEnabledExtensionNames = VK_EXTENSION_NAMES;
createInfo.enabledExtensionCount = 1;

createInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;

I believe the reason is that Vulkan now requires this extension on MacOS. An ideal fix would probably verify if the extension is available, and maybe whether it's on MacOS, but I'm not very familiar with how to do any of these things idiomatically.

I hope the above fix will help someone else in this situation, or maybe someone more familiar with this can apply the patch idiomatically :)

Thanks!