From ad1a3b789fc3961a835305425221572c04da94e7 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 12 Sep 2024 13:03:49 +0200 Subject: [PATCH] [CoreVideo] Implement Xcode 16.0 beta 1-6 changes. (#21163) Note: there were no changes in beta 2, beta 3, beta 5 or beta 6. --- src/CoreVideo/CVDisplayLink.cs | 204 ++++++++++++++++++ src/CoreVideo/CVMetalBuffer.cs | 58 +++++ src/CoreVideo/CVMetalBufferCache.cs | 125 +++++++++++ src/CoreVideo/CVPixelFormatDescription.cs | 1 + src/CoreVideo/CVPixelFormatType.cs | 53 +++++ src/corevideo.cs | 32 +++ src/frameworks.sources | 2 + .../Documentation.KnownFailures.txt | 11 + tests/introspection/ApiCMAttachmentTest.cs | 2 + .../CoreVideo/CVMetalBufferCacheTest.cs | 93 ++++++++ .../CoreVideo/CVMetalBufferTest.cs | 56 +++++ .../MacCatalyst-CoreVideo.todo | 9 - .../api-annotations-dotnet/iOS-CoreVideo.todo | 9 - .../macOS-CoreVideo.todo | 30 --- .../tvOS-CoreVideo.todo | 9 - tests/xtro-sharpie/iOS-CoreVideo.todo | 9 - tests/xtro-sharpie/macOS-CoreVideo.todo | 30 --- tests/xtro-sharpie/tvOS-CoreVideo.todo | 9 - tests/xtro-sharpie/watchOS-CoreVideo.todo | 2 - 19 files changed, 637 insertions(+), 107 deletions(-) create mode 100644 src/CoreVideo/CVMetalBuffer.cs create mode 100644 src/CoreVideo/CVMetalBufferCache.cs create mode 100644 tests/monotouch-test/CoreVideo/CVMetalBufferCacheTest.cs create mode 100644 tests/monotouch-test/CoreVideo/CVMetalBufferTest.cs delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreVideo.todo delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreVideo.todo delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreVideo.todo delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreVideo.todo delete mode 100644 tests/xtro-sharpie/iOS-CoreVideo.todo delete mode 100644 tests/xtro-sharpie/macOS-CoreVideo.todo delete mode 100644 tests/xtro-sharpie/tvOS-CoreVideo.todo delete mode 100644 tests/xtro-sharpie/watchOS-CoreVideo.todo diff --git a/src/CoreVideo/CVDisplayLink.cs b/src/CoreVideo/CVDisplayLink.cs index 7880dc778d9..edc6d910930 100644 --- a/src/CoreVideo/CVDisplayLink.cs +++ b/src/CoreVideo/CVDisplayLink.cs @@ -62,11 +62,13 @@ internal CVDisplayLink (NativeHandle handle, bool owns) } #if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [SupportedOSPlatform ("macos12.0")] [UnsupportedOSPlatform ("ios")] [UnsupportedOSPlatform ("tvos")] [UnsupportedOSPlatform ("maccatalyst")] #else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [Mac (12,0)] [NoiOS] [NoTV] @@ -76,11 +78,13 @@ internal CVDisplayLink (NativeHandle handle, bool owns) unsafe static extern CVReturn CVDisplayLinkCreateWithCGDisplay (uint displayId, IntPtr* displayLink); #if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [SupportedOSPlatform ("macos12.0")] [UnsupportedOSPlatform ("ios")] [UnsupportedOSPlatform ("tvos")] [UnsupportedOSPlatform ("maccatalyst")] #else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [Mac (12,0)] [NoiOS] [NoTV] @@ -113,11 +117,13 @@ internal CVDisplayLink (NativeHandle handle, bool owns) => CreateFromDisplayId (displayId, out var _); #if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [SupportedOSPlatform ("macos12.0")] [UnsupportedOSPlatform ("ios")] [UnsupportedOSPlatform ("tvos")] [UnsupportedOSPlatform ("maccatalyst")] #else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [Mac (12,0)] [NoiOS] [NoTV] @@ -127,11 +133,13 @@ internal CVDisplayLink (NativeHandle handle, bool owns) unsafe static extern CVReturn CVDisplayLinkCreateWithCGDisplays (uint* displayArray, nint count, IntPtr* displayLink); #if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [SupportedOSPlatform ("macos12.0")] [UnsupportedOSPlatform ("ios")] [UnsupportedOSPlatform ("tvos")] [UnsupportedOSPlatform ("maccatalyst")] #else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [Mac (12,0)] [NoiOS] [NoTV] @@ -170,11 +178,13 @@ internal CVDisplayLink (NativeHandle handle, bool owns) => CreateFromDisplayIds (displayIds, out var _); #if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [SupportedOSPlatform ("macos12.0")] [UnsupportedOSPlatform ("ios")] [UnsupportedOSPlatform ("tvos")] [UnsupportedOSPlatform ("maccatalyst")] #else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [Mac (12,0)] [NoiOS] [NoTV] @@ -184,11 +194,13 @@ internal CVDisplayLink (NativeHandle handle, bool owns) unsafe static extern CVReturn CVDisplayLinkCreateWithOpenGLDisplayMask (uint mask, IntPtr* displayLinkOut); #if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [SupportedOSPlatform ("macos12.0")] [UnsupportedOSPlatform ("ios")] [UnsupportedOSPlatform ("tvos")] [UnsupportedOSPlatform ("maccatalyst")] #else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [Mac (12,0)] [NoiOS] [NoTV] @@ -219,17 +231,41 @@ internal CVDisplayLink (NativeHandle handle, bool owns) public static CVDisplayLink? CreateFromOpenGLMask (uint mask) => CreateFromOpenGLMask (mask, out var _); +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif [DllImport (Constants.CoreVideoLibrary)] extern static void CVDisplayLinkRetain (IntPtr handle); +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif [DllImport (Constants.CoreVideoLibrary)] extern static void CVDisplayLinkRelease (IntPtr handle); +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif protected internal override void Retain () { CVDisplayLinkRetain (GetCheckedHandle ()); } +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif protected internal override void Release () { CVDisplayLinkRelease (GetCheckedHandle ()); @@ -245,7 +281,20 @@ protected override void Dispose (bool disposing) } [DllImport (Constants.CoreVideoLibrary)] +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif unsafe extern static CVReturn CVDisplayLinkCreateWithActiveCGDisplays (IntPtr* displayLinkOut); + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif static IntPtr Create () { CVReturn ret; @@ -260,80 +309,217 @@ static IntPtr Create () return handle; } + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif public CVDisplayLink () : base (Create (), true) { } +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif [DllImport (Constants.CoreVideoLibrary)] extern static CVReturn CVDisplayLinkSetCurrentCGDisplay (IntPtr displayLink, int /* CGDirectDisplayID = uint32_t */ displayId); + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif public CVReturn SetCurrentDisplay (int displayId) { return CVDisplayLinkSetCurrentCGDisplay (Handle, displayId); } +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif [DllImport (Constants.CoreVideoLibrary)] extern static CVReturn CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext (IntPtr displayLink, IntPtr cglContext, IntPtr cglPixelFormat); + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif public CVReturn SetCurrentDisplay (CGLContext cglContext, CGLPixelFormat cglPixelFormat) { return CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext (Handle, cglContext.Handle, cglPixelFormat.Handle); } +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif [DllImport (Constants.CoreVideoLibrary)] extern static int /* CGDirectDisplayID = uint32_t */ CVDisplayLinkGetCurrentCGDisplay (IntPtr displayLink); + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif public int GetCurrentDisplay () { return CVDisplayLinkGetCurrentCGDisplay (Handle); } +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif [DllImport (Constants.CoreVideoLibrary)] extern static CVReturn CVDisplayLinkStart (IntPtr displayLink); + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif public CVReturn Start () { return CVDisplayLinkStart (Handle); } +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif [DllImport (Constants.CoreVideoLibrary)] extern static CVReturn CVDisplayLinkStop (IntPtr displayLink); + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif public CVReturn Stop () { return CVDisplayLinkStop (Handle); } +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif [DllImport (Constants.CoreVideoLibrary)] extern static CVTime CVDisplayLinkGetNominalOutputVideoRefreshPeriod (IntPtr displayLink); + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif public CVTime NominalOutputVideoRefreshPeriod { get { return CVDisplayLinkGetNominalOutputVideoRefreshPeriod (Handle); } } +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif [DllImport (Constants.CoreVideoLibrary)] extern static CVTime CVDisplayLinkGetOutputVideoLatency (IntPtr displayLink); + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif public CVTime OutputVideoLatency { get { return CVDisplayLinkGetOutputVideoLatency (Handle); } } +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif [DllImport (Constants.CoreVideoLibrary)] extern static double CVDisplayLinkGetActualOutputVideoRefreshPeriod (IntPtr displayLink); + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif public double ActualOutputVideoRefreshPeriod { get { return CVDisplayLinkGetActualOutputVideoRefreshPeriod (Handle); } } +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif [DllImport (Constants.CoreVideoLibrary)] extern static byte CVDisplayLinkIsRunning (IntPtr displayLink); + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif public bool IsRunning { get { return CVDisplayLinkIsRunning (Handle) != 0; } } +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif [DllImport (Constants.CoreVideoLibrary)] unsafe extern static CVReturn CVDisplayLinkGetCurrentTime (IntPtr displayLink, CVTimeStamp* outTime); + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif public CVReturn GetCurrentTime (out CVTimeStamp outTime) { CVReturn ret; @@ -373,12 +559,22 @@ ref System.Runtime.CompilerServices.Unsafe.AsRef (inOutputTime), } #if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] [DllImport (Constants.CoreVideoLibrary)] extern static unsafe CVReturn CVDisplayLinkSetOutputCallback (IntPtr displayLink, delegate* unmanaged function, IntPtr userInfo); #else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [DllImport (Constants.CoreVideoLibrary)] extern static CVReturn CVDisplayLinkSetOutputCallback (IntPtr displayLink, CVDisplayLinkOutputCallback function, IntPtr userInfo); #endif + +#if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] + [SupportedOSPlatform ("macos")] +#else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] +#endif public CVReturn SetOutputCallback (DisplayLinkOutputCallback callback) { callbackHandle = GCHandle.Alloc (callback); @@ -395,11 +591,13 @@ public CVReturn SetOutputCallback (DisplayLinkOutputCallback callback) } #if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [SupportedOSPlatform ("macos12.0")] [UnsupportedOSPlatform ("ios")] [UnsupportedOSPlatform ("tvos")] [UnsupportedOSPlatform ("maccatalyst")] #else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [Mac (12,0)] [NoiOS] [NoTV] @@ -409,11 +607,13 @@ public CVReturn SetOutputCallback (DisplayLinkOutputCallback callback) static extern nuint CVDisplayLinkGetTypeID (); #if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [SupportedOSPlatform ("macos12.0")] [UnsupportedOSPlatform ("ios")] [UnsupportedOSPlatform ("tvos")] [UnsupportedOSPlatform ("maccatalyst")] #else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [Mac (12,0)] [NoiOS] [NoTV] @@ -423,11 +623,13 @@ public static nuint GetTypeId () => CVDisplayLinkGetTypeID (); #if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [SupportedOSPlatform ("macos12.0")] [UnsupportedOSPlatform ("ios")] [UnsupportedOSPlatform ("tvos")] [UnsupportedOSPlatform ("maccatalyst")] #else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [Mac (12,0)] [NoiOS] [NoTV] @@ -437,11 +639,13 @@ public static nuint GetTypeId () unsafe static extern int CVDisplayLinkTranslateTime (IntPtr displayLink, CVTimeStamp inTime, CVTimeStamp* outTime); #if NET + [ObsoletedOSPlatform ("macos15.0", "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [SupportedOSPlatform ("macos12.0")] [UnsupportedOSPlatform ("ios")] [UnsupportedOSPlatform ("tvos")] [UnsupportedOSPlatform ("maccatalyst")] #else + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'NSView.GetDisplayLink', 'NSWindow.GetDisplayLink' or 'NSScreen.GetDisplayLink' instead.")] [Mac (12,0)] [NoiOS] [NoTV] diff --git a/src/CoreVideo/CVMetalBuffer.cs b/src/CoreVideo/CVMetalBuffer.cs new file mode 100644 index 00000000000..398ba2b5bef --- /dev/null +++ b/src/CoreVideo/CVMetalBuffer.cs @@ -0,0 +1,58 @@ +#if !WATCH +using System; +using System.Runtime.InteropServices; + +using CoreFoundation; +using CoreGraphics; +using Foundation; +using Metal; +using ObjCRuntime; + +#if !NET +using NativeHandle = System.IntPtr; +#endif + +#nullable enable + +namespace CoreVideo { + + /// A CVPixelBuffer wrapped in a Metal based buffer. + /// This type is used to provide buffers to Metal. +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [NoWatch, TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public class CVMetalBuffer : CVBuffer { +#if !COREBUILD + [Preserve (Conditional = true)] + internal CVMetalBuffer (NativeHandle handle, bool owns) + : base (handle, owns) + { + } + + [DllImport (Constants.CoreVideoLibrary)] + extern static /* CFTypeID */ nint CVMetalBufferCacheGetTypeID (); + + public static nint GetTypeId () + { + return CVMetalBufferCacheGetTypeID (); + } + + [DllImport (Constants.CoreVideoLibrary)] + extern static /* id CV_NULLABLE */ IntPtr CVMetalBufferGetBuffer (IntPtr /* CVMetalBufferRef CV_NONNULL */ buffer); + + /// Retrieve the Metal MTLBuffer for the CVMetalBuffer. + public IMTLBuffer? GetMetalBuffer () + { + return Runtime.GetINativeObject (CVMetalBufferGetBuffer (GetCheckedHandle ()), owns: false); + } + +#endif // !COREBUILD + } +} + +#endif // !WATCH diff --git a/src/CoreVideo/CVMetalBufferCache.cs b/src/CoreVideo/CVMetalBufferCache.cs new file mode 100644 index 00000000000..ae0562fa29d --- /dev/null +++ b/src/CoreVideo/CVMetalBufferCache.cs @@ -0,0 +1,125 @@ +#if !WATCH +using System; +using System.Runtime.InteropServices; + +using CoreFoundation; +using CoreGraphics; +using Foundation; +using Metal; +using ObjCRuntime; + +#if !NET +using NativeHandle = System.IntPtr; +#endif + +#nullable enable + +namespace CoreVideo { + + /// A cache used to manage instances. +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [NoWatch, TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public class CVMetalBufferCache : NativeObject { +#if !COREBUILD + [Preserve (Conditional = true)] + internal CVMetalBufferCache (NativeHandle handle, bool owns) + : base (handle, owns) + { + } + + [DllImport (Constants.CoreVideoLibrary)] + extern static /* CFTypeID */ nint CVMetalBufferGetTypeID (); + + public static nint GetTypeId () + { + return CVMetalBufferGetTypeID (); + } + + [DllImport (Constants.CoreVideoLibrary)] + unsafe extern static /* CVReturn */ CVReturn CVMetalBufferCacheCreate ( + IntPtr /* CFAllocatorRef CV_NULLABLE */ allocator, + IntPtr /* CFDictionaryRef CV_NULLABLE */ cacheAttributes, + IntPtr /* id CV_NONNULL */ metalDevice, + IntPtr* /* CV_RETURNS_RETAINED_PARAMETER CVMetalBufferCacheRef CV_NULLABLE * CV_NONNULL */ cacheOut + ); + + static IntPtr Create (IMTLDevice device, NSDictionary? attributes) + { + IntPtr handle; + CVReturn res; + unsafe { + res = CVMetalBufferCacheCreate (IntPtr.Zero, attributes.GetHandle (), device.GetNonNullHandle (nameof (device)), &handle); + } + if (res != CVReturn.Success) + throw new Exception ($"Could not create CVMetalBufferCache, CVMetalBufferCacheCreate returned: {res}"); + return handle; + } + + /// Create a new instance. + /// The Metal device to create the instance for. + /// An optional dictionary of attributes to apply to the cache. + public CVMetalBufferCache (IMTLDevice device, NSDictionary? attributes) + : base (Create (device, attributes), owns: true) + { + } + + /// Create a new instance. + /// The Metal device to create the instance for. + /// Optional attributes to apply to the cache. + public CVMetalBufferCache (IMTLDevice device, CVMetalBufferCacheAttributes? attributes) + : this (device, attributes?.Dictionary) + { + } + + [DllImport (Constants.CoreVideoLibrary)] + unsafe extern static /* CVReturn */ CVReturn CVMetalBufferCacheCreateBufferFromImage ( + IntPtr /* CFAllocatorRef CV_NULLABLE */ allocator, + IntPtr /* CVMetalBufferCacheRef CV_NONNULL */ bufferCache, + IntPtr /* CVImageBufferRef CV_NONNULL */ imageBuffer, + IntPtr* /* CV_RETURNS_RETAINED_PARAMETER CVMetalBufferRef CV_NULLABLE * CV_NONNULL */ bufferOut + ); + + /// Create a for an existing . + /// The image buffer to create the from. + public CVMetalBuffer? CreateBufferFromImage (CVImageBuffer imageBuffer) + { + IntPtr handle; + CVReturn res; + unsafe { + res = CVMetalBufferCacheCreateBufferFromImage (IntPtr.Zero, GetCheckedHandle (), imageBuffer.GetNonNullHandle (nameof (imageBuffer)), &handle); + } + if (res != CVReturn.Success) + throw new Exception ($"Could not create CVMetalBuffer, CVMetalBufferCacheCreateBufferFromImage returned: {res}"); + return Runtime.GetINativeObject (handle, true); + } + + [DllImport (Constants.CoreVideoLibrary)] + unsafe extern static /* CVReturn */ CVReturn CVMetalBufferCacheFlush ( + IntPtr /* CVMetalBufferCacheRef CV_NONNULL */ bufferCache, + CVOptionFlags options + ); + + /// Perform internal housekeeping/recycling operations. + /// This method must be called periodically. + public void Flush () + { + Flush (CVOptionFlags.None); + } + + /// Perform internal housekeeping/recycling operations. + /// Any flags for the flush operation. Currently unused, always pass . + /// This method must be called periodically. + public void Flush (CVOptionFlags options) + { + CVMetalBufferCacheFlush (GetCheckedHandle (), options); + } +#endif // !COREBUILD + } +} +#endif // !WATCH diff --git a/src/CoreVideo/CVPixelFormatDescription.cs b/src/CoreVideo/CVPixelFormatDescription.cs index ae3b58290b2..768a611cc1d 100644 --- a/src/CoreVideo/CVPixelFormatDescription.cs +++ b/src/CoreVideo/CVPixelFormatDescription.cs @@ -368,6 +368,7 @@ public CVFillExtendedPixelsCallBackDataStruct? FillExtendedPixelsCallbackStruct } } #endif + #endif // !COREBUILD } } diff --git a/src/CoreVideo/CVPixelFormatType.cs b/src/CoreVideo/CVPixelFormatType.cs index 04686b8e9b0..e65ef5e1e4d 100644 --- a/src/CoreVideo/CVPixelFormatType.cs +++ b/src/CoreVideo/CVPixelFormatType.cs @@ -63,6 +63,8 @@ public enum CVPixelFormatType : uint { CV48RGB = 0x62343872, CV32AlphaGray = 0x62333261, CV16Gray = 0x62313667, + /// 30-bit RGB, 10-bit big endian samples, 2 unused padding bits (at most significant end). + CV30RGB_r210 = 0x72323130, // 'r210' CV422YpCbCr8 = 0x32767579, CV4444YpCbCrA8 = 0x76343038, CV4444YpCbCrA8R = 0x72343038, @@ -122,6 +124,57 @@ public enum CVPixelFormatType : uint { CV64Rgba_DownscaledProResRaw = 0x62703634, // 'bp64' // iOS 14.2 CV64RgbaLE = 0x6C363472, + + /* Lossless pixel formats */ + + /// Lossless-compressed form of . + Lossless_32BGRA = ('&' << 24) + ('B' << 16) + ('G' << 8) + 'A', // '&BGA' + + /// Lossless-compressed form of . + /// No CVPlanarPixelBufferInfo struct. + Lossless_64RGBAHalf = ('&' << 24) + ('R' << 16) + ('h' << 8) + 'A', // '&RhA' + + /// Lossless-compressed form of . + /// No CVPlanarPixelBufferInfo struct. + Lossless_420YpCbCr8BiPlanarVideoRange = ('&' << 24) + ('8' << 16) + ('v' << 8) + '0', // '&8v0' + + /// Lossless-compressed form of . + /// No CVPlanarPixelBufferInfo struct. + Lossless_420YpCbCr8BiPlanarFullRange = ('&' << 24) + ('8' << 16) + ('f' << 8) + '0', // '&8f0' + + /// Lossless-compressed form of . + /// No CVPlanarPixelBufferInfo struct. Compressed-packed with bo padding bits between pixels. + Lossless_420YpCbCr10PackedBiPlanarVideoRange = ('&' << 24) + ('x' << 16) + ('v' << 8) + '0', // '&xv0' + + /// Lossless-compressed form of . + /// No CVPlanarPixelBufferInfo struct. Compressed-packed with bo padding bits between pixels. + Lossless_422YpCbCr10PackedBiPlanarVideoRange = ('&' << 24) + ('x' << 16) + ('v' << 8) + '2', // '&xv2' + + /// Lossless-compressed form of . + /// No CVPlanarPixelBufferInfo struct. Compressed-packed with bo padding bits between pixels. + Lossless_420YpCbCr10PackedBiPlanarFullRange = ('&' << 24) + ('x' << 16) + ('f' << 8) + '0', // '&xf0' + + /* Lossy pixel formats */ + + /// Lossy-compressed form of . + /// No CVPlanarPixelBufferInfo struct. + Lossy_32BGRA = ('-' << 24) + ('B' << 16) + ('G' << 8) + 'A', // '-BGA' + + /// Lossy-compressed form of . + /// No CVPlanarPixelBufferInfo struct. + Lossy_420YpCbCr8BiPlanarVideoRange = ('-' << 24) + ('8' << 16) + ('v' << 8) + '0', // '-8v0' + + /// Lossy-compressed form of . + /// No CVPlanarPixelBufferInfo struct. + Lossy_420YpCbCr8BiPlanarFullRange = ('-' << 24) + ('8' << 16) + ('f' << 8) + '0', // '-8f0' + + /// Lossy-compressed form of . + /// No CVPlanarPixelBufferInfo struct. Compressed-packed with bo padding bits between pixels. + Lossy_420YpCbCr10PackedBiPlanarVideoRange = ('-' << 24) + ('x' << 16) + ('v' << 8) + '0', // '-xv0' + + /// Lossy-compressed form of . + /// No CVPlanarPixelBufferInfo struct. Compressed-packed with bo padding bits between pixels. + Lossy_422YpCbCr10PackedBiPlanarVideoRange = ('-' << 24) + ('x' << 16) + ('v' << 8) + '2', // '-xv2' } #if !COREBUILD diff --git a/src/corevideo.cs b/src/corevideo.cs index 46b5f699b92..d39fcbf9881 100644 --- a/src/corevideo.cs +++ b/src/corevideo.cs @@ -284,6 +284,18 @@ interface CVImageBuffer : CVBuffer { [Watch (10, 2), TV (17, 2), Mac (14, 2), iOS (17, 2), MacCatalyst (17, 2)] [Field ("kCVImageBufferLogTransferFunction_AppleLog")] NSString LogTransferFunctionAppleLogKey { get; } + + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] + [Field ("kCVImageBufferSceneIlluminationKey")] + NSString SceneIlluminationKey { get; } + + [Mac (15, 0), NoiOS, NoTV, NoWatch, NoMacCatalyst] + [Field ("kCVImageBufferPostDecodeProcessingSequenceMetadataKey")] + NSString PostDecodeProcessingSequenceMetadataKey { get; } + + [Mac (15, 0), NoiOS, NoTV, NoWatch, NoMacCatalyst] + [Field ("kCVImageBufferPostDecodeProcessingFrameMetadataKey")] + NSString PostDecodeProcessingFrameMetadataKey { get; } } [MacCatalyst (13, 1)] @@ -571,6 +583,19 @@ public enum CVVersatileBayerPattern : uint { Bggr = 3, } + [NoWatch, TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] + [Static, Internal] + interface CVMetalBufferCacheAttributeKeys { + [Field ("kCVMetalBufferCacheMaximumBufferAgeKey")] + NSString MaximumBufferAgeKey { get; } + } + + [NoWatch] + [StrongDictionary ("CVMetalBufferCacheAttributeKeys")] + interface CVMetalBufferCacheAttributes { + double MaximumBufferAge { get; } + } + [Partial] interface CVPixelFormatKeys { [Field ("kCVPixelFormatName")] @@ -661,6 +686,10 @@ interface CVPixelFormatKeys { [Field ("kCVPixelFormatFillExtendedPixelsCallback")] NSString FillExtendedPixelsCallback { get; } + + [iOS (18, 0), Mac (15, 0), MacCatalyst (18, 0), TV (18, 0), Watch (11, 0)] + [Field ("kCVPixelFormatBitsPerComponent")] + NSString BitsPerComponent { get; } } [Partial] @@ -767,5 +796,8 @@ interface CVPixelFormatDescription { bool OpenGlesCompatibility { get; set; } NSData FillExtendedPixelsCallback { get; set; } + + [iOS (18, 0), Mac (15, 0), MacCatalyst (18, 0), TV (18, 0), Watch (11, 0)] + int BitsPerComponent { get; set; } } } diff --git a/src/frameworks.sources b/src/frameworks.sources index 7e3cf9ef4f7..7e3245a1adc 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -720,6 +720,8 @@ COREVIDEO_CORE_SOURCES = \ COREVIDEO_SOURCES = \ CoreVideo/CVDisplayLink.cs \ + CoreVideo/CVMetalBuffer.cs \ + CoreVideo/CVMetalBufferCache.cs \ CoreVideo/CVMetalTexture.cs \ CoreVideo/CVMetalTextureAttributes.cs \ CoreVideo/CVMetalTextureCache.cs \ diff --git a/tests/cecil-tests/Documentation.KnownFailures.txt b/tests/cecil-tests/Documentation.KnownFailures.txt index c097cc4ea90..fb2875a24f3 100644 --- a/tests/cecil-tests/Documentation.KnownFailures.txt +++ b/tests/cecil-tests/Documentation.KnownFailures.txt @@ -34270,6 +34270,10 @@ M:CoreVideo.CVImageBuffer.GetCodePoint(CoreVideo.CVImageBufferYCbCrMatrix) M:CoreVideo.CVImageBuffer.GetColorPrimariesOption(System.Int32) M:CoreVideo.CVImageBuffer.GetTransferFunctionOption(System.Int32) M:CoreVideo.CVImageBuffer.GetYCbCrMatrixOption(System.Int32) +M:CoreVideo.CVMetalBuffer.GetTypeId +M:CoreVideo.CVMetalBufferCache.GetTypeId +M:CoreVideo.CVMetalBufferCacheAttributes.#ctor +M:CoreVideo.CVMetalBufferCacheAttributes.#ctor(Foundation.NSDictionary) M:CoreVideo.CVMetalTexture.GetCleanTexCoords(System.Single[]@,System.Single[]@,System.Single[]@,System.Single[]@) M:CoreVideo.CVMetalTextureAttributes.#ctor M:CoreVideo.CVMetalTextureAttributes.#ctor(Foundation.NSDictionary) @@ -65927,9 +65931,12 @@ P:CoreVideo.CVImageBuffer.NonPropagatedAttachmentsKey P:CoreVideo.CVImageBuffer.PixelAspectRatioHorizontalSpacingKey P:CoreVideo.CVImageBuffer.PixelAspectRatioKey P:CoreVideo.CVImageBuffer.PixelAspectRatioVerticalSpacingKey +P:CoreVideo.CVImageBuffer.PostDecodeProcessingFrameMetadataKey +P:CoreVideo.CVImageBuffer.PostDecodeProcessingSequenceMetadataKey P:CoreVideo.CVImageBuffer.PreferredCleanApertureKey P:CoreVideo.CVImageBuffer.PropagatedAttachmentsKey P:CoreVideo.CVImageBuffer.RegionOfInterestKey +P:CoreVideo.CVImageBuffer.SceneIlluminationKey P:CoreVideo.CVImageBuffer.TimeScaleKey P:CoreVideo.CVImageBuffer.TimeValueKey P:CoreVideo.CVImageBuffer.TransferFunction_ITU_R_2020 @@ -65948,6 +65955,7 @@ P:CoreVideo.CVImageBuffer.YCbCrMatrix_ITU_R_709_2 P:CoreVideo.CVImageBuffer.YCbCrMatrix_P3_D65 P:CoreVideo.CVImageBuffer.YCbCrMatrix_SMPTE_240M_1995 P:CoreVideo.CVImageBuffer.YCbCrMatrixKey +P:CoreVideo.CVMetalBufferCacheAttributes.MaximumBufferAge P:CoreVideo.CVMetalTexture.IsFlipped P:CoreVideo.CVMetalTexture.Texture P:CoreVideo.CVMetalTextureAttributes.Usage @@ -66021,6 +66029,7 @@ P:CoreVideo.CVPixelFormatComponentRangeKeys.FullRange P:CoreVideo.CVPixelFormatComponentRangeKeys.VideoRange P:CoreVideo.CVPixelFormatComponentRangeKeys.WideRange P:CoreVideo.CVPixelFormatDescription.BitsPerBlock +P:CoreVideo.CVPixelFormatDescription.BitsPerComponent P:CoreVideo.CVPixelFormatDescription.BlackBlock P:CoreVideo.CVPixelFormatDescription.BlockHeight P:CoreVideo.CVPixelFormatDescription.BlockHorizontalAlignment @@ -66051,6 +66060,7 @@ P:CoreVideo.CVPixelFormatDescription.Planes P:CoreVideo.CVPixelFormatDescription.QDCompatibility P:CoreVideo.CVPixelFormatDescription.VerticalSubsampling P:CoreVideo.CVPixelFormatKeys.BitsPerBlock +P:CoreVideo.CVPixelFormatKeys.BitsPerComponent P:CoreVideo.CVPixelFormatKeys.BlackBlock P:CoreVideo.CVPixelFormatKeys.BlockHeight P:CoreVideo.CVPixelFormatKeys.BlockHorizontalAlignment @@ -82357,6 +82367,7 @@ T:CoreVideo.CVImageBufferAlphaChannelMode T:CoreVideo.CVImageBufferColorPrimaries T:CoreVideo.CVImageBufferTransferFunction T:CoreVideo.CVImageBufferYCbCrMatrix +T:CoreVideo.CVMetalBufferCacheAttributes T:CoreVideo.CVMetalTexture T:CoreVideo.CVMetalTextureAttributes T:CoreVideo.CVPixelBufferAttributes diff --git a/tests/introspection/ApiCMAttachmentTest.cs b/tests/introspection/ApiCMAttachmentTest.cs index b84c923955b..d6546bbf24f 100644 --- a/tests/introspection/ApiCMAttachmentTest.cs +++ b/tests/introspection/ApiCMAttachmentTest.cs @@ -221,6 +221,8 @@ protected virtual bool Skip (string nativeName) case "CVBuffer": // DOES support the API, but it has its own version and is already in the bindings, so no need ATM case "CVImageBuffer": // same as CVBuffer case "CVPixelBuffer": // same as CVBuffer + case "CVMetalBuffer": // same as CVBuffer + case "CVMetalBufferCache": // same as CVBuffer case "MTAudioProcessingTap": case "Protocol": case "MidiObject": // causes crash diff --git a/tests/monotouch-test/CoreVideo/CVMetalBufferCacheTest.cs b/tests/monotouch-test/CoreVideo/CVMetalBufferCacheTest.cs new file mode 100644 index 00000000000..d13352af1c8 --- /dev/null +++ b/tests/monotouch-test/CoreVideo/CVMetalBufferCacheTest.cs @@ -0,0 +1,93 @@ +// +// Unit tests for CVMetalBufferCache +// + +#if !__WATCHOS__ + +using System; + +using CoreVideo; +using Foundation; +using Metal; +using ObjCRuntime; + +using NUnit.Framework; + +namespace MonoTouchFixtures.CoreVideo { + + [TestFixture] + [Preserve (AllMembers = true)] + public class CVMetalBufferCacheTests { + + [Test] + public void GetTypeIdTest () + { + TestRuntime.AssertXcodeVersion (16, 0); + + Assert.AreNotEqual (0, CVMetalBufferCache.GetTypeId (), "GetTypeId"); + } + + [Test] + public void CtorTest_NSDictionary () + { + TestRuntime.AssertXcodeVersion (16, 0); + + using var device = MTLDevice.SystemDefault; + if (device is null) + Assert.Ignore ("Metal is not supported on this device."); + + using var cache = new CVMetalBufferCache (device, (NSDictionary) null); + Assert.IsNotNull (cache); + } + + [Test] + public void CtorTest_CVMetalBufferCacheAttributes () + { + TestRuntime.AssertXcodeVersion (16, 0); + + using var device = MTLDevice.SystemDefault; + if (device is null) + Assert.Ignore ("Metal is not supported on this device."); + + using var cache = new CVMetalBufferCache (device, (CVMetalBufferCacheAttributes) null); + Assert.IsNotNull (cache); + } + +#if !MONOMAC + [Test] + [TestCase (CVPixelFormatType.CV32BGRA)] + public void CreateBufferFromImageTest (CVPixelFormatType pft) + { + TestRuntime.AssertXcodeVersion (16, 0); + TestRuntime.AssertNotSimulator (); // metal api not supported in the simulator + + using var device = MTLDevice.SystemDefault; + if (device is null) + Assert.Ignore ("Metal is not supported on this device."); + + using var cache = new CVMetalBufferCache (device, (CVMetalBufferCacheAttributes) null); + var dict = new CVPixelBufferAttributes () { + MetalCompatibility = true, + }; + using var image = new CVPixelBuffer (320, 320, pft, dict); + using var buffer = cache.CreateBufferFromImage (image); + Assert.IsNotNull (buffer, "Buffer"); + } +#endif // !MONOMAC + + [Test] + public void FlushTest () + { + TestRuntime.AssertXcodeVersion (16, 0); + + using var device = MTLDevice.SystemDefault; + if (device is null) + Assert.Ignore ("Metal is not supported on this device."); + + using var cache = new CVMetalBufferCache (device, (CVMetalBufferCacheAttributes) null); + cache.Flush (); + cache.Flush (CVOptionFlags.None); + } + } +} +#endif diff --git a/tests/monotouch-test/CoreVideo/CVMetalBufferTest.cs b/tests/monotouch-test/CoreVideo/CVMetalBufferTest.cs new file mode 100644 index 00000000000..104d232fe54 --- /dev/null +++ b/tests/monotouch-test/CoreVideo/CVMetalBufferTest.cs @@ -0,0 +1,56 @@ +// +// Unit tests for CVMetalBuffer +// + +#if !__WATCHOS__ + +using System; +using System.Collections.Generic; + +using CoreVideo; +using Foundation; +using Metal; +using ObjCRuntime; + +using NUnit.Framework; + +namespace MonoTouchFixtures.CoreVideo { + + [TestFixture] + [Preserve (AllMembers = true)] + public class CVMetalBufferTests { + + [Test] + public void GetTypeIdTest () + { + TestRuntime.AssertXcodeVersion (16, 0); + + Assert.AreNotEqual (0, CVMetalBuffer.GetTypeId (), "GetTypeId"); + } + +#if !MONOMAC + [Test] + [TestCase (CVPixelFormatType.CV32BGRA)] + public void GetMetalBufferTest (CVPixelFormatType pft) + { + TestRuntime.AssertXcodeVersion (16, 0); + TestRuntime.AssertNotSimulator (); // metal api not supported in the simulator + + using var device = MTLDevice.SystemDefault; + if (device is null) + Assert.Ignore ("Metal is not supported on this device."); + + using var cache = new CVMetalBufferCache (device, (CVMetalBufferCacheAttributes) null); + var dict = new CVPixelBufferAttributes () { + MetalCompatibility = true, + }; + using var image = new CVPixelBuffer (320, 320, pft, dict); + using var buffer = cache.CreateBufferFromImage (image); + Assert.IsNotNull (buffer, "Buffer"); + using var metalBuffer = buffer.GetMetalBuffer (); + Assert.IsNotNull (metalBuffer, "GetMetalBuffer"); + } +#endif // !MONOMAC + } +} +#endif diff --git a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreVideo.todo b/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreVideo.todo deleted file mode 100644 index bc0c241ca5f..00000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreVideo.todo +++ /dev/null @@ -1,9 +0,0 @@ -!missing-field! kCVImageBufferSceneIlluminationKey not bound -!missing-field! kCVMetalBufferCacheMaximumBufferAgeKey not bound -!missing-field! kCVPixelFormatBitsPerComponent not bound -!missing-pinvoke! CVMetalBufferCacheCreate is not bound -!missing-pinvoke! CVMetalBufferCacheCreateBufferFromImage is not bound -!missing-pinvoke! CVMetalBufferCacheFlush is not bound -!missing-pinvoke! CVMetalBufferCacheGetTypeID is not bound -!missing-pinvoke! CVMetalBufferGetBuffer is not bound -!missing-pinvoke! CVMetalBufferGetTypeID is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreVideo.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreVideo.todo deleted file mode 100644 index bc0c241ca5f..00000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreVideo.todo +++ /dev/null @@ -1,9 +0,0 @@ -!missing-field! kCVImageBufferSceneIlluminationKey not bound -!missing-field! kCVMetalBufferCacheMaximumBufferAgeKey not bound -!missing-field! kCVPixelFormatBitsPerComponent not bound -!missing-pinvoke! CVMetalBufferCacheCreate is not bound -!missing-pinvoke! CVMetalBufferCacheCreateBufferFromImage is not bound -!missing-pinvoke! CVMetalBufferCacheFlush is not bound -!missing-pinvoke! CVMetalBufferCacheGetTypeID is not bound -!missing-pinvoke! CVMetalBufferGetBuffer is not bound -!missing-pinvoke! CVMetalBufferGetTypeID is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreVideo.todo b/tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreVideo.todo deleted file mode 100644 index 212322901fb..00000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreVideo.todo +++ /dev/null @@ -1,30 +0,0 @@ -!deprecated-attribute-missing! CVDisplayLinkCreateWithActiveCGDisplays missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkCreateWithCGDisplay missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkCreateWithCGDisplays missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkCreateWithOpenGLDisplayMask missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkGetActualOutputVideoRefreshPeriod missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkGetCurrentCGDisplay missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkGetCurrentTime missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkGetNominalOutputVideoRefreshPeriod missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkGetOutputVideoLatency missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkGetTypeID missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkIsRunning missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkRelease missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkRetain missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkSetCurrentCGDisplay missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkSetOutputCallback missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkStart missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkStop missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkTranslateTime missing a [Deprecated] attribute -!missing-field! kCVImageBufferSceneIlluminationKey not bound -!missing-field! kCVMetalBufferCacheMaximumBufferAgeKey not bound -!missing-field! kCVPixelFormatBitsPerComponent not bound -!missing-pinvoke! CVMetalBufferCacheCreate is not bound -!missing-pinvoke! CVMetalBufferCacheCreateBufferFromImage is not bound -!missing-pinvoke! CVMetalBufferCacheFlush is not bound -!missing-pinvoke! CVMetalBufferCacheGetTypeID is not bound -!missing-pinvoke! CVMetalBufferGetBuffer is not bound -!missing-pinvoke! CVMetalBufferGetTypeID is not bound -!missing-field! kCVImageBufferPostDecodeProcessingFrameMetadataKey not bound -!missing-field! kCVImageBufferPostDecodeProcessingSequenceMetadataKey not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreVideo.todo b/tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreVideo.todo deleted file mode 100644 index bc0c241ca5f..00000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreVideo.todo +++ /dev/null @@ -1,9 +0,0 @@ -!missing-field! kCVImageBufferSceneIlluminationKey not bound -!missing-field! kCVMetalBufferCacheMaximumBufferAgeKey not bound -!missing-field! kCVPixelFormatBitsPerComponent not bound -!missing-pinvoke! CVMetalBufferCacheCreate is not bound -!missing-pinvoke! CVMetalBufferCacheCreateBufferFromImage is not bound -!missing-pinvoke! CVMetalBufferCacheFlush is not bound -!missing-pinvoke! CVMetalBufferCacheGetTypeID is not bound -!missing-pinvoke! CVMetalBufferGetBuffer is not bound -!missing-pinvoke! CVMetalBufferGetTypeID is not bound diff --git a/tests/xtro-sharpie/iOS-CoreVideo.todo b/tests/xtro-sharpie/iOS-CoreVideo.todo deleted file mode 100644 index bc0c241ca5f..00000000000 --- a/tests/xtro-sharpie/iOS-CoreVideo.todo +++ /dev/null @@ -1,9 +0,0 @@ -!missing-field! kCVImageBufferSceneIlluminationKey not bound -!missing-field! kCVMetalBufferCacheMaximumBufferAgeKey not bound -!missing-field! kCVPixelFormatBitsPerComponent not bound -!missing-pinvoke! CVMetalBufferCacheCreate is not bound -!missing-pinvoke! CVMetalBufferCacheCreateBufferFromImage is not bound -!missing-pinvoke! CVMetalBufferCacheFlush is not bound -!missing-pinvoke! CVMetalBufferCacheGetTypeID is not bound -!missing-pinvoke! CVMetalBufferGetBuffer is not bound -!missing-pinvoke! CVMetalBufferGetTypeID is not bound diff --git a/tests/xtro-sharpie/macOS-CoreVideo.todo b/tests/xtro-sharpie/macOS-CoreVideo.todo deleted file mode 100644 index 212322901fb..00000000000 --- a/tests/xtro-sharpie/macOS-CoreVideo.todo +++ /dev/null @@ -1,30 +0,0 @@ -!deprecated-attribute-missing! CVDisplayLinkCreateWithActiveCGDisplays missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkCreateWithCGDisplay missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkCreateWithCGDisplays missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkCreateWithOpenGLDisplayMask missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkGetActualOutputVideoRefreshPeriod missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkGetCurrentCGDisplay missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkGetCurrentTime missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkGetNominalOutputVideoRefreshPeriod missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkGetOutputVideoLatency missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkGetTypeID missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkIsRunning missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkRelease missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkRetain missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkSetCurrentCGDisplay missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkSetOutputCallback missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkStart missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkStop missing a [Deprecated] attribute -!deprecated-attribute-missing! CVDisplayLinkTranslateTime missing a [Deprecated] attribute -!missing-field! kCVImageBufferSceneIlluminationKey not bound -!missing-field! kCVMetalBufferCacheMaximumBufferAgeKey not bound -!missing-field! kCVPixelFormatBitsPerComponent not bound -!missing-pinvoke! CVMetalBufferCacheCreate is not bound -!missing-pinvoke! CVMetalBufferCacheCreateBufferFromImage is not bound -!missing-pinvoke! CVMetalBufferCacheFlush is not bound -!missing-pinvoke! CVMetalBufferCacheGetTypeID is not bound -!missing-pinvoke! CVMetalBufferGetBuffer is not bound -!missing-pinvoke! CVMetalBufferGetTypeID is not bound -!missing-field! kCVImageBufferPostDecodeProcessingFrameMetadataKey not bound -!missing-field! kCVImageBufferPostDecodeProcessingSequenceMetadataKey not bound diff --git a/tests/xtro-sharpie/tvOS-CoreVideo.todo b/tests/xtro-sharpie/tvOS-CoreVideo.todo deleted file mode 100644 index bc0c241ca5f..00000000000 --- a/tests/xtro-sharpie/tvOS-CoreVideo.todo +++ /dev/null @@ -1,9 +0,0 @@ -!missing-field! kCVImageBufferSceneIlluminationKey not bound -!missing-field! kCVMetalBufferCacheMaximumBufferAgeKey not bound -!missing-field! kCVPixelFormatBitsPerComponent not bound -!missing-pinvoke! CVMetalBufferCacheCreate is not bound -!missing-pinvoke! CVMetalBufferCacheCreateBufferFromImage is not bound -!missing-pinvoke! CVMetalBufferCacheFlush is not bound -!missing-pinvoke! CVMetalBufferCacheGetTypeID is not bound -!missing-pinvoke! CVMetalBufferGetBuffer is not bound -!missing-pinvoke! CVMetalBufferGetTypeID is not bound diff --git a/tests/xtro-sharpie/watchOS-CoreVideo.todo b/tests/xtro-sharpie/watchOS-CoreVideo.todo deleted file mode 100644 index 5377f84e49a..00000000000 --- a/tests/xtro-sharpie/watchOS-CoreVideo.todo +++ /dev/null @@ -1,2 +0,0 @@ -!missing-field! kCVImageBufferSceneIlluminationKey not bound -!missing-field! kCVPixelFormatBitsPerComponent not bound