Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ICD Drivers found with MoltenVK [macos] #135

Open
s-daveb opened this issue Feb 17, 2024 · 2 comments
Open

No ICD Drivers found with MoltenVK [macos] #135

s-daveb opened this issue Feb 17, 2024 · 2 comments

Comments

@s-daveb
Copy link

s-daveb commented Feb 17, 2024

Please see my reply, I may have a fix

Describe the bug
I was able to build everything on my system, with minimal warnings, but when I run the program, I get an exception and vulkan layer errors.

To Reproduce

brew install molten-vk vulkan-extensionlayer vulkan-tools vulkan-volk vulkan-headers vulkan-utility-libraries vulkan-loader vulkan-validationlayers ```

cd ~/Developer/C++/Acid
cmake -B Build -G Ninja -DCMAKE_BUILD_TYPE=Debug
cmake --build Build
Build/bin/Tutorial1
Version: 0.14.3
Git: 2ff8adee3 on master
Compiled on: Darwin-22.6.0 from: Ninja with: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++

Instance Layers: VK_LAYER_KHRONOS_timeline_semaphore, VK_LAYER_KHRONOS_validation, VK_LAYER_KHRONOS_synchronization2, VK_LAYER_KHRONOS_shader_object,

Searching for ICD drivers named ../../../lib/libMoltenVK.dylib
vkCreateInstance: Found drivers that contain devices which support the portability subset, but the instance does not enumerate portability drivers! 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.
vkCreateInstance: Found no drivers!
libc++abi: terminating due to uncaught exception of type std::runtime_error: Vulkan error: The requested version of Vulkan is not supported by the driver or is otherwise incompatible

Expected behaviour*
The tutorial runs

Screenshots
N/A

Hardware:

  • Device: Macbook Pro 2017 (Touchbar)
  • OS: macOS Ventura 13.6.4

Additional context

╰─➤  brew search moltenvk
==> Formulae
molten-vk ✔

╰─➤  brew search vulkan
==> Formulae
vulkan-extensionlayer ✔           vulkan-tools ✔                    vulkan-volk ✔
vulkan-headers ✔                  vulkan-utility-libraries ✔
vulkan-loader ✔                   vulkan-validationlayers ✔

I think maybe Vulkan is being initialized without portability extensions?
I've done very little Vulkan programming, but when I have, I have to add:

#ifdef __APPLE__
       extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
        extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
#endif

//...

vk::InstanceCreateInfo createInfo({}, &appInfo, 0, nullptr, static_cast<uint32_t>(extensions.size()), extensions.data());

#ifdef __APPLE__
        createInfo.setFlags(vk::InstanceCreateFlagBits::eEnumeratePortabilityKHR);
#endif
@s-daveb s-daveb changed the title Tutorials do not work on macOS with MoltenVK No ICD Drivers found with MoltenVK [macos] Feb 17, 2024
@s-daveb
Copy link
Author

s-daveb commented Feb 17, 2024

The following patch seems to fix that ICD exception. But it turns out that MoltenVK does not support Geometry Shaders (at least on my GPU) - so I can't load the tutorials anyway.

diff --git a/Sources/Graphics/Devices/Instance.cpp b/Sources/Graphics/Devices/Instance.cpp
index 323e191db..febff8877 100644
--- a/Sources/Graphics/Devices/Instance.cpp
+++ b/Sources/Graphics/Devices/Instance.cpp
@@ -145,6 +145,12 @@ std::vector<const char *> Instance::GetExtensions() const {
 	if (enableValidationLayers)
 		extensions.emplace_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
 	//extensions.emplace_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
+
+#ifdef __APPLE__
+		// macOS specific extensions
+	extensions.emplace_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
+	extensions.emplace_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
+#endif
 	return extensions;
 }
 
@@ -168,6 +174,7 @@ void Instance::CreateInstance() {
 		enableValidationLayers = false;
 	}
 
+
 	auto extensions = GetExtensions();
 	
 	VkInstanceCreateInfo instanceCreateInfo = {};
@@ -176,6 +183,10 @@ void Instance::CreateInstance() {
 	instanceCreateInfo.enabledExtensionCount = static_cast<uint32_t>(extensions.size());
 	instanceCreateInfo.ppEnabledExtensionNames = extensions.data();
 
+#ifdef __APPLE__
+	instanceCreateInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
+#endif
+
 #if USE_DEBUG_MESSENGER
 	VkDebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfo = {};
 #endif

@mPorst
Copy link

mPorst commented Feb 27, 2024

The tutorials seem to be broken, see also this editor issue.
I'm in the process of getting into the engine, the TestPhysics works on my devices (windows and linux) but seems to depend on a large ecosystem of additional classes (scene, camera, ui, ...)
I tried to get tutorial1 running and I'm currently stuck at the fact that at some point the camera is queried but returns a nullptr. So I try to figure out how to create a scene...
Anyway, I can't directly answer your question but hope the info helps you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants