From 60c735d1a4cf6bcf02218f090ce59bcd7bf82d85 Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Fri, 9 Sep 2022 20:37:56 +0200 Subject: [PATCH] Enable Vulkan on MacOS --- CMakeLists.txt | 2 +- src/common/library.h | 6 ++++++ src/detection/vulkan.c | 15 +++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96cbc4b1f..2691902f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ endif() include(CMakeDependentOption) cmake_dependent_option(ENABLE_LIBPCI "Enable libpci" ON "LINUX" OFF) -cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX" OFF) +cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE" OFF) cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX" OFF) cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX" OFF) cmake_dependent_option(ENABLE_XCB "Enable xcb" ON "LINUX" OFF) diff --git a/src/common/library.h b/src/common/library.h index 0ccfd5872..c3349c128 100644 --- a/src/common/library.h +++ b/src/common/library.h @@ -5,6 +5,12 @@ #include +#ifdef __APPLE__ + #define FF_LIBRARY_EXTENSION ".dylib" +#else + #define FF_LIBRARY_EXTENSION ".so" +#endif + #define FF_LIBRARY_SYMBOL(symbolName) \ __typeof__(&symbolName) ff ## symbolName; diff --git a/src/detection/vulkan.c b/src/detection/vulkan.c index 43a208fcb..f5e2f19cd 100644 --- a/src/detection/vulkan.c +++ b/src/detection/vulkan.c @@ -35,7 +35,7 @@ static void applyDriverName(VkPhysicalDeviceDriverProperties* properties, FFstrb static void detectVulkan(const FFinstance* instance, FFVulkanResult* result) { - FF_LIBRARY_LOAD(vulkan, instance->config.libVulkan, , "libvulkan.so", 2) + FF_LIBRARY_LOAD(vulkan, instance->config.libVulkan, , "libvulkan"FF_LIBRARY_EXTENSION, 2) FF_LIBRARY_LOAD_SYMBOL(vulkan, vkGetInstanceProcAddr,) FF_LIBRARY_LOAD_SYMBOL(vulkan, vkCreateInstance,) FF_LIBRARY_LOAD_SYMBOL(vulkan, vkDestroyInstance,) @@ -85,9 +85,16 @@ static void detectVulkan(const FFinstance* instance, FFVulkanResult* result) .pApplicationInfo = &applicationInfo, .enabledLayerCount = 0, .ppEnabledLayerNames = NULL, - .enabledExtensionCount = 0, - .ppEnabledExtensionNames = NULL, - .flags = 0 + + #if defined(__APPLE__) && defined(VK_KHR_portability_enumeration) + .enabledExtensionCount = 1, + .ppEnabledExtensionNames = (const char* const[]) { VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME }, + .flags = VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR + #else + .enabledExtensionCount = 0, + .ppEnabledExtensionNames = NULL, + .flags = 0 + #endif }; VkInstance vkInstance;