| 42 | ////////////////////////////////////////////////////////////////////////// |
| 43 | |
| 44 | GLFWbool _glfwInitVulkan(int mode) |
| 45 | { |
| 46 | VkResult err; |
| 47 | VkExtensionProperties* ep; |
| 48 | uint32_t i, count; |
| 49 | |
| 50 | if (_glfw.vk.available) |
| 51 | return GLFW_TRUE; |
| 52 | |
| 53 | #if !defined(_GLFW_VULKAN_STATIC) |
| 54 | #if defined(_GLFW_VULKAN_LIBRARY) |
| 55 | _glfw.vk.handle = _glfw_dlopen(_GLFW_VULKAN_LIBRARY); |
| 56 | #elif defined(_GLFW_WIN32) |
| 57 | _glfw.vk.handle = _glfw_dlopen("vulkan-1.dll"); |
| 58 | #elif defined(_GLFW_COCOA) |
| 59 | _glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib"); |
| 60 | if (!_glfw.vk.handle) |
| 61 | _glfw.vk.handle = _glfwLoadLocalVulkanLoaderNS(); |
| 62 | #elif defined(__OpenBSD__) || defined(__NetBSD__) |
| 63 | _glfw.vk.handle = _glfw_dlopen("libvulkan.so"); |
| 64 | #else |
| 65 | _glfw.vk.handle = _glfw_dlopen("libvulkan.so.1"); |
| 66 | #endif |
| 67 | if (!_glfw.vk.handle) |
| 68 | { |
| 69 | if (mode == _GLFW_REQUIRE_LOADER) |
| 70 | _glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found"); |
| 71 | |
| 72 | return GLFW_FALSE; |
| 73 | } |
| 74 | |
| 75 | _glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) |
| 76 | _glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr"); |
| 77 | if (!_glfw.vk.GetInstanceProcAddr) |
| 78 | { |
| 79 | _glfwInputError(GLFW_API_UNAVAILABLE, |
| 80 | "Vulkan: Loader does not export vkGetInstanceProcAddr"); |
| 81 | |
| 82 | _glfwTerminateVulkan(); |
| 83 | return GLFW_FALSE; |
| 84 | } |
| 85 | |
| 86 | _glfw.vk.EnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) |
| 87 | vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties"); |
| 88 | if (!_glfw.vk.EnumerateInstanceExtensionProperties) |
| 89 | { |
| 90 | _glfwInputError(GLFW_API_UNAVAILABLE, |
| 91 | "Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties"); |
| 92 | |
| 93 | _glfwTerminateVulkan(); |
| 94 | return GLFW_FALSE; |
| 95 | } |
| 96 | #endif // _GLFW_VULKAN_STATIC |
| 97 | |
| 98 | err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL); |
| 99 | if (err) |
| 100 | { |
| 101 | // NOTE: This happens on systems with a loader but without any Vulkan ICD |
no test coverage detected