-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information
1 parent
fd88272
commit ad1a3b7
Showing
19 changed files
with
637 additions
and
107 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
|
||
/// <summary>A CVPixelBuffer wrapped in a Metal based buffer.</summary> | ||
/// <remarks>This type is used to provide buffers to Metal.</remarks> | ||
#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<MTLBuffer> CV_NULLABLE */ IntPtr CVMetalBufferGetBuffer (IntPtr /* CVMetalBufferRef CV_NONNULL */ buffer); | ||
|
||
/// <summary>Retrieve the Metal MTLBuffer for the CVMetalBuffer.</summary> | ||
public IMTLBuffer? GetMetalBuffer () | ||
{ | ||
return Runtime.GetINativeObject<IMTLBuffer> (CVMetalBufferGetBuffer (GetCheckedHandle ()), owns: false); | ||
} | ||
|
||
#endif // !COREBUILD | ||
} | ||
} | ||
|
||
#endif // !WATCH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
|
||
/// <summary>A cache used to manage <see cref="CVMetalBuffer" /> instances.</summary> | ||
#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<MTLDevice> 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; | ||
} | ||
|
||
/// <summary>Create a new <see cref="CVMetalBufferCache" /> instance.</summary> | ||
/// <param name="device">The Metal device to create the <see cref="CVMetalBufferCache" /> instance for.</param> | ||
/// <param name="attributes">An optional dictionary of attributes to apply to the cache.</param> | ||
public CVMetalBufferCache (IMTLDevice device, NSDictionary? attributes) | ||
: base (Create (device, attributes), owns: true) | ||
{ | ||
} | ||
|
||
/// <summary>Create a new <see cref="CVMetalBufferCache" /> instance.</summary> | ||
/// <param name="device">The Metal device to create the <see cref="CVMetalBufferCache" /> instance for.</param> | ||
/// <param name="attributes">Optional attributes to apply to the cache.</param> | ||
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 | ||
); | ||
|
||
/// <summary>Create a <see cref="CVMetalBuffer" /> for an existing <see cref="CVImageBuffer" />.</summary> | ||
/// <param name="imageBuffer">The image buffer to create the <see cref="CVMetalBuffer" /> from.</param> | ||
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<CVMetalBuffer> (handle, true); | ||
} | ||
|
||
[DllImport (Constants.CoreVideoLibrary)] | ||
unsafe extern static /* CVReturn */ CVReturn CVMetalBufferCacheFlush ( | ||
IntPtr /* CVMetalBufferCacheRef CV_NONNULL */ bufferCache, | ||
CVOptionFlags options | ||
); | ||
|
||
/// <summary>Perform internal housekeeping/recycling operations.</summary> | ||
/// <remarks>This method must be called periodically.</remarks> | ||
public void Flush () | ||
{ | ||
Flush (CVOptionFlags.None); | ||
} | ||
|
||
/// <summary>Perform internal housekeeping/recycling operations.</summary> | ||
/// <param name="options">Any flags for the flush operation. Currently unused, always pass <see cref="CVOptionFlags.None" />.</param> | ||
/// <remarks>This method must be called periodically.</remarks> | ||
public void Flush (CVOptionFlags options) | ||
{ | ||
CVMetalBufferCacheFlush (GetCheckedHandle (), options); | ||
} | ||
#endif // !COREBUILD | ||
} | ||
} | ||
#endif // !WATCH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.