Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/vk/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions src/vk/Enums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Vulkan
{
public enum VkInstanceCreateFlagBits: uint {
/// <summary>
/// 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.
/// </summary>
PortabilityBitKHR = 1,
};

public static partial class RawConstants
{
public const VkInstanceCreateFlagBits VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR = VkInstanceCreateFlagBits.PortabilityBitKHR;
};
}