Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metal] Make P/Invokes have blittable signatures. #20009

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Metal/MTLDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static IMTLDevice [] GetAllDevices ()
[UnsupportedOSPlatform ("maccatalyst")]
#endif
[DllImport (Constants.MetalLibrary)]
unsafe static extern IntPtr MTLCopyAllDevicesWithObserver (out IntPtr observer, BlockLiteral* handler);
unsafe static extern IntPtr MTLCopyAllDevicesWithObserver (IntPtr* observer, BlockLiteral* handler);

#if NET
[SupportedOSPlatform ("macos")]
Expand All @@ -118,7 +118,7 @@ public static IMTLDevice [] GetAllDevices (MTLDeviceNotificationHandler handler,
block.SetupBlockUnsafe (static_notificationHandler, handler);
#endif

rv = MTLCopyAllDevicesWithObserver (out observer_handle, &block);
rv = MTLCopyAllDevicesWithObserver (&observer_handle, &block);
}

var obj = NSArray.ArrayFromHandle<IMTLDevice> (rv);
Expand Down
7 changes: 5 additions & 2 deletions src/Metal/MTLVertexDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public partial class MTLVertexDescriptor {
[SupportedOSPlatform ("maccatalyst")]
#endif
[DllImport (Constants.MetalKitLibrary)]
static extern /* MTLVertexDescriptor __nonnull */ IntPtr MTKMetalVertexDescriptorFromModelIOWithError (/* MDLVertexDescriptor __nonnull */ IntPtr modelIODescriptor, out IntPtr error);
unsafe static extern /* MTLVertexDescriptor __nonnull */ IntPtr MTKMetalVertexDescriptorFromModelIOWithError (/* MDLVertexDescriptor __nonnull */ IntPtr modelIODescriptor, IntPtr* error);

#if NET
[SupportedOSPlatform ("ios")]
Expand All @@ -53,7 +53,10 @@ public partial class MTLVertexDescriptor {
if (descriptor is null)
throw new ArgumentException ("descriptor");
IntPtr err;
var vd = Runtime.GetNSObject<MTLVertexDescriptor> (MTKMetalVertexDescriptorFromModelIOWithError (descriptor.Handle, out err));
MTLVertexDescriptor? vd;
unsafe {
vd = Runtime.GetNSObject<MTLVertexDescriptor> (MTKMetalVertexDescriptorFromModelIOWithError (descriptor.Handle, &err));
}
error = Runtime.GetNSObject<NSError> (err);
return vd;
}
Expand Down
2 changes: 0 additions & 2 deletions tests/cecil-tests/BlittablePInvokes.KnownFailures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,6 @@ public partial class BlittablePInvokes {
"System.IntPtr MediaAccessibility.MACaptionAppearance::MACaptionAppearanceCopyWindowColor(System.IntPtr,System.IntPtr&)",
"System.IntPtr MediaAccessibility.MACaptionAppearance::MACaptionAppearanceGetTextEdgeStyle(System.IntPtr,System.IntPtr&)",
"System.IntPtr MediaAccessibility.MAImageCaptioning::MAImageCaptioningCopyCaption(System.IntPtr,System.IntPtr&)",
"System.IntPtr Metal.MTLDevice::MTLCopyAllDevicesWithObserver(System.IntPtr&,ObjCRuntime.BlockLiteral*)",
"System.IntPtr Metal.MTLVertexDescriptor::MTKMetalVertexDescriptorFromModelIOWithError(System.IntPtr,System.IntPtr&)",
"System.IntPtr ModelIO.MDLVertexDescriptor::MTKModelIOVertexDescriptorFromMetalWithError(System.IntPtr,System.IntPtr&)",
"System.IntPtr ObjCRuntime.Selector::GetHandle(System.String)",
"System.IntPtr SearchKit.SKIndex::SKIndexOpenWithURL(System.IntPtr,System.IntPtr,System.Boolean)",
Expand Down
Loading