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

[GLKit] Make the GLKVertexAttributeParametersFromModelIO P/Invoke have a blittable signature. #20529

Merged
merged 1 commit into from
Apr 29, 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
30 changes: 30 additions & 0 deletions src/GLKit/Defs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 0 additions & 1 deletion tests/cecil-tests/BlittablePInvokes.KnownFailures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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*)",
Expand Down
Loading