SilkVulkanTutorial
SilkVulkanTutorial copied to clipboard
Add osx (m1) support
At this moment the samples crashed on m1, but original examples from VulkanSDK with MoltenVK are work fine
For anyone with this issue, I found a fix. On M1 you need to set it up so that vulkan operates in a portability mode that is compatible with molten. Change the following function in each of the projects.
private string[] GetRequiredExtensions()
{
var glfwExtensions = window!.VkSurface!.GetRequiredExtensions(out var glfwExtensionCount);
var extensions = SilkMarshal.PtrToStringArray((nint)glfwExtensions, (int)glfwExtensionCount);
extensions = extensions.Append("VK_KHR_portability_enumeration").ToArray();
if (EnableValidationLayers)
{
return extensions.Append(ExtDebugUtils.ExtensionName).ToArray();
}
return extensions;
}
and then the place where it's called, you need to add the createInfo.Flags bit
var extensions = GetRequiredExtensions();
createInfo.EnabledExtensionCount = (uint)extensions.Length;
createInfo.PpEnabledExtensionNames = (byte**)SilkMarshal.StringArrayToPtr(extensions); ;
createInfo.Flags = InstanceCreateFlags.EnumeratePortabilityBitKhr;
After that, it all works.
Works well. Thanks!