diff --git a/src/vk/Commands.cs b/src/vk/Commands.cs index 7583757..e98f30d 100644 --- a/src/vk/Commands.cs +++ b/src/vk/Commands.cs @@ -47,7 +47,9 @@ private static string GetVulkanName() #endif else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - return "libvulkan.dylib"; + // libvulkan.dylib is an additional translation layer from Vulkan SDK. + // libMoltenVK supports libvulkan functions already. + return "libMoltenVK.dylib"; } else { @@ -160,6 +162,18 @@ protected override IntPtr LoadLibrary(string libraryName) string localPath = Path.Combine(baseDir, libraryName); handle = Libdl.dlopen(localPath, Libdl.RTLD_NOW); } + + if (handle == IntPtr.Zero && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { + // Try to load system-wide MoltenVK from /usr/local/lib or /opt/homebrew/lib. + // It is not possible to install MoltenVK under /usr/lib on macOS due to System Integrity Protection. + string localPath = Path.Combine("/opt/homebrew/lib", libraryName); + handle = Libdl.dlopen(localPath, Libdl.RTLD_NOW); + + if (handle == IntPtr.Zero) { + localPath = Path.Combine("/usr/local/lib", libraryName); + handle = Libdl.dlopen(localPath, Libdl.RTLD_NOW); + } + } } return handle; diff --git a/src/vk/Enums.cs b/src/vk/Enums.cs new file mode 100644 index 0000000..26ce96a --- /dev/null +++ b/src/vk/Enums.cs @@ -0,0 +1,16 @@ +namespace Vulkan +{ + public enum VkInstanceCreateFlagBits: uint { + /// + /// Provided by VK_KHR_portability_enumeration. Specifies that the instance will enumerate + /// available Vulkan Portability-compliant physical devices and groups in addition to the + /// Vulkan physical devices and groups that are enumerated by default. + /// + PortabilityBitKHR = 1, + }; + + public static partial class RawConstants + { + public const VkInstanceCreateFlagBits VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR = VkInstanceCreateFlagBits.PortabilityBitKHR; + }; +}