2024-09-01 21:33:11 +01: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 10:43:08 -03: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 21:33:11 +01:00
|
|
|
private const string VulkanLib = "libvulkan.dylib";
|
|
|
|
|
|
2023-01-13 00:31:21 +00:00
|
|
|
[LibraryImport("libMoltenVK.dylib")]
|
2024-10-26 08:46:41 -05:00
|
|
|
private static partial Result vkGetMoltenVKConfigurationMVK(nint unusedInstance, out MVKConfiguration config, in nint configSize);
|
2023-01-13 00:31:21 +00:00
|
|
|
|
|
|
|
|
[LibraryImport("libMoltenVK.dylib")]
|
2024-10-26 08:46:41 -05:00
|
|
|
private static partial Result vkSetMoltenVKConfigurationMVK(nint unusedInstance, in MVKConfiguration config, in nint configSize);
|
2023-01-13 00:31:21 +00:00
|
|
|
|
|
|
|
|
public static void Initialize()
|
|
|
|
|
{
|
2025-01-25 14:12:17 -06:00
|
|
|
IntPtr configSize = (nint)Marshal.SizeOf<MVKConfiguration>();
|
2023-01-13 00:31:21 +00:00
|
|
|
|
2024-10-26 08:46:41 -05:00
|
|
|
vkGetMoltenVKConfigurationMVK(nint.Zero, out MVKConfiguration config, configSize);
|
2023-01-13 00:31:21 +00:00
|
|
|
|
|
|
|
|
config.UseMetalArgumentBuffers = true;
|
|
|
|
|
|
|
|
|
|
config.SemaphoreSupportStyle = MVKVkSemaphoreSupportStyle.MVK_CONFIG_VK_SEMAPHORE_SUPPORT_STYLE_SINGLE_QUEUE;
|
|
|
|
|
config.SynchronousQueueSubmits = false;
|
|
|
|
|
|
2023-05-09 22:31:52 -03:00
|
|
|
config.ResumeLostDevice = true;
|
|
|
|
|
|
2024-10-26 08:46:41 -05:00
|
|
|
vkSetMoltenVKConfigurationMVK(nint.Zero, config, configSize);
|
2023-01-13 00:31:21 +00:00
|
|
|
}
|
2024-09-01 21:33:11 +01:00
|
|
|
|
|
|
|
|
private static string[] Resolver(string path)
|
|
|
|
|
{
|
|
|
|
|
if (path.EndsWith(VulkanLib))
|
|
|
|
|
{
|
|
|
|
|
path = path[..^VulkanLib.Length] + "libMoltenVK.dylib";
|
|
|
|
|
return [path];
|
|
|
|
|
}
|
2025-01-26 15:32:25 -06:00
|
|
|
return [];
|
2024-09-01 21:33:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void InitializeResolver()
|
|
|
|
|
{
|
|
|
|
|
((DefaultPathResolver)PathResolver.Default).Resolvers.Insert(0, Resolver);
|
|
|
|
|
}
|
2023-01-13 00:31:21 +00:00
|
|
|
}
|
2023-07-01 12:31:42 +02:00
|
|
|
}
|