From d75aec51c96ff3fc786f71e54ad2db117957497b Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 25 Apr 2024 19:20:37 +0200 Subject: [PATCH] [GLKit] Make the GLKVertexAttributeParametersFromModelIO P/Invoke have a blittable signature. This was complicated a bit because it uses a non-blittable struct we can't change because it's public API. So introduce an internal temporary blittable struct. Contributes towards #15684. --- src/GLKit/Defs.cs | 30 +++++++++++++++++++ .../BlittablePInvokes.KnownFailures.cs | 1 - 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/GLKit/Defs.cs b/src/GLKit/Defs.cs index a28058380376..355c9918fe04 100644 --- a/src/GLKit/Defs.cs +++ b/src/GLKit/Defs.cs @@ -142,17 +142,47 @@ public enum GLKTextureLoaderError { public struct GLKVertexAttributeParameters { public uint Type; public uint Size; +#if XAMCORE_5_0 + byte normalized; + public bool Normalized { + get => normalized != 0; + set => normalized = value.AsByte (); + } +#else [MarshalAs (UnmanagedType.I1)] public bool Normalized; +#endif #if !COREBUILD [DllImport (Constants.GLKitLibrary, EntryPoint = "GLKVertexAttributeParametersFromModelIO")] +#if XAMCORE_5_0 extern static GLKVertexAttributeParameters FromVertexFormat_ (nuint vertexFormat); +#else + extern static GLKVertexAttributeParametersInternal FromVertexFormat_ (nuint vertexFormat); +#endif public static GLKVertexAttributeParameters FromVertexFormat (MDLVertexFormat vertexFormat) { +#if XAMCORE_5_0 return FromVertexFormat_ ((nuint) (ulong) vertexFormat); +#else + var tmp = FromVertexFormat_ ((nuint) (ulong) vertexFormat); + var rv = new GLKVertexAttributeParameters (); + rv.Type = tmp.Type; + rv.Size = tmp.Size; + rv.Normalized = tmp.Normalized != 0; + return rv; +#endif } #endif } + +#if !XAMCORE_5_0 + [StructLayout (LayoutKind.Sequential)] + struct GLKVertexAttributeParametersInternal { + public uint Type; + public uint Size; + public byte Normalized; + } +#endif // !XAMCORE_5_0 } diff --git a/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs b/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs index a3416a4edcd5..54890a39ad18 100644 --- a/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs +++ b/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs @@ -64,7 +64,6 @@ public partial class BlittablePInvokes { "AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSend(System.IntPtr,System.IntPtr)", "AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper_stret(System.IntPtr,System.IntPtr)", "AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper(System.IntPtr,System.IntPtr)", - "GLKit.GLKVertexAttributeParameters GLKit.GLKVertexAttributeParameters::FromVertexFormat_(System.UIntPtr)", "MediaToolbox.MTAudioProcessingTapError MediaToolbox.MTAudioProcessingTap::MTAudioProcessingTapCreate(System.IntPtr,MediaToolbox.MTAudioProcessingTap/Callbacks&,MediaToolbox.MTAudioProcessingTapCreationFlags,System.IntPtr&)", "MediaToolbox.MTAudioProcessingTapError MediaToolbox.MTAudioProcessingTap::MTAudioProcessingTapGetSourceAudio(System.IntPtr,System.IntPtr,System.IntPtr,MediaToolbox.MTAudioProcessingTapFlags&,CoreMedia.CMTimeRange&,System.IntPtr&)", "ObjCRuntime.NativeHandle ObjCRuntime.Messaging::NativeHandle_objc_msgSend_AudioComponentDescription_ref_NativeHandle(System.IntPtr,System.IntPtr,AudioUnit.AudioComponentDescription,ObjCRuntime.NativeHandle*)",