2024-09-01 20:33:11 +00:00
|
|
|
using Silk.NET.Core.Loader;
|
2023-01-13 00:31:21 +00:00
|
|
|
using Silk.NET.Vulkan;
|
|
|
|
using System;
|
|
|
|
using System.Runtime.InteropServices;
|
2023-03-04 13:43:08 +00:00
|
|
|
using System.Runtime.Versioning;
|
2023-01-13 00:31:21 +00:00
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Vulkan.MoltenVK
|
|
|
|
{
|
|
|
|
[SupportedOSPlatform("macos")]
|
|
|
|
public static partial class MVKInitialization
|
|
|
|
{
|
2024-09-01 20:33:11 +00:00
|
|
|
private const string VulkanLib = "libvulkan.dylib";
|
|
|
|
|
2023-01-13 00:31:21 +00:00
|
|
|
[LibraryImport("libMoltenVK.dylib")]
|
|
|
|
private static partial Result vkGetMoltenVKConfigurationMVK(IntPtr unusedInstance, out MVKConfiguration config, in IntPtr configSize);
|
|
|
|
|
|
|
|
[LibraryImport("libMoltenVK.dylib")]
|
|
|
|
private static partial Result vkSetMoltenVKConfigurationMVK(IntPtr unusedInstance, in MVKConfiguration config, in IntPtr configSize);
|
|
|
|
|
|
|
|
public static void Initialize()
|
|
|
|
{
|
|
|
|
var configSize = (IntPtr)Marshal.SizeOf<MVKConfiguration>();
|
|
|
|
|
|
|
|
vkGetMoltenVKConfigurationMVK(IntPtr.Zero, out MVKConfiguration config, configSize);
|
|
|
|
|
|
|
|
config.UseMetalArgumentBuffers = true;
|
|
|
|
|
|
|
|
config.SemaphoreSupportStyle = MVKVkSemaphoreSupportStyle.MVK_CONFIG_VK_SEMAPHORE_SUPPORT_STYLE_SINGLE_QUEUE;
|
|
|
|
config.SynchronousQueueSubmits = false;
|
|
|
|
|
2023-05-10 01:31:52 +00:00
|
|
|
config.ResumeLostDevice = true;
|
|
|
|
|
2023-01-13 00:31:21 +00:00
|
|
|
vkSetMoltenVKConfigurationMVK(IntPtr.Zero, config, configSize);
|
|
|
|
}
|
2024-09-01 20:33:11 +00:00
|
|
|
|
|
|
|
private static string[] Resolver(string path)
|
|
|
|
{
|
|
|
|
if (path.EndsWith(VulkanLib))
|
|
|
|
{
|
|
|
|
path = path[..^VulkanLib.Length] + "libMoltenVK.dylib";
|
|
|
|
return [path];
|
|
|
|
}
|
|
|
|
return Array.Empty<string>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void InitializeResolver()
|
|
|
|
{
|
|
|
|
((DefaultPathResolver)PathResolver.Default).Resolvers.Insert(0, Resolver);
|
|
|
|
}
|
2023-01-13 00:31:21 +00:00
|
|
|
}
|
2023-07-01 10:31:42 +00:00
|
|
|
}
|