[metalperformanceshaders] Add nullability to (generated and manual) bindings (#15163)

* Go through the ignore files and confirm nullability

* enable nullability

* throw better exceptions

* use is null

* remove from maccatalyst todo

* use a gethandle

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
This commit is contained in:
TJ Lambert 2022-06-02 08:35:04 -05:00 коммит произвёл GitHub
Родитель f4380b65b2
Коммит a0ba164cca
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
21 изменённых файлов: 97 добавлений и 127 удалений

Просмотреть файл

@ -1,3 +1,5 @@
#nullable enable
using System; using System;
using ObjCRuntime; using ObjCRuntime;

Просмотреть файл

@ -1,3 +1,5 @@
#nullable enable
using System; using System;
using Metal; using Metal;
using Foundation; using Foundation;

Просмотреть файл

@ -1,3 +1,5 @@
#nullable enable
using System; using System;
using Metal; using Metal;
using Foundation; using Foundation;

Просмотреть файл

@ -1,3 +1,5 @@
#nullable enable
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

Просмотреть файл

@ -7,6 +7,8 @@
// Copyright 2019 Microsoft Corporation. // Copyright 2019 Microsoft Corporation.
// //
#nullable enable
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ObjCRuntime; using ObjCRuntime;
@ -32,8 +34,8 @@ namespace MetalPerformanceShaders {
// Using 'NSArray<MPSImage>' instead of `MPSImage[]` because image array 'Handle' matters. // Using 'NSArray<MPSImage>' instead of `MPSImage[]` because image array 'Handle' matters.
public static nuint IncrementReadCount (NSArray<MPSImage> imageBatch, nint amount) public static nuint IncrementReadCount (NSArray<MPSImage> imageBatch, nint amount)
{ {
if (imageBatch == null) if (imageBatch is null)
throw new ArgumentNullException (nameof (imageBatch)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (imageBatch));
return MPSImageBatchIncrementReadCount (imageBatch.Handle, amount); return MPSImageBatchIncrementReadCount (imageBatch.Handle, amount);
} }
@ -44,10 +46,10 @@ namespace MetalPerformanceShaders {
// Using 'NSArray<MPSImage>' instead of `MPSImage[]` because image array 'Handle' matters. // Using 'NSArray<MPSImage>' instead of `MPSImage[]` because image array 'Handle' matters.
public static void Synchronize (NSArray<MPSImage> imageBatch, IMTLCommandBuffer commandBuffer) public static void Synchronize (NSArray<MPSImage> imageBatch, IMTLCommandBuffer commandBuffer)
{ {
if (imageBatch == null) if (imageBatch is null)
throw new ArgumentNullException (nameof (imageBatch)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (imageBatch));
if (commandBuffer == null) if (commandBuffer is null)
throw new ArgumentNullException (nameof (commandBuffer)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (commandBuffer));
MPSImageBatchSynchronize (imageBatch.Handle, commandBuffer.Handle); MPSImageBatchSynchronize (imageBatch.Handle, commandBuffer.Handle);
} }
@ -78,8 +80,8 @@ namespace MetalPerformanceShaders {
#endif #endif
public static nuint GetResourceSize (NSArray<MPSImage> imageBatch) public static nuint GetResourceSize (NSArray<MPSImage> imageBatch)
{ {
if (imageBatch == null) if (imageBatch is null)
throw new ArgumentNullException (nameof (imageBatch)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (imageBatch));
return MPSImageBatchResourceSize (imageBatch.Handle); return MPSImageBatchResourceSize (imageBatch.Handle);
} }
@ -116,10 +118,10 @@ namespace MetalPerformanceShaders {
//[BindingImpl (BindingImplOptions.Optimizable)] //[BindingImpl (BindingImplOptions.Optimizable)]
//public static nint Iterate (NSArray<MPSImage> imageBatch, MPSImageBatchIterator iterator) //public static nint Iterate (NSArray<MPSImage> imageBatch, MPSImageBatchIterator iterator)
//{ //{
// if (imageBatch == null) // if (imageBatch is null)
// throw new ArgumentNullException (nameof (imageBatch)); // ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (imageBatch));
// if (iterator == null) // if (iterator is null)
// throw new ArgumentNullException (nameof (iterator)); // ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (iterator));
// unsafe { // unsafe {
// BlockLiteral* block_ptr_iterator; // BlockLiteral* block_ptr_iterator;
// BlockLiteral block_iterator; // BlockLiteral block_iterator;

Просмотреть файл

@ -1,5 +1,7 @@
// Copyright 2015 Xamarin Inc. All rights reserved. // Copyright 2015 Xamarin Inc. All rights reserved.
#nullable enable
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Foundation; using Foundation;

Просмотреть файл

@ -1,5 +1,7 @@
// Copyright 2015-2016 Xamarin Inc. All rights reserved. // Copyright 2015-2016 Xamarin Inc. All rights reserved.
#nullable enable
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using CoreGraphics; using CoreGraphics;
@ -17,7 +19,7 @@ namespace MetalPerformanceShaders {
public static bool Supports (IMTLDevice device) public static bool Supports (IMTLDevice device)
{ {
return MPSSupportsMTLDevice (device == null ? IntPtr.Zero : device.Handle); return MPSSupportsMTLDevice (device.GetHandle ());
} }
#if NET #if NET
@ -43,16 +45,16 @@ namespace MetalPerformanceShaders {
[Mac (10,15)] [Mac (10,15)]
[iOS (13,0)] [iOS (13,0)]
#endif #endif
public static IMTLDevice GetPreferredDevice (MPSDeviceOptions options) public static IMTLDevice? GetPreferredDevice (MPSDeviceOptions options)
{ {
var h = MPSGetPreferredDevice ((nuint)(ulong) options); var h = MPSGetPreferredDevice ((nuint)(ulong) options);
return Runtime.GetINativeObject<IMTLDevice> (h, false); return Runtime.GetINativeObject<IMTLDevice> (h, false);
} }
internal unsafe static float [] GetTransform (IntPtr transform) internal unsafe static float []? GetTransform (IntPtr transform)
{ {
var t = (float*) transform; var t = (float*) transform;
if (t == null) if (t is null)
return null; return null;
return new float [3] { t [0], t [1], t [2] }; return new float [3] { t [0], t [1], t [2] };
} }
@ -93,7 +95,7 @@ namespace MetalPerformanceShaders {
[Mac (10,14)] [Mac (10,14)]
[iOS (12,0)] [iOS (12,0)]
#endif #endif
public static void HintTemporaryMemoryHighWaterMark (IMTLCommandBuffer commandBuffer, nuint sizeInBytes) => MPSHintTemporaryMemoryHighWaterMark (commandBuffer == null ? IntPtr.Zero : commandBuffer.Handle, sizeInBytes); public static void HintTemporaryMemoryHighWaterMark (IMTLCommandBuffer commandBuffer, nuint sizeInBytes) => MPSHintTemporaryMemoryHighWaterMark (commandBuffer.GetHandle (), sizeInBytes);
#if NET #if NET
[SupportedOSPlatform ("tvos12.0")] [SupportedOSPlatform ("tvos12.0")]
@ -118,7 +120,7 @@ namespace MetalPerformanceShaders {
[Mac (10,14)] [Mac (10,14)]
[iOS (12,0)] [iOS (12,0)]
#endif #endif
public static void SetHeapCacheDuration (IMTLCommandBuffer commandBuffer, double seconds) => MPSSetHeapCacheDuration (commandBuffer == null ? IntPtr.Zero : commandBuffer.Handle, seconds); public static void SetHeapCacheDuration (IMTLCommandBuffer commandBuffer, double seconds) => MPSSetHeapCacheDuration (commandBuffer.GetHandle (), seconds);
#endif #endif
} }
@ -157,8 +159,8 @@ namespace MetalPerformanceShaders {
public MPSImageDilate (IMTLDevice device, nuint kernelWidth, nuint kernelHeight, float[] values) public MPSImageDilate (IMTLDevice device, nuint kernelWidth, nuint kernelHeight, float[] values)
: base (NSObjectFlag.Empty) : base (NSObjectFlag.Empty)
{ {
if (values == null) if (values is null)
throw new ArgumentNullException (nameof (values)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (values));
unsafe { unsafe {
fixed (float* ptr = values) fixed (float* ptr = values)
@ -188,7 +190,7 @@ namespace MetalPerformanceShaders {
} }
} }
public float[] Transform { public float[]? Transform {
get { return MPSKernel.GetTransform (_Transform); } get { return MPSKernel.GetTransform (_Transform); }
} }
} }
@ -205,7 +207,7 @@ namespace MetalPerformanceShaders {
} }
} }
public float[] Transform { public float[]? Transform {
get { return MPSKernel.GetTransform (_Transform); } get { return MPSKernel.GetTransform (_Transform); }
} }
} }
@ -222,7 +224,7 @@ namespace MetalPerformanceShaders {
} }
} }
public float[] Transform { public float[]? Transform {
get { return MPSKernel.GetTransform (_Transform); } get { return MPSKernel.GetTransform (_Transform); }
} }
} }
@ -239,7 +241,7 @@ namespace MetalPerformanceShaders {
} }
} }
public float[] Transform { public float[]? Transform {
get { return MPSKernel.GetTransform (_Transform); } get { return MPSKernel.GetTransform (_Transform); }
} }
} }
@ -256,7 +258,7 @@ namespace MetalPerformanceShaders {
} }
} }
public float[] Transform { public float[]? Transform {
get { return MPSKernel.GetTransform (_Transform); } get { return MPSKernel.GetTransform (_Transform); }
} }
} }
@ -267,8 +269,8 @@ namespace MetalPerformanceShaders {
public MPSImageSobel (IMTLDevice device, float[] transform) public MPSImageSobel (IMTLDevice device, float[] transform)
: base (NSObjectFlag.Empty) : base (NSObjectFlag.Empty)
{ {
if (transform == null) if (transform is null)
throw new ArgumentNullException (nameof (transform)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (transform));
unsafe { unsafe {
fixed (float* ptr = transform) fixed (float* ptr = transform)
@ -276,7 +278,7 @@ namespace MetalPerformanceShaders {
} }
} }
public float[] ColorTransform { public float[]? ColorTransform {
get { return MPSKernel.GetTransform (_ColorTransform); } get { return MPSKernel.GetTransform (_ColorTransform); }
} }
} }
@ -287,8 +289,8 @@ namespace MetalPerformanceShaders {
public MPSCnnConvolution (IMTLDevice device, MPSCnnConvolutionDescriptor convolutionDescriptor, float[] kernelWeights, float[] biasTerms, MPSCnnConvolutionFlags flags) public MPSCnnConvolution (IMTLDevice device, MPSCnnConvolutionDescriptor convolutionDescriptor, float[] kernelWeights, float[] biasTerms, MPSCnnConvolutionFlags flags)
: base (NSObjectFlag.Empty) : base (NSObjectFlag.Empty)
{ {
if (kernelWeights == null) if (kernelWeights is null)
throw new ArgumentNullException (nameof (kernelWeights)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (kernelWeights));
unsafe { unsafe {
fixed (float* kernelWeightsptr = kernelWeights) fixed (float* kernelWeightsptr = kernelWeights)
@ -319,8 +321,8 @@ namespace MetalPerformanceShaders {
public MPSCnnFullyConnected (IMTLDevice device, MPSCnnConvolutionDescriptor convolutionDescriptor, float[] kernelWeights, float[] biasTerms, MPSCnnConvolutionFlags flags) public MPSCnnFullyConnected (IMTLDevice device, MPSCnnConvolutionDescriptor convolutionDescriptor, float[] kernelWeights, float[] biasTerms, MPSCnnConvolutionFlags flags)
: base (NSObjectFlag.Empty) : base (NSObjectFlag.Empty)
{ {
if (kernelWeights == null) if (kernelWeights is null)
throw new ArgumentNullException (nameof (kernelWeights)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (kernelWeights));
unsafe { unsafe {
fixed (float* kernelWeightsptr = kernelWeights) fixed (float* kernelWeightsptr = kernelWeights)
@ -347,8 +349,8 @@ namespace MetalPerformanceShaders {
public MPSImagePyramid (IMTLDevice device, nuint kernelWidth, nuint kernelHeight, float[] kernelWeights) public MPSImagePyramid (IMTLDevice device, nuint kernelWidth, nuint kernelHeight, float[] kernelWeights)
: base (NSObjectFlag.Empty) : base (NSObjectFlag.Empty)
{ {
if (kernelWeights == null) if (kernelWeights is null)
throw new ArgumentNullException (nameof (kernelWeights)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (kernelWeights));
unsafe { unsafe {
fixed (float* ptr = kernelWeights) fixed (float* ptr = kernelWeights)
@ -363,8 +365,8 @@ namespace MetalPerformanceShaders {
public MPSImageGaussianPyramid (IMTLDevice device, nuint kernelWidth, nuint kernelHeight, float[] kernelWeights) public MPSImageGaussianPyramid (IMTLDevice device, nuint kernelWidth, nuint kernelHeight, float[] kernelWeights)
: base (NSObjectFlag.Empty) : base (NSObjectFlag.Empty)
{ {
if (kernelWeights == null) if (kernelWeights is null)
throw new ArgumentNullException (nameof (kernelWeights)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (kernelWeights));
unsafe { unsafe {
fixed (float* ptr = kernelWeights) fixed (float* ptr = kernelWeights)
@ -377,8 +379,8 @@ namespace MetalPerformanceShaders {
[DesignatedInitializer] [DesignatedInitializer]
public MPSImageLaplacianPyramid (IMTLDevice device, nuint kernelWidth, nuint kernelHeight, float[] kernelWeights) : base (NSObjectFlag.Empty) public MPSImageLaplacianPyramid (IMTLDevice device, nuint kernelWidth, nuint kernelHeight, float[] kernelWeights) : base (NSObjectFlag.Empty)
{ {
if (kernelWeights == null) if (kernelWeights is null)
throw new ArgumentNullException (nameof (kernelWeights)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (kernelWeights));
if ((nuint) kernelWeights.Length < kernelWidth * kernelHeight) if ((nuint) kernelWeights.Length < kernelWidth * kernelHeight)
throw new ArgumentException ($"'{nameof (kernelWeights)}' size must be at least '{nameof (kernelWidth)}' * '{nameof (kernelHeight)}'."); throw new ArgumentException ($"'{nameof (kernelWeights)}' size must be at least '{nameof (kernelWidth)}' * '{nameof (kernelHeight)}'.");
@ -393,8 +395,8 @@ namespace MetalPerformanceShaders {
[DesignatedInitializer] [DesignatedInitializer]
public MPSImageLaplacianPyramidSubtract (IMTLDevice device, nuint kernelWidth, nuint kernelHeight, float[] kernelWeights) : base (NSObjectFlag.Empty) public MPSImageLaplacianPyramidSubtract (IMTLDevice device, nuint kernelWidth, nuint kernelHeight, float[] kernelWeights) : base (NSObjectFlag.Empty)
{ {
if (kernelWeights == null) if (kernelWeights is null)
throw new ArgumentNullException (nameof (kernelWeights)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (kernelWeights));
if ((nuint) kernelWeights.Length < kernelWidth * kernelHeight) if ((nuint) kernelWeights.Length < kernelWidth * kernelHeight)
throw new ArgumentException ($"'{nameof (kernelWeights)}' size must be at least '{nameof (kernelWidth)}' * '{nameof (kernelHeight)}'."); throw new ArgumentException ($"'{nameof (kernelWeights)}' size must be at least '{nameof (kernelWidth)}' * '{nameof (kernelHeight)}'.");
@ -409,8 +411,8 @@ namespace MetalPerformanceShaders {
[DesignatedInitializer] [DesignatedInitializer]
public MPSImageLaplacianPyramidAdd (IMTLDevice device, nuint kernelWidth, nuint kernelHeight, float[] kernelWeights) : base (NSObjectFlag.Empty) public MPSImageLaplacianPyramidAdd (IMTLDevice device, nuint kernelWidth, nuint kernelHeight, float[] kernelWeights) : base (NSObjectFlag.Empty)
{ {
if (kernelWeights == null) if (kernelWeights is null)
throw new ArgumentNullException (nameof (kernelWeights)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (kernelWeights));
if ((nuint) kernelWeights.Length < kernelWidth * kernelHeight) if ((nuint) kernelWeights.Length < kernelWidth * kernelHeight)
throw new ArgumentException ($"'{nameof (kernelWeights)}' size must be at least '{nameof (kernelWidth)}' * '{nameof (kernelHeight)}'."); throw new ArgumentException ($"'{nameof (kernelWeights)}' size must be at least '{nameof (kernelWidth)}' * '{nameof (kernelHeight)}'.");
@ -476,7 +478,7 @@ namespace MetalPerformanceShaders {
[Mac (10,13,4)] [Mac (10,13,4)]
[iOS (11,3)] [iOS (11,3)]
#endif #endif
public static MPSCnnBinaryFullyConnectedNode Create (MPSNNImageNode sourceNode, IMPSCnnConvolutionDataSource weights, float [] outputBiasTerms, float [] outputScaleTerms, float [] inputBiasTerms, float [] inputScaleTerms, MPSCnnBinaryConvolutionType type, MPSCnnBinaryConvolutionFlags flags) public new static MPSCnnBinaryFullyConnectedNode Create (MPSNNImageNode sourceNode, IMPSCnnConvolutionDataSource weights, float [] outputBiasTerms, float [] outputScaleTerms, float [] inputBiasTerms, float [] inputScaleTerms, MPSCnnBinaryConvolutionType type, MPSCnnBinaryConvolutionFlags flags)
{ {
unsafe { unsafe {
fixed (void* outputBiasTermsHandle = outputBiasTerms) fixed (void* outputBiasTermsHandle = outputBiasTerms)

Просмотреть файл

@ -1,3 +1,5 @@
#nullable enable
using System; using System;
using Metal; using Metal;
using Foundation; using Foundation;

Просмотреть файл

@ -1,3 +1,5 @@
#nullable enable
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using CoreGraphics; using CoreGraphics;
@ -17,7 +19,7 @@ namespace MetalPerformanceShaders {
[Mac (10,15)] [Mac (10,15)]
[iOS (13,0)] [iOS (13,0)]
#endif #endif
public unsafe static MPSNNGraph Create (IMTLDevice device, MPSNNImageNode[] resultImages, bool[] resultsAreNeeded) public unsafe static MPSNNGraph? Create (IMTLDevice device, MPSNNImageNode[] resultImages, bool[] resultsAreNeeded)
{ {
fixed (void *resultsAreNeededHandle = resultsAreNeeded) fixed (void *resultsAreNeededHandle = resultsAreNeeded)
return Create (device, resultImages, (IntPtr) resultsAreNeededHandle); return Create (device, resultImages, (IntPtr) resultsAreNeededHandle);

Просмотреть файл

@ -7,6 +7,8 @@
// Copyright 2019 Microsoft Corporation. // Copyright 2019 Microsoft Corporation.
// //
#nullable enable
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ObjCRuntime; using ObjCRuntime;
@ -32,8 +34,8 @@ namespace MetalPerformanceShaders {
// Using 'NSArray<MPSState>' instead of `MPSState[]` because array 'Handle' matters. // Using 'NSArray<MPSState>' instead of `MPSState[]` because array 'Handle' matters.
public static nuint IncrementReadCount (NSArray<MPSState> stateBatch, nint amount) public static nuint IncrementReadCount (NSArray<MPSState> stateBatch, nint amount)
{ {
if (stateBatch == null) if (stateBatch is null)
throw new ArgumentNullException (nameof (stateBatch)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (stateBatch));
return MPSStateBatchIncrementReadCount (stateBatch.Handle, amount); return MPSStateBatchIncrementReadCount (stateBatch.Handle, amount);
} }
@ -44,10 +46,10 @@ namespace MetalPerformanceShaders {
// Using 'NSArray<MPSState>' instead of `MPSState[]` because array 'Handle' matters. // Using 'NSArray<MPSState>' instead of `MPSState[]` because array 'Handle' matters.
public static void Synchronize (NSArray<MPSState> stateBatch, IMTLCommandBuffer commandBuffer) public static void Synchronize (NSArray<MPSState> stateBatch, IMTLCommandBuffer commandBuffer)
{ {
if (stateBatch == null) if (stateBatch is null)
throw new ArgumentNullException (nameof (stateBatch)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (stateBatch));
if (commandBuffer == null) if (commandBuffer is null)
throw new ArgumentNullException (nameof (commandBuffer)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (commandBuffer));
MPSStateBatchSynchronize (stateBatch.Handle, commandBuffer.Handle); MPSStateBatchSynchronize (stateBatch.Handle, commandBuffer.Handle);
} }
@ -78,8 +80,8 @@ namespace MetalPerformanceShaders {
#endif #endif
public static nuint GetResourceSize (NSArray<MPSState> stateBatch) public static nuint GetResourceSize (NSArray<MPSState> stateBatch)
{ {
if (stateBatch == null) if (stateBatch is null)
throw new ArgumentNullException (nameof (stateBatch)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (stateBatch));
return MPSStateBatchResourceSize (stateBatch.Handle); return MPSStateBatchResourceSize (stateBatch.Handle);
} }

Просмотреть файл

@ -7,6 +7,8 @@
// Copyright 2019 Microsoft Corporation. // Copyright 2019 Microsoft Corporation.
// //
#nullable enable
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Foundation; using Foundation;
@ -15,21 +17,21 @@ using ObjCRuntime;
namespace MetalPerformanceShaders { namespace MetalPerformanceShaders {
public partial class MPSStateResourceList { public partial class MPSStateResourceList {
public static MPSStateResourceList Create (params MTLTextureDescriptor [] descriptors) public static MPSStateResourceList? Create (params MTLTextureDescriptor [] descriptors)
{ {
if (descriptors == null) if (descriptors is null)
throw new ArgumentNullException (nameof (descriptors)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (descriptors));
if (descriptors.Length > 10) if (descriptors.Length > 10)
throw new ArgumentException ("Only 10 parameters are currently supported."); throw new ArgumentException ("Only 10 parameters are currently supported.");
var arr = new IntPtr [10]; var arr = new IntPtr [10];
for (int i = 0; i < descriptors.Length; ++i) { for (int i = 0; i < descriptors.Length; ++i) {
if (descriptors [i] == null) if (descriptors [i] is null)
throw new ArgumentException ($"'{nameof (descriptors)}[{i}]' was null."); throw new ArgumentException ($"'{nameof (descriptors)}[{i}]' was null.");
arr [i] = descriptors [i].Handle; arr [i] = descriptors [i].Handle;
} }
MPSStateResourceList ret; MPSStateResourceList? ret;
// Learned the hard way about arm64's variadic arguments calling conventions are different... // Learned the hard way about arm64's variadic arguments calling conventions are different...
if (Runtime.IsARM64CallingConvention) if (Runtime.IsARM64CallingConvention)
ret = Runtime.GetNSObject<MPSStateResourceList> (IntPtr_objc_msgSend_IntPtrx3_FakeIntPtrx5_IntPtrx10 (class_ptr, Selector.GetHandle ("resourceListWithTextureDescriptors:"), arr [0], IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, arr [1], arr [2], arr [3], arr [4], arr [5], arr [6], arr [7], arr [8], arr [9], IntPtr.Zero)); ret = Runtime.GetNSObject<MPSStateResourceList> (IntPtr_objc_msgSend_IntPtrx3_FakeIntPtrx5_IntPtrx10 (class_ptr, Selector.GetHandle ("resourceListWithTextureDescriptors:"), arr [0], IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, arr [1], arr [2], arr [3], arr [4], arr [5], arr [6], arr [7], arr [8], arr [9], IntPtr.Zero));
@ -39,10 +41,10 @@ namespace MetalPerformanceShaders {
return ret; return ret;
} }
public static MPSStateResourceList Create (params nuint [] bufferSizes) public static MPSStateResourceList? Create (params nuint [] bufferSizes)
{ {
if (bufferSizes == null) if (bufferSizes is null)
throw new ArgumentNullException (nameof (bufferSizes)); ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (bufferSizes));
if (bufferSizes.Length > 10) if (bufferSizes.Length > 10)
throw new ArgumentException ("Only 10 parameters are currently supported."); throw new ArgumentException ("Only 10 parameters are currently supported.");
@ -52,7 +54,7 @@ namespace MetalPerformanceShaders {
Marshal.Copy ((IntPtr) ptr, arr, 0, bufferSizes.Length); Marshal.Copy ((IntPtr) ptr, arr, 0, bufferSizes.Length);
} }
MPSStateResourceList ret; MPSStateResourceList? ret;
// Learned the hard way about arm64's variadic arguments calling conventions are different... // Learned the hard way about arm64's variadic arguments calling conventions are different...
if (Runtime.IsARM64CallingConvention) if (Runtime.IsARM64CallingConvention)
ret = Runtime.GetNSObject<MPSStateResourceList> (IntPtr_objc_msgSend_IntPtrx3_FakeIntPtrx5_IntPtrx10 (class_ptr, Selector.GetHandle ("resourceListWithBufferSizes:"), arr [0], IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, arr [1], arr [2], arr [3], arr [4], arr [5], arr [6], arr [7], arr [8], arr [9], IntPtr.Zero)); ret = Runtime.GetNSObject<MPSStateResourceList> (IntPtr_objc_msgSend_IntPtrx3_FakeIntPtrx5_IntPtrx10 (class_ptr, Selector.GetHandle ("resourceListWithBufferSizes:"), arr [0], IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, arr [1], arr [2], arr [3], arr [4], arr [5], arr [6], arr [7], arr [8], arr [9], IntPtr.Zero));

Просмотреть файл

@ -5486,6 +5486,7 @@ namespace MetalPerformanceShaders {
void ReloadFromDataSources (); void ReloadFromDataSources ();
[Export ("encodeToCommandBuffer:sourceImages:sourceStates:intermediateImages:destinationStates:")] [Export ("encodeToCommandBuffer:sourceImages:sourceStates:intermediateImages:destinationStates:")]
[return: NullAllowed]
MPSImage EncodeToCommandBuffer (IMTLCommandBuffer commandBuffer, MPSImage[] sourceImages, [NullAllowed] MPSState[] sourceStates, [NullAllowed] NSMutableArray<MPSImage> intermediateImages, [NullAllowed] NSMutableArray<MPSState> destinationStates); MPSImage EncodeToCommandBuffer (IMTLCommandBuffer commandBuffer, MPSImage[] sourceImages, [NullAllowed] MPSState[] sourceStates, [NullAllowed] NSMutableArray<MPSImage> intermediateImages, [NullAllowed] NSMutableArray<MPSState> destinationStates);
[TV (11,3), Mac (10,13,4), iOS (11,3)] [TV (11,3), Mac (10,13,4), iOS (11,3)]
@ -5494,6 +5495,7 @@ namespace MetalPerformanceShaders {
NSArray<MPSImage> EncodeBatch (IMTLCommandBuffer commandBuffer, NSArray<MPSImage> [] sourceImages, [NullAllowed] NSArray<MPSState>[] sourceStates, [NullAllowed] NSMutableArray<NSArray<MPSImage>> intermediateImages, [NullAllowed] NSMutableArray<NSArray<MPSState>> destinationStates); NSArray<MPSImage> EncodeBatch (IMTLCommandBuffer commandBuffer, NSArray<MPSImage> [] sourceImages, [NullAllowed] NSArray<MPSState>[] sourceStates, [NullAllowed] NSMutableArray<NSArray<MPSImage>> intermediateImages, [NullAllowed] NSMutableArray<NSArray<MPSState>> destinationStates);
[Export ("encodeToCommandBuffer:sourceImages:")] [Export ("encodeToCommandBuffer:sourceImages:")]
[return: NullAllowed]
MPSImage EncodeToCommandBuffer (IMTLCommandBuffer commandBuffer, MPSImage[] sourceImages); MPSImage EncodeToCommandBuffer (IMTLCommandBuffer commandBuffer, MPSImage[] sourceImages);
[Export ("encodeBatchToCommandBuffer:sourceImages:sourceStates:")] [Export ("encodeBatchToCommandBuffer:sourceImages:sourceStates:")]

Просмотреть файл

@ -1,13 +1,7 @@
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramEqualization::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramSpecification::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageNormalizedHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!missing-enum! MPSCNNConvolutionWeightsLayout not bound !missing-enum! MPSCNNConvolutionWeightsLayout not bound
!missing-enum! MPSPolygonType not bound !missing-enum! MPSPolygonType not bound
!missing-enum! MPSRayMaskOperator not bound !missing-enum! MPSRayMaskOperator not bound
!missing-enum! MPSTemporalWeighting not bound !missing-enum! MPSTemporalWeighting not bound
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[])' is missing an [NullAllowed] on return type
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[],MetalPerformanceShaders.MPSState[],Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSImage>,Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSState>)' is missing an [NullAllowed] on return type
!missing-protocol! MPSCNNGroupNormalizationDataSource not bound !missing-protocol! MPSCNNGroupNormalizationDataSource not bound
!missing-protocol! MPSNNGramMatrixCallback not bound !missing-protocol! MPSNNGramMatrixCallback not bound
!missing-protocol! MPSSVGFTextureAllocator not bound !missing-protocol! MPSSVGFTextureAllocator not bound

Просмотреть файл

@ -40,3 +40,9 @@
# unused (came along some API yet to be bound) # unused (came along some API yet to be bound)
!unknown-simd-type-mapping! The Simd type vector_uchar16 does not have a mapping to a managed type. Please add one in SimdCheck.cs !unknown-simd-type-mapping! The Simd type vector_uchar16 does not have a mapping to a managed type. Please add one in SimdCheck.cs
# These four below just have a 'ref' in front of the parameters in question and are okay.
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramEqualization::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramSpecification::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageNormalizedHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1

Просмотреть файл

@ -1,10 +0,0 @@
# Initial result from new rule extra-null-allowed
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramEqualization::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramSpecification::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageNormalizedHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
# Initial result from new rule missing-null-allowed
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[])' is missing an [NullAllowed] on return type
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[],MetalPerformanceShaders.MPSState[],Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSImage>,Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSState>)' is missing an [NullAllowed] on return type

Просмотреть файл

@ -1,10 +0,0 @@
# Initial result from new rule extra-null-allowed
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramEqualization::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramSpecification::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageNormalizedHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
# Initial result from new rule missing-null-allowed
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[])' is missing an [NullAllowed] on return type
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[],MetalPerformanceShaders.MPSState[],Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSImage>,Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSState>)' is missing an [NullAllowed] on return type

Просмотреть файл

@ -1,10 +0,0 @@
# Initial result from new rule extra-null-allowed
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramEqualization::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramSpecification::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageNormalizedHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
# Initial result from new rule missing-null-allowed
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[])' is missing an [NullAllowed] on return type
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[],MetalPerformanceShaders.MPSState[],Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSImage>,Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSState>)' is missing an [NullAllowed] on return type

Просмотреть файл

@ -40,3 +40,9 @@
# unused (came along some API yet to be bound) # unused (came along some API yet to be bound)
!unknown-simd-type-mapping! The Simd type vector_uchar16 does not have a mapping to a managed type. Please add one in SimdCheck.cs !unknown-simd-type-mapping! The Simd type vector_uchar16 does not have a mapping to a managed type. Please add one in SimdCheck.cs
# These four below just have a 'ref' in front of the parameters in question and are okay.
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramEqualization::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramSpecification::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageNormalizedHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1

Просмотреть файл

@ -1,10 +0,0 @@
# Initial result from new rule extra-null-allowed
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramEqualization::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramSpecification::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageNormalizedHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
# Initial result from new rule missing-null-allowed
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[])' is missing an [NullAllowed] on return type
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[],MetalPerformanceShaders.MPSState[],Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSImage>,Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSState>)' is missing an [NullAllowed] on return type

Просмотреть файл

@ -1,10 +0,0 @@
# Initial result from new rule extra-null-allowed
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramEqualization::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramSpecification::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageNormalizedHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
# Initial result from new rule missing-null-allowed
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[])' is missing an [NullAllowed] on return type
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[],MetalPerformanceShaders.MPSState[],Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSImage>,Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSState>)' is missing an [NullAllowed] on return type

Просмотреть файл

@ -1,10 +0,0 @@
# Initial result from new rule extra-null-allowed
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramEqualization::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageHistogramSpecification::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
!extra-null-allowed! 'System.Void MetalPerformanceShaders.MPSImageNormalizedHistogram::.ctor(Metal.IMTLDevice,MetalPerformanceShaders.MPSImageHistogramInfo&)' has a extraneous [NullAllowed] on parameter #1
# Initial result from new rule missing-null-allowed
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[])' is missing an [NullAllowed] on return type
!missing-null-allowed! 'MetalPerformanceShaders.MPSImage MetalPerformanceShaders.MPSNNGraph::EncodeToCommandBuffer(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImage[],MetalPerformanceShaders.MPSState[],Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSImage>,Foundation.NSMutableArray`1<MetalPerformanceShaders.MPSState>)' is missing an [NullAllowed] on return type