mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-19 16:06:54 +02: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
|
@ -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 void SetDisplaySyncEnabled(this CAMetalLayer metalLayer, bool enabled)
|
||||
=> ObjectiveCRuntime.objc_msgSend(metalLayer.NativePtr, sel_setDisplaySyncEnabled, enabled);
|
||||
public static NSDictionary GetDeveloperHudProperties(this CAMetalLayer metalLayer)
|
||||
=> new(ObjectiveCRuntime.IntPtr_objc_msgSend(metalLayer.NativePtr, sel_developerHUDProperties));
|
||||
|
||||
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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue