blurrypiano / littleVulkanEngine

Code repo for video tutorial series teaching Vulkan and computer graphics
MIT License
829 stars 147 forks source link

vkCreateInstance: Found no drivers #39

Open hongye007 opened 1 year ago

hongye007 commented 1 year ago

validation layer: 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. validation layer: vkCreateInstance: Found no drivers! libc++abi: terminating with uncaught exception of type std::runtime_error: failed to create instance!

MacBook Pro mac os 12.6.3 vulkan 1.3.239.0

ComputationTime commented 1 year ago

I encountered the same problem on a 2020 Mac M1 MacOS 13.0.1. Modifying the lve_device.cpp file fixed it for me.

Found the solution here: https://stackoverflow.com/questions/68127785/how-to-fix-vk-khr-portability-subset-error-on-mac-m1-while-following-vulkan-tuto

Try changing this part in lve_device.cpp

VkInstanceCreateInfo createInfo = {};
  createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
  createInfo.pApplicationInfo = &appInfo;

  auto extensions = getRequiredExtensions();
  createInfo.enabledExtensionCount = static_cast<uint32_t>(extensions.size());
  createInfo.ppEnabledExtensionNames = extensions.data();

To this:

VkInstanceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
createInfo.flags = VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
createInfo.pApplicationInfo = &appInfo;

auto extensions = getRequiredExtensions();
extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
createInfo.enabledExtensionCount = static_cast<uint32_t>(extensions.size());
createInfo.ppEnabledExtensionNames = extensions.data();

I hope this works. I'm also a beginner to this. The errors are annoying but try to stick with it!!! Good luck!

leonardseymore commented 9 months ago

@ComputationTime That worked, but I also had to add this VK_KHR_portability_subset to the deviceExtensions in the lve_device.hpp file:

const std::vector<const char *> deviceExtensions = {VK_KHR_SWAPCHAIN_EXTENSION_NAME, "VK_KHR_portability_subset"};