mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2025-01-09 15:51:59 +00:00
metal: Bump SharpMetal to preview 21
This commit is contained in:
parent
153d1ef06b
commit
664c63c6a8
5 changed files with 39 additions and 18 deletions
|
@ -44,7 +44,7 @@
|
|||
<PackageVersion Include="Gommon" Version="2.6.8" />
|
||||
<PackageVersion Include="securifybv.ShellLink" Version="0.1.0" />
|
||||
<PackageVersion Include="shaderc.net" Version="0.1.0" />
|
||||
<PackageVersion Include="SharpMetal" Version="1.0.0-preview20" />
|
||||
<PackageVersion Include="SharpMetal" Version="1.0.0-preview21" />
|
||||
<PackageVersion Include="SharpZipLib" Version="1.4.2" />
|
||||
<PackageVersion Include="Silk.NET.Vulkan" Version="2.21.0" />
|
||||
<PackageVersion Include="Silk.NET.Vulkan.Extensions.EXT" Version="2.21.0" />
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using SharpMetal;
|
||||
using SharpMetal.Foundation;
|
||||
using SharpMetal.ObjectiveCCore;
|
||||
using SharpMetal.QuartzCore;
|
||||
using System.Runtime.Versioning;
|
||||
|
@ -9,22 +10,13 @@ namespace Ryujinx.Graphics.Metal.SharpMetalExtensions
|
|||
[SupportedOSPlatform("macOS")]
|
||||
public static class CAMetalLayerExtensions
|
||||
{
|
||||
private static readonly Selector sel_displaySyncEnabled = "displaySyncEnabled";
|
||||
private static readonly Selector sel_setDisplaySyncEnabled = "setDisplaySyncEnabled:";
|
||||
|
||||
private static readonly Selector sel_developerHUDProperties = "developerHUDProperties";
|
||||
private static readonly Selector sel_setDeveloperHUDProperties = "setDeveloperHUDProperties:";
|
||||
|
||||
public static bool IsDisplaySyncEnabled(this CAMetalLayer metalLayer)
|
||||
=> ObjectiveCRuntime.bool_objc_msgSend(metalLayer.NativePtr, sel_displaySyncEnabled);
|
||||
public static NSDictionary GetDeveloperHudProperties(this CAMetalLayer metalLayer)
|
||||
=> new(ObjectiveCRuntime.IntPtr_objc_msgSend(metalLayer.NativePtr, sel_developerHUDProperties));
|
||||
|
||||
public static void SetDisplaySyncEnabled(this CAMetalLayer metalLayer, bool enabled)
|
||||
=> ObjectiveCRuntime.objc_msgSend(metalLayer.NativePtr, sel_setDisplaySyncEnabled, enabled);
|
||||
|
||||
public static nint GetDeveloperHudProperties(this CAMetalLayer metalLayer)
|
||||
=> ObjectiveCRuntime.IntPtr_objc_msgSend(metalLayer.NativePtr, sel_developerHUDProperties);
|
||||
|
||||
public static void SetDeveloperHudProperties(this CAMetalLayer metalLayer, nint dictionaryPointer)
|
||||
=> ObjectiveCRuntime.objc_msgSend(metalLayer.NativePtr, sel_setDeveloperHUDProperties, dictionaryPointer);
|
||||
public static void SetDeveloperHudProperties(this CAMetalLayer metalLayer, NSDictionary dictionary)
|
||||
=> ObjectiveCRuntime.objc_msgSend(metalLayer.NativePtr, sel_setDeveloperHUDProperties, dictionary);
|
||||
}
|
||||
}
|
||||
|
|
28
src/Ryujinx.Graphics.Metal.SharpMetalExtensions/NSHelper.cs
Normal file
28
src/Ryujinx.Graphics.Metal.SharpMetalExtensions/NSHelper.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using SharpMetal.Foundation;
|
||||
using SharpMetal.ObjectiveCCore;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Graphics.Metal.SharpMetalExtensions
|
||||
{
|
||||
[SupportedOSPlatform("macOS")]
|
||||
public static class NSHelper
|
||||
{
|
||||
public static unsafe string ToDotNetString(this NSString source)
|
||||
{
|
||||
char[] sourceBuffer = new char[source.Length];
|
||||
fixed (char* pSourceBuffer = sourceBuffer)
|
||||
{
|
||||
ObjectiveC.bool_objc_msgSend(source,
|
||||
"getCString:maxLength:encoding:",
|
||||
pSourceBuffer,
|
||||
source.MaximumLengthOfBytes(NSStringEncoding.UTF16) + 1,
|
||||
(ulong)NSStringEncoding.UTF16);
|
||||
}
|
||||
|
||||
return new string(sourceBuffer);
|
||||
}
|
||||
|
||||
public static NSString ToNSString(this string source)
|
||||
=> new(ObjectiveC.IntPtr_objc_msgSend(new ObjectiveCClass("NSString"), "stringWithUTF8String:", source));
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Metal
|
|||
public bool ScreenCaptureRequested { get; set; }
|
||||
|
||||
private readonly MetalRenderer _renderer;
|
||||
private readonly CAMetalLayer _metalLayer;
|
||||
private CAMetalLayer _metalLayer;
|
||||
|
||||
private int _width;
|
||||
private int _height;
|
||||
|
@ -147,10 +147,10 @@ namespace Ryujinx.Graphics.Metal
|
|||
switch (vSyncMode)
|
||||
{
|
||||
case VSyncMode.Unbounded:
|
||||
_metalLayer.SetDisplaySyncEnabled(false);
|
||||
_metalLayer.DisplaySyncEnabled = false;
|
||||
break;
|
||||
case VSyncMode.Switch:
|
||||
_metalLayer.SetDisplaySyncEnabled(true);
|
||||
_metalLayer.DisplaySyncEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue