[Metal] New bindings from Xcode 9 betas (#2457)

This commit is contained in:
Timothy Risi 2017-09-05 04:45:03 -08:00 коммит произвёл Sebastien Pouliot
Родитель 483561c38f
Коммит c628320cda
20 изменённых файлов: 1330 добавлений и 65 удалений

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

@ -92,6 +92,21 @@ namespace XamCore.Metal {
}
}
[StructLayout (LayoutKind.Sequential)]
public struct MTLSamplePosition
{
public float X;
public float Y;
public MTLSamplePosition (float x, float y)
{
this.X = x;
this.Y = y;
}
}
public struct MTLClearColor {
public double Red, Green, Blue, Alpha;

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

@ -0,0 +1,13 @@
#if XAMCORE_2_0
using System;
namespace XamCore.Metal {
public static partial class MTLArgumentEncoder_Extensions {
public unsafe static void SetBuffers (this IMTLArgumentEncoder This, IMTLBuffer [] buffers, nint [] offsets, Foundation.NSRange range)
{
fixed (void* handle = offsets)
This.SetBuffers (buffers, (IntPtr)handle, range);
}
}
}
#endif

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

@ -79,5 +79,17 @@ namespace XamCore.Metal {
}
}
}
public partial class MTLPipelineBufferDescriptorArray {
public MTLPipelineBufferDescriptor this [nuint index]
{
get {
return GetObject (index);
}
set {
SetObject (value, index);
}
}
}
}
#endif

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

@ -4,19 +4,6 @@ using XamCore.ObjCRuntime;
namespace XamCore.Metal {
#if IOS || TVOS
public static partial class MTLRenderCommandEncoder_Extensions {
// Apple removed this in Xcode 8
[Introduced (PlatformName.iOS, 9,0)]
[Deprecated (PlatformName.iOS, 10,0)]
[Introduced (PlatformName.TvOS, 9,1)]
[Deprecated (PlatformName.TvOS, 10,0)]
public static void SetDepthClipMode (IMTLRenderCommandEncoder This, MTLDepthClipMode depthClipMode)
{
}
}
#endif
}
#endif

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

@ -16,6 +16,10 @@ using XamCore.Foundation;
using XamCore.ObjCRuntime;
namespace XamCore.Metal {
#if MONOMAC
[Advice ("The 'NSString' argument will match a property of 'MTLDeviceNotificationHandler'.")]
public delegate void MTLDeviceNotificationHandler (IMTLDevice device, NSString notifyName);
#endif
[iOS (8,0)][Mac (10,11)]
public static partial class MTLDevice {
@ -42,6 +46,62 @@ namespace XamCore.Metal {
return system_default;
}
}
#if MONOMAC
[Mac (10, 13, onlyOn64: true), NoiOS, NoWatch, NoTV]
[DllImport (Constants.MetalLibrary)]
unsafe static extern IntPtr MTLCopyAllDevicesWithObserver (ref IntPtr observer, void* handler);
[Mac (10, 13, onlyOn64: true), NoiOS, NoWatch, NoTV]
public static IMTLDevice [] GetAllDevices (ref NSObject observer, MTLDeviceNotificationHandler handler)
{
if (observer == null)
throw new ArgumentNullException ("observer");
IntPtr handle = observer.Handle;
unsafe
{
BlockLiteral* block_ptr_handler;
BlockLiteral block_handler;
block_handler = new BlockLiteral ();
block_ptr_handler = &block_handler;
block_handler.SetupBlock (static_notificationHandler, handler);
var rv = MTLCopyAllDevicesWithObserver (ref handle, (void*) block_ptr_handler);
var obj = NSArray.ArrayFromHandle<IMTLDevice> (rv);
if (handle != observer.Handle)
observer = Runtime.GetNSObject (handle);
return obj;
}
}
internal delegate void InnerNotification (IntPtr block, IntPtr device, IntPtr notifyName);
static readonly InnerNotification static_notificationHandler = TrampolineNotificationHandler;
[MonoPInvokeCallback (typeof (InnerNotification))]
public static unsafe void TrampolineNotificationHandler (IntPtr block, IntPtr device, IntPtr notifyName)
{
var descriptor = (BlockLiteral*) block;
var del = (MTLDeviceNotificationHandler) (descriptor->Target);
if (del != null)
del ((IMTLDevice) Runtime.GetNSObject (device), (XamCore.Foundation.NSString) Runtime.GetNSObject (notifyName));
}
[Mac (10, 13, onlyOn64: true), NoiOS, NoWatch, NoTV]
[DllImport (Constants.MetalLibrary)]
static extern void MTLRemoveDeviceObserver (IntPtr observer);
[Mac (10, 13, onlyOn64: true), NoiOS, NoWatch, NoTV]
public static void RemoveObserver (NSObject observer)
{
if (observer == null)
throw new ArgumentNullException ("observer");
MTLRemoveDeviceObserver (observer.Handle);
}
#endif
}
public static partial class MTLDevice_Extensions {
@ -61,11 +121,19 @@ namespace XamCore.Metal {
var handle = GCHandle.Alloc (data, GCHandleType.Pinned); // This requires a pinned GCHandle, since it's not possible to use unsafe code to get the address of a generic object.
try {
IntPtr ptr = handle.AddrOfPinnedObject ();
return This.CreateBufferNoCopy (ptr, (nuint)(data.Length * Marshal.SizeOf (typeof (T))) , options, deallocator);
return This.CreateBufferNoCopy (ptr, (nuint)(data.Length * Marshal.SizeOf (typeof (T))), options, deallocator);
} finally {
handle.Free ();
}
}
public unsafe static void GetDefaultSamplePositions (this IMTLDevice This, MTLSamplePosition [] positions, nuint count)
{
if (positions.Length < (nint)count)
throw new ArgumentException ("Length of 'positions' cannot be less than 'count'.");
fixed (void * handle = positions)
GetDefaultSamplePositions (This, (IntPtr)handle, count);
}
}
}
#endif

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

@ -79,6 +79,8 @@ namespace XamCore.Metal {
InvalidResource = 9,
[iOS (10,0), TV (10,0), NoWatch, NoMac]
Memoryless = 10,
[Mac (10,13), NoiOS, NoTV, NoWatch]
DeviceRemoved = 11,
}
[Native]
@ -93,6 +95,8 @@ namespace XamCore.Metal {
StoreAndMultisampleResolve,
[iOS (10,0), TV (10,0), NoWatch, Mac (10,12)]
Unknown,
[iOS (11,0), TV (11,0), NoWatch, Mac (10,13)]
CustomSampleDepthStore,
}
[Native]
@ -191,6 +195,29 @@ namespace XamCore.Metal {
Int1010102Normalized = 40,
UInt1010102Normalized = 41,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
UChar4NormalizedBgra = 42,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
UChar = 45,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
Char = 46,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
UCharNormalized = 47,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
CharNormalized = 48,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
UShort = 49,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
Short = 50,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
UShortNormalized = 51,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
ShortNormalized = 52,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
Half = 53,
}
[Mac (10,11)]
@ -246,6 +273,8 @@ namespace XamCore.Metal {
RGB10A2Uint = 91,
RG11B10Float = 92,
RGB9E5Float = 93,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
BGR10A2Unorm = 94,
RG32Uint = 103,
RG32Sint = 104,
RG32Float = 105,
@ -474,7 +503,7 @@ namespace XamCore.Metal {
[iOS (10,0), TV (10,0), NoWatch, NoMac]
StorageModeMemoryless = MTLStorageMode.Memoryless << 4,
[iOS (10,0), TV (10,0), NoWatch, NoMac]
[iOS (10,0), TV (10,0), NoWatch, Mac (10,13)]
HazardTrackingModeUntracked = 1 << 8,
}
@ -563,7 +592,11 @@ namespace XamCore.Metal {
Bool = 53,
Bool2 = 54,
Bool3 = 55,
Bool4 = 56
Bool4 = 56,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch] Texture = 58,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch] Sampler = 59,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch] Pointer = 60,
}
[Native]
@ -598,15 +631,31 @@ namespace XamCore.Metal {
iOS_GPUFamily2_v3 = 6,
[iOS (10,0), NoTV, NoWatch, NoMac]
iOS_GPUFamily3_v2 = 7,
[iOS (11,0), NoTV, NoWatch, NoMac]
iOS_GPUFamily1_v4 = 8,
[iOS (11,0), NoTV, NoWatch, NoMac]
iOS_GPUFamily2_v4 = 9,
[iOS (11,0), NoTV, NoWatch, NoMac]
iOS_GPUFamily3_v3 = 10,
[Mac (10,11)]
OSX_GPUFamily1_v1 = 10000,
[Mac (10,11), NoiOS, NoTV, NoWatch]
macOS_GPUFamily1_v1 = 10000,
[NoiOS, NoTV, NoWatch, Mac (10,12)]
OSX_GPUFamily1_v2 = 10001,
[Availability (Introduced = Platform.Mac_10_11, Deprecated = Platform.Mac_10_13, Message="Use 'macOS_GPUFamily1_v1' instead.")]
OSX_GPUFamily1_v1 = macOS_GPUFamily1_v1,
[NoiOS, NoTV, NoWatch, Mac (10,12)]
OSX_ReadWriteTextureTier2 = 10002,
[Mac (10,13), NoiOS, NoTV, NoWatch]
macOS_GPUFamily1_v2 = 10001,
[Availability (Introduced = Platform.Mac_10_12, Deprecated = Platform.Mac_10_13, Message="Use 'macOS_GPUFamily1_v2' instead.")]
OSX_GPUFamily1_v2 = macOS_GPUFamily1_v2,
[Mac (10,13), NoiOS, NoTV, NoWatch]
macOS_ReadWriteTextureTier2 = 10002,
[Availability (Introduced = Platform.Mac_10_12, Deprecated = Platform.Mac_10_13, Message="Use 'macOS_ReadWriteTextureTier2' instead.")]
OSX_ReadWriteTextureTier2 = macOS_ReadWriteTextureTier2,
[Mac (10,13), NoiOS, NoTV, NoWatch]
macOS_GPUFamily1_v3 = 10003,
[TV (9,0)]
TVOS_GPUFamily1_v1 = 30000,
@ -624,6 +673,8 @@ namespace XamCore.Metal {
v1_1 = (1 << 16) + 1,
[iOS (10,0), TV (10,0), NoWatch, Mac (10,12)]
v1_2 = (1 << 16) + 2,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
v2_0 = (2 << 16),
}
[iOS (9,0)][Mac (10,11)]
@ -764,7 +815,27 @@ namespace XamCore.Metal {
UInt3 = 38,
UInt4 = 39,
Int1010102Normalized = 40,
UInt1010102Normalized = 41
UInt1010102Normalized = 41,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
UChar4Normalized_Bgra = 42,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
UChar = 45,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
Char = 46,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
UCharNormalized = 47,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
CharNormalized = 48,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
UShort = 49,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
Short = 50,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
UShortNormalized = 51,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
ShortNormalized = 52,
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
Half = 53,
}
[iOS (10,0), TV (10,0), NoWatch, Mac (10,12)]
@ -787,5 +858,48 @@ namespace XamCore.Metal {
Vertex = (1 << 0),
Fragment = (1 << 1)
}
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[Native, Flags]
public enum MTLResourceUsage : nuint
{
Read = 1 << 0,
Write = 1 << 1,
Sample = 1 << 2,
}
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[Native]
public enum MTLMutability : nuint
{
Default = 0,
Mutable = 1,
Immutable = 2,
}
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[Native]
public enum MTLReadWriteTextureTier : nuint
{
None = 0,
One = 1,
Two = 2,
}
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[Native]
public enum MTLArgumentBuffersTier : nuint
{
One = 0,
Two = 1,
}
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[Native, Flags]
public enum MTLStoreActionOptions : nuint
{
None = 0,
CustomSamplePositions = 1 << 0,
}
}
#endif

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

@ -0,0 +1,26 @@
#if XAMCORE_2_0 && MONOMAC
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using XamCore.Foundation;
using XamCore.ObjCRuntime;
namespace XamCore.Metal {
public static class IMTLRenderCommandEncoder_Extensions {
[Mac (10,13, onlyOn64: true), NoiOS, NoTV, NoWatch]
public unsafe static void SetViewports (this IMTLRenderCommandEncoder This, MTLViewport [] viewports)
{
fixed (void* handle = viewports)
This.SetViewports ((IntPtr)handle, (nuint)(viewports?.Length ?? 0));
}
[Mac (10,13, onlyOn64: true), NoiOS, NoTV, NoWatch]
public unsafe static void SetScissorRects (this IMTLRenderCommandEncoder This, MTLScissorRect [] scissorRects)
{
fixed (void* handle = scissorRects)
This.SetScissorRects ((IntPtr)handle, (nuint)(scissorRects?.Length ?? 0));
}
}
}
#endif

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

@ -0,0 +1,21 @@
#if XAMCORE_2_0 && !COREBUILD
using System;
namespace XamCore.Metal {
public partial class MTLRenderPassDescriptor {
public unsafe void SetSamplePositions (MTLSamplePosition [] positions)
{
fixed (void* handle = positions)
SetSamplePositions ((IntPtr)handle, (nuint)(positions?.Length ?? 0));
}
public unsafe nuint GetSamplePositions (MTLSamplePosition [] positions)
{
fixed (void* handle = positions) {
nuint count = GetSamplePositions ((IntPtr)handle, (nuint)(positions?.Length ?? 0));
return count;
}
}
}
}
#endif

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

@ -964,9 +964,12 @@ METAL_CORE_SOURCES = \
Metal/Defs.cs \
METAL_SOURCES = \
Metal/MTLArgumentEncoder.cs \
Metal/MTLCompat.cs \
Metal/MTLDevice.cs \
Metal/MTLArrays.cs \
Metal/MTLRenderCommandEncoder.cs \
Metal/MTLRenderPassDescriptor.cs \
Metal/MTLVertexDescriptor.cs \
# MetalKit

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

@ -24,11 +24,12 @@ using XamCore.Foundation;
using XamCore.ObjCRuntime;
namespace XamCore.Metal {
delegate void MTLDeallocator (IntPtr pointer, nuint length);
delegate void MTLNewComputePipelineStateWithReflectionCompletionHandler (IMTLComputePipelineState computePipelineState, MTLComputePipelineReflection reflection, NSError error);
delegate void MTLDrawablePresentedHandler (IMTLDrawable drawable);
interface IMTLCommandEncoder {}
[iOS (8,0)][Mac (10,11, onlyOn64 : true)]
@ -77,13 +78,17 @@ namespace XamCore.Metal {
[Export ("isDepthTexture")]
bool IsDepthTexture { get; }
[iOS (10, 0), TV (10,0), NoWatch, NoMac]
[iOS (10, 0), TV (10,0), NoWatch, Mac (10,13, onlyOn64: true)]
[Export ("arrayLength")]
nuint ArrayLength { get; }
[Mac (10, 13), iOS (11,0), TV (11,0), NoWatch]
[NullAllowed, Export ("bufferPointerType")]
MTLPointerType BufferPointerType { get; }
}
[iOS (8,0)][Mac (10,11, onlyOn64 : true)]
[BaseType (typeof (NSObject))]
[BaseType (typeof (MTLType))]
interface MTLArrayType {
[Export ("arrayLength")]
nuint Length { get; }
@ -99,6 +104,18 @@ namespace XamCore.Metal {
[Export ("elementArrayType")]
MTLArrayType ElementArrayType ();
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[Export ("argumentIndexStride")]
nuint ArgumentIndexStride { get; }
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[NullAllowed, Export ("elementTextureReferenceType")]
MTLTextureReferenceType ElementTextureReferenceType { get; }
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[NullAllowed, Export ("elementPointerType")]
MTLPointerType ElementPointerType { get; }
}
[iOS (8,0)][Mac (10,11, onlyOn64 : true)]
@ -136,10 +153,11 @@ namespace XamCore.Metal {
#if MONOMAC
[Abstract, Export ("didModifyRange:")]
void DidModify (NSRange range);
#else
#endif
[Mac (10,13, onlyOn64: true)]
[return: NullAllowed]
[Abstract, Export ("newTextureWithDescriptor:offset:bytesPerRow:")]
IMTLTexture CreateTexture (MTLTextureDescriptor descriptor, nuint offset, nuint bytesPerRow);
#endif
[iOS (10,0), TV (10,0), NoWatch, Mac (10,12)]
#if XAMCORE_4_0
@ -239,6 +257,7 @@ namespace XamCore.Metal {
[Abstract]
#endif
[Export ("parallelRenderCommandEncoderWithDescriptor:")]
[return: NullAllowed]
IMTLParallelRenderCommandEncoder CreateParallelRenderCommandEncoder (MTLRenderPassDescriptor renderPassDescriptor);
#if XAMCORE_2_0
@ -293,6 +312,20 @@ namespace XamCore.Metal {
[iOS (10,3)][TV (10,2)][Mac (10,12,4, onlyOn64 : true)]
[Export ("GPUEndTime")]
double /* CFTimeInterval */ GpuEndTime { get; }
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract] // @required but we can't add abstract members in C# and keep binary compatibility
#endif
[Export ("pushDebugGroup:")]
void PushDebugGroup (string @string);
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract] // @required but we can't add abstract members in C# and keep binary compatibility
#endif
[Export ("popDebugGroup")]
void PopDebugGroup ();
}
interface IMTLCommandQueue {}
@ -309,12 +342,15 @@ namespace XamCore.Metal {
[Abstract, Export ("commandBuffer")]
[Autorelease]
[return: NullAllowed]
IMTLCommandBuffer CommandBuffer ();
[Abstract, Export ("commandBufferWithUnretainedReferences")]
[Autorelease]
[return: NullAllowed]
IMTLCommandBuffer CommandBufferWithUnretainedReferences ();
[Availability (Deprecated = Platform.iOS_11_0 | Platform.Mac_10_13, Message = "Use 'MTLCaptureScope' instead.")]
[Abstract, Export ("insertDebugCaptureBoundary")]
void InsertDebugCaptureBoundary ();
}
@ -397,19 +433,54 @@ namespace XamCore.Metal {
[Export ("setStageInRegion:")]
void SetStage (MTLRegion region);
[iOS (10,0), TV (10,0), NoWatch, NoMac]
[iOS (10,0), TV (10,0), NoWatch, Mac (10,13, onlyOn64: true)]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("updateFence:")]
void Update (IMTLFence fence);
[iOS (10,0), TV (10,0), NoWatch, NoMac]
[iOS (10,0), TV (10,0), NoWatch, Mac (10,13, onlyOn64: true)]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("waitForFence:")]
void Wait (IMTLFence fence);
[Mac (10,13, onlyOn64: true)]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("dispatchThreads:threadsPerThreadgroup:")]
void DispatchThreads (MTLSize threadsPerGrid, MTLSize threadsPerThreadgroup);
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("useResource:usage:")]
void UseResource (IMTLResource resource, MTLResourceUsage usage);
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("useResources:count:usage:")]
void UseResources (IMTLResource[] resources, nuint count, MTLResourceUsage usage);
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("useHeap:")]
void UseHeap (IMTLHeap heap);
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("useHeaps:count:")]
void UseHeaps (IMTLHeap[] heaps, nuint count);
}
[iOS (8,0)][Mac (10,11, onlyOn64 : true)]
@ -435,6 +506,20 @@ namespace XamCore.Metal {
[Abstract, Export ("threadExecutionWidth")]
nuint ThreadExecutionWidth { get; }
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[NullAllowed, Export ("label")]
string Label { get; }
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("staticThreadgroupMemoryLength")]
nuint StaticThreadgroupMemoryLength { get; }
}
interface IMTLBlitCommandEncoder {}
@ -485,14 +570,14 @@ namespace XamCore.Metal {
[Abstract, Export ("copyFromBuffer:sourceOffset:toBuffer:destinationOffset:size:")]
void CopyFromBuffer (IMTLBuffer sourceBuffer, nuint sourceOffset, IMTLBuffer destinationBuffer, nuint destinationOffset, nuint size);
[iOS (10,0), TV (10,0), NoWatch, NoMac]
[iOS (10,0), TV (10,0), NoWatch, Mac (10,13, onlyOn64: true)]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("updateFence:")]
void Update (IMTLFence fence);
[iOS (10,0), TV (10,0), NoWatch, NoMac]
[iOS (10,0), TV (10,0), NoWatch, Mac (10,13, onlyOn64: true)]
#if XAMCORE_4_0
[Abstract]
#endif
@ -502,7 +587,7 @@ namespace XamCore.Metal {
interface IMTLFence {}
[iOS (10,0), TV (10,0), NoWatch, NoMac]
[iOS (10,0), TV (10,0), NoWatch, Mac (10,13, onlyOn64: true)]
[Protocol] // From Apple Docs: Your app does not define classes that implement this protocol. Model is not needed
interface MTLFence
{
@ -562,49 +647,58 @@ namespace XamCore.Metal {
[Export ("depth24Stencil8PixelFormatSupported")]
bool Depth24Stencil8PixelFormatSupported { [Bind ("isDepth24Stencil8PixelFormatSupported")] get; }
[iOS (10,0), TV (10,0), NoWatch, NoMac]
[iOS (10,0), TV (10,0), NoWatch, Mac (10,13)]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("heapTextureSizeAndAlignWithDescriptor:")]
MTLSizeAndAlign GetHeapTextureSizeAndAlign (MTLTextureDescriptor desc);
[iOS (10,0), TV (10,0), NoWatch, NoMac]
[iOS (10,0), TV (10,0), NoWatch, Mac (10, 13)]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("heapBufferSizeAndAlignWithLength:options:")]
MTLSizeAndAlign GetHeapBufferSizeAndAlignWithLength (nuint length, MTLResourceOptions options);
[iOS (10,0), TV (10,0), NoWatch, NoMac]
[iOS (10,0), TV (10,0), NoWatch, Mac (10, 13)]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("newHeapWithDescriptor:")]
[return: NullAllowed]
IMTLHeap CreateHeap (MTLHeapDescriptor descriptor);
[Abstract, Export ("newCommandQueue")]
[return: NullAllowed]
IMTLCommandQueue CreateCommandQueue ();
[Abstract, Export ("newCommandQueueWithMaxCommandBufferCount:")]
[return: NullAllowed]
IMTLCommandQueue CreateCommandQueue (nuint maxCommandBufferCount);
[Abstract, Export ("newBufferWithLength:options:")]
[return: NullAllowed]
IMTLBuffer CreateBuffer (nuint length, MTLResourceOptions options);
[Abstract, Export ("newBufferWithBytes:length:options:")]
[return: NullAllowed]
IMTLBuffer CreateBuffer (IntPtr pointer, nuint length, MTLResourceOptions options);
[Abstract, Export ("newBufferWithBytesNoCopy:length:options:deallocator:")]
[return: NullAllowed]
IMTLBuffer CreateBufferNoCopy (IntPtr pointer, nuint length, MTLResourceOptions options, MTLDeallocator deallocator);
[Abstract, Export ("newDepthStencilStateWithDescriptor:")]
[return: NullAllowed]
IMTLDepthStencilState CreateDepthStencilState (MTLDepthStencilDescriptor descriptor);
[Abstract, Export ("newTextureWithDescriptor:")]
[return: NullAllowed]
IMTLTexture CreateTexture (MTLTextureDescriptor descriptor);
[Abstract, Export ("newSamplerStateWithDescriptor:")]
[return: NullAllowed]
IMTLSamplerState CreateSamplerState (MTLSamplerDescriptor descriptor);
[Abstract, Export ("newDefaultLibrary")]
@ -682,7 +776,7 @@ namespace XamCore.Metal {
[Export ("newComputePipelineStateWithDescriptor:options:completionHandler:")]
void CreateComputePipelineState (MTLComputePipelineDescriptor descriptor, MTLPipelineOption options, MTLNewComputePipelineStateWithReflectionCompletionHandler completionHandler);
[iOS (10, 0), TV (10,0), NoWatch, NoMac]
[iOS (10, 0), TV (10,0), NoWatch, Mac (10,13)]
#if XAMCORE_4_0
[Abstract]
#endif
@ -699,6 +793,92 @@ namespace XamCore.Metal {
#endif
[Export ("supportsTextureSampleCount:")]
bool SupportsTextureSampleCount (nuint sampleCount);
[Mac (10, 13), NoiOS, NoWatch, NoTV]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("removable")]
bool Removable { [Bind ("isRemovable")] get; }
[Mac (10, 13), NoiOS, NoWatch, NoTV]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("readWriteTextureSupport")]
MTLReadWriteTextureTier ReadWriteTextureSupport { get; }
[Mac (10, 13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("argumentBuffersSupport")]
MTLArgumentBuffersTier ArgumentBuffersSupport { get; }
[Mac (10, 13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("rasterOrderGroupsSupported")]
bool RasterOrderGroupsSupported { [Bind ("areRasterOrderGroupsSupported")] get; }
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("newLibraryWithURL:error:")]
[return: NullAllowed]
IMTLLibrary CreateLibrary (NSUrl url, [NullAllowed] out NSError error);
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("minimumLinearTextureAlignmentForPixelFormat:")]
nuint GetMinimumLinearTextureAlignment (MTLPixelFormat format);
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("maxThreadgroupMemoryLength")]
nuint MaxThreadgroupMemoryLength { get; }
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("programmableSamplePositionsSupported")]
bool ProgrammableSamplePositionsSupported { [Bind ("areProgrammableSamplePositionsSupported")] get; }
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("getDefaultSamplePositions:count:")]
void GetDefaultSamplePositions (IntPtr positions, nuint count);
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("newArgumentEncoderWithArguments:")]
[return: NullAllowed]
IMTLArgumentEncoder CreateArgumentEncoder (MTLArgumentDescriptor[] arguments);
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("registryID")]
ulong RegistryId { get; }
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("currentAllocatedSize")]
nuint CurrentAllocatedSize { get; }
}
interface IMTLDrawable {}
@ -824,6 +1004,7 @@ namespace XamCore.Metal {
bool FramebufferOnly { [Bind ("isFramebufferOnly")] get; }
[Abstract, Export ("newTextureViewWithPixelFormat:")]
[return: NullAllowed]
IMTLTexture CreateTextureView (MTLPixelFormat pixelFormat);
#if XAMCORE_4_0
@ -836,6 +1017,7 @@ namespace XamCore.Metal {
[Abstract]
#endif
[Export ("newTextureViewWithPixelFormat:textureType:levels:slices:")]
[return: NullAllowed]
IMTLTexture CreateTextureView (MTLPixelFormat pixelFormat, MTLTextureType textureType, NSRange levelRange, NSRange sliceRange);
#if XAMCORE_2_0
@ -861,6 +1043,21 @@ namespace XamCore.Metal {
#endif
[Export ("replaceRegion:mipmapLevel:withBytes:bytesPerRow:")]
void ReplaceRegion (MTLRegion region, nuint level, IntPtr pixelBytes, nuint bytesPerRow);
//FIXME: https://bugzilla.xamarin.com/show_bug.cgi?id=58899
// [Mac (10, 11), iOS (11,0), TV (11,0), NoWatch]
//#if XAMCORE_4_0
// [Abstract]
//#endif
//[NullAllowed, Export ("iosurface")]
//IOSurfaceRef* */ IOSurface { get; }
[Mac (10, 11), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("iosurfacePlane")]
nuint IOSurfacePlane { get; }
}
@ -966,6 +1163,10 @@ namespace XamCore.Metal {
// /SourceCache/AcceleratorKit/AcceleratorKit-14.9/Framework/MTLSampler.m:240: failed assertion `label must not be nil.'
[Export ("label")]
string Label { get; set; }
[Mac (10, 13), iOS (11,0), TV (11,0), NoWatch]
[Export ("supportArgumentBuffers")]
bool SupportArgumentBuffers { get; set; }
}
interface IMTLSamplerState {}
@ -1055,6 +1256,18 @@ namespace XamCore.Metal {
[iOS (10, 0), TV (10,0), NoWatch, Mac (10,12)]
[Export ("tessellationOutputWindingOrder", ArgumentSemantic.Assign)]
MTLWinding TessellationOutputWindingOrder { get; set; }
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[Export ("vertexBuffers")]
MTLPipelineBufferDescriptorArray VertexBuffers { get; }
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[Export ("fragmentBuffers")]
MTLPipelineBufferDescriptorArray FragmentBuffers { get; }
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[Export ("rasterSampleCount")]
nuint RasterSampleCount { get; set; }
}
[iOS (8,0)][Mac (10,11, onlyOn64 : true)]
@ -1304,6 +1517,20 @@ namespace XamCore.Metal {
#endif
[Export ("functionConstantsDictionary")]
NSDictionary<NSString, MTLFunctionConstant> FunctionConstants { get; }
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("newArgumentEncoderWithBufferIndex:")]
IMTLArgumentEncoder CreateArgumentEncoder (nuint bufferIndex);
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("newArgumentEncoderWithBufferIndex:reflection:")]
IMTLArgumentEncoder CreateArgumentEncoder (nuint bufferIndex, [NullAllowed] out MTLArgument reflection);
}
interface IMTLLibrary {}
@ -1406,10 +1633,22 @@ namespace XamCore.Metal {
[Export ("arrayType")]
MTLArrayType ArrayType ();
#endif
[Mac (10, 13), iOS (11,0), TV (11,0), NoWatch]
[Export ("argumentIndex")]
nuint ArgumentIndex { get; }
[Mac (10, 13), iOS (11,0), TV (11,0), NoWatch]
[NullAllowed, Export ("textureReferenceType")]
MTLTextureReferenceType TextureReferenceType { get; }
[Mac (10, 13), iOS (11,0), TV (11,0), NoWatch]
[NullAllowed, Export ("pointerType")]
MTLPointerType PointerType { get; }
}
[iOS (8,0)][Mac (10,11, onlyOn64 : true)]
[BaseType (typeof (NSObject))]
[BaseType (typeof (MTLType))]
interface MTLStructType {
[Export ("members")]
MTLStructMember [] Members { get; }
@ -1466,6 +1705,7 @@ namespace XamCore.Metal {
[Abstract]
[Export ("renderCommandEncoder")]
[Autorelease]
[return: NullAllowed]
IMTLRenderCommandEncoder CreateRenderCommandEncoder ();
[iOS (10,0), TV (10,0), NoWatch, Mac (10,12)]
@ -1488,6 +1728,27 @@ namespace XamCore.Metal {
#endif
[Export ("setStencilStoreAction:")]
void SetStencilStoreAction (MTLStoreAction storeAction);
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("setColorStoreActionOptions:atIndex:")]
void SetColorStoreActionOptions (MTLStoreActionOptions storeActionOptions, nuint colorAttachmentIndex);
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("setDepthStoreActionOptions:")]
void SetDepthStoreActionOptions (MTLStoreActionOptions storeActionOptions);
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("setStencilStoreActionOptions:")]
void SetStencilStoreActionOptions (MTLStoreActionOptions storeActionOptions);
}
interface IMTLRenderCommandEncoder {}
@ -1520,9 +1781,7 @@ namespace XamCore.Metal {
[Abstract, Export ("setCullMode:")]
void SetCullMode (MTLCullMode cullMode);
[Mac (10,11, onlyOn64 : true)]
[NoTV]
[NoiOS] // it was [iOS (9,0)] but now it's marked as not available on iOS in Xcode 8
[Mac (10,11, onlyOn64 : true), TV (11,0), iOS (11,0), NoWatch]
#if XAMCORE_4_0
// Apple added a new required member in iOS 9, but that breaks our binary compat, so we can't do that in our existing code.
[Abstract]
@ -1686,14 +1945,14 @@ namespace XamCore.Metal {
[Export ("textureBarrier")]
void TextureBarrier ();
[iOS (10,0), TV (10,0), NoWatch, NoMac]
[iOS (10,0), TV (10,0), NoWatch, Mac (10,13)]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("updateFence:afterStages:")]
void Update (IMTLFence fence, MTLRenderStages stages);
[iOS (10,0), TV (10,0), NoWatch, NoMac]
[iOS (10,0), TV (10,0), NoWatch, Mac (10,13)]
#if XAMCORE_4_0
[Abstract]
#endif
@ -1741,6 +2000,69 @@ namespace XamCore.Metal {
#endif
[Export ("drawIndexedPatches:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:indirectBuffer:indirectBufferOffset:")]
void DrawIndexedPatches (nuint numberOfPatchControlPoints, [NullAllowed] IMTLBuffer patchIndexBuffer, nuint patchIndexBufferOffset, IMTLBuffer controlPointIndexBuffer, nuint controlPointIndexBufferOffset, IMTLBuffer indirectBuffer, nuint indirectBufferOffset);
[Mac (10,13), NoiOS, NoTV, NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("setViewports:count:")]
void SetViewports (IntPtr viewports, nuint count);
[Mac (10,13), NoiOS, NoTV, NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("setScissorRects:count:")]
void SetScissorRects (IntPtr scissorRects, nuint count);
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("setColorStoreActionOptions:atIndex:")]
void SetColorStoreActionOptions (MTLStoreActionOptions storeActionOptions, nuint colorAttachmentIndex);
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("setDepthStoreActionOptions:")]
void SetDepthStoreActionOptions (MTLStoreActionOptions storeActionOptions);
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("setStencilStoreActionOptions:")]
void SetStencilStoreActionOptions (MTLStoreActionOptions storeActionOptions);
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("useResource:usage:")]
void UseResource (IMTLResource resource, MTLResourceUsage usage);
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("useResources:count:usage:")]
void UseResources (IMTLResource[] resources, nuint count, MTLResourceUsage usage);
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("useHeap:")]
void UseHeap (IMTLHeap heap);
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("useHeaps:count:")]
void UseHeaps (IMTLHeap[] heaps, nuint count);
}
[iOS (8,0)][Mac (10,11, onlyOn64 : true)]
@ -1828,6 +2150,10 @@ namespace XamCore.Metal {
[Export ("storeAction")]
MTLStoreAction StoreAction { get; set; }
[Mac (10, 13), iOS (11,0), TV (11,0), NoWatch]
[Export ("storeActionOptions", ArgumentSemantic.Assign)]
MTLStoreActionOptions StoreActionOptions { get; set; }
}
[iOS (8,0)][Mac (10,11, onlyOn64 : true)]
@ -1893,10 +2219,18 @@ namespace XamCore.Metal {
[NoTV]
[Export ("renderTargetArrayLength")]
nuint RenderTargetArrayLength { get; set; }
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[Export ("setSamplePositions:count:")]
unsafe void SetSamplePositions ([NullAllowed] IntPtr positions, nuint count);
[Mac (10,13), iOS (11,0), TV (11,0), NoWatch]
[Export ("getSamplePositions:count:")]
nuint GetSamplePositions ([NullAllowed] IntPtr positions, nuint count);
}
[iOS (10, 0), TV (10,0), NoWatch, NoMac]
[iOS (10, 0), TV (10,0), NoWatch, Mac (10,13, onlyOn64: true)]
[BaseType (typeof(NSObject))]
// note: type works only on devices, symbol is missing on the simulator
interface MTLHeapDescriptor : NSCopying
@ -1911,7 +2245,7 @@ namespace XamCore.Metal {
MTLCpuCacheMode CpuCacheMode { get; set; }
}
[iOS (10, 0), TV (10,0), NoWatch, NoMac]
[iOS (10, 0), TV (10,0), NoWatch, Mac (10,13, onlyOn64: true)]
[Protocol] // From Apple Docs: Your app does not define classes that implement this protocol. Model is not needed
interface MTLHeap
{
@ -1954,6 +2288,13 @@ namespace XamCore.Metal {
[Abstract]
[Export ("setPurgeableState:")]
MTLPurgeableState SetPurgeableState (MTLPurgeableState state);
[Mac (10, 13), iOS (11,0), TV (11,0), NoWatch]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("currentAllocatedSize")]
nuint CurrentAllocatedSize { get; }
}
interface IMTLResource {}
@ -1981,26 +2322,33 @@ namespace XamCore.Metal {
[Abstract, Export ("setPurgeableState:")]
MTLPurgeableState SetPurgeableState (MTLPurgeableState state);
[iOS (10, 0), TV (10,0), NoWatch, NoMac]
[iOS (10, 0), TV (10,0), NoWatch, Mac (10,13)]
#if XAMCORE_4_0
[Abstract]
#endif
[NullAllowed, Export ("heap")]
IMTLHeap Heap { get; }
[iOS (10, 0), TV (10,0), NoWatch, NoMac]
[iOS (10, 0), TV (10,0), NoWatch, Mac (10,13)]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("makeAliasable")]
void MakeAliasable ();
[iOS (10, 0), TV (10,0), NoWatch, NoMac]
[iOS (10, 0), TV (10,0), NoWatch, Mac (10,13)]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("isAliasable")]
bool IsAliasable { get; }
[iOS (10, 0), TV (10,0), NoWatch, Mac (10,13)]
#if XAMCORE_4_0
[Abstract]
#endif
[Export ("allocatedSize")]
nuint AllocatedSize { get; }
}
[iOS (9,0)][Mac (10,11, onlyOn64: true)]
@ -2025,6 +2373,10 @@ namespace XamCore.Metal {
[iOS (10, 0), TV (10,0), NoWatch, Mac (10,12)]
[NullAllowed, Export ("stageInputDescriptor", ArgumentSemantic.Copy)]
MTLStageInputOutputDescriptor StageInputDescriptor { get; set; }
[Mac (10, 13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
[Export ("buffers")]
MTLPipelineBufferDescriptorArray Buffers { get; }
}
[iOS (10,0), TV (10,0), NoWatch, Mac (10,12, onlyOn64 : true)]
@ -2050,5 +2402,244 @@ namespace XamCore.Metal {
[Export ("reset")]
void Reset ();
}
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
[BaseType (typeof(NSObject))]
interface MTLType
{
[Export ("dataType")]
MTLDataType DataType { get; }
}
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
[BaseType (typeof(NSObject))]
interface MTLPointerType
{
[Export ("elementType")]
MTLDataType ElementType { get; }
[Export ("access")]
MTLArgumentAccess Access { get; }
[Export ("alignment")]
nuint Alignment { get; }
[Export ("dataSize")]
nuint DataSize { get; }
[Export ("elementIsArgumentBuffer")]
bool ElementIsArgumentBuffer { get; }
[NullAllowed, Export ("elementStructType")]
MTLStructType ElementStructType { get; }
[NullAllowed, Export ("elementArrayType")]
MTLArrayType ElementArrayType { get; }
}
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
[BaseType (typeof(MTLType))]
interface MTLTextureReferenceType
{
[Export ("textureDataType")]
MTLDataType TextureDataType { get; }
[Export ("textureType")]
MTLTextureType TextureType { get; }
[Export ("access")]
MTLArgumentAccess Access { get; }
[Export ("isDepthTexture")]
bool IsDepthTexture { get; }
}
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
interface IMTLCaptureScope { }
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
[Protocol, Model]
[BaseType (typeof(NSObject))]
interface MTLCaptureScope
{
[Abstract]
[Export ("beginScope")]
void BeginScope ();
[Abstract]
[Export ("endScope")]
void EndScope ();
[Abstract]
[NullAllowed, Export ("label")]
string Label { get; set; }
[Abstract]
[Export ("device")]
IMTLDevice Device { get; }
[Abstract]
[NullAllowed, Export ("commandQueue")]
IMTLCommandQueue CommandQueue { get; }
}
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
interface MTLCaptureManager
{
[Static]
[Export ("sharedCaptureManager")]
MTLCaptureManager Shared { get; }
[Export ("newCaptureScopeWithDevice:")]
IMTLCaptureScope CreateNewCaptureScope (IMTLDevice device);
[Export ("newCaptureScopeWithCommandQueue:")]
IMTLCaptureScope CreateNewCaptureScope (IMTLCommandQueue commandQueue);
[Export ("startCaptureWithDevice:")]
void StartCapture (IMTLDevice device);
[Export ("startCaptureWithCommandQueue:")]
void StartCapture (IMTLCommandQueue commandQueue);
[Export ("startCaptureWithScope:")]
void StartCapture (IMTLCaptureScope captureScope);
[Export ("stopCapture")]
void StopCapture ();
[NullAllowed, Export ("defaultCaptureScope", ArgumentSemantic.Strong)]
IMTLCaptureScope DefaultCaptureScope { get; set; }
[Export ("isCapturing")]
bool IsCapturing { get; }
}
[Mac (10, 13, onlyOn64: true), NoiOS, NoTV, NoWatch]
interface MTLDeviceNotificationName {
[Field ("MTLDeviceWasAddedNotification")]
NSString DeviceWasAdded { get; set; }
[Field ("MTLDeviceRemovalRequestedNotification")]
NSString DeviceRemovalRequested { get; set; }
[Field ("MTLDeviceWasRemovedNotification")]
NSString MTLDeviceWasRemoved { get; set; }
}
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
[BaseType (typeof(NSObject))]
interface MTLPipelineBufferDescriptor : NSCopying
{
[Export ("mutability", ArgumentSemantic.Assign)]
MTLMutability Mutability { get; set; }
}
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
[BaseType (typeof(NSObject))]
interface MTLPipelineBufferDescriptorArray
{
[Internal]
[Export ("objectAtIndexedSubscript:")]
MTLPipelineBufferDescriptor GetObject (nuint bufferIndex);
[Internal]
[Export ("setObject:atIndexedSubscript:")]
void SetObject ([NullAllowed] MTLPipelineBufferDescriptor buffer, nuint bufferIndex);
}
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
[BaseType (typeof(NSObject))]
interface MTLArgumentDescriptor : NSCopying
{
[Static]
[Export ("argumentDescriptor")]
MTLArgumentDescriptor ArgumentDescriptor { get; }
[Export ("dataType", ArgumentSemantic.Assign)]
MTLDataType DataType { get; set; }
[Export ("index")]
nuint Index { get; set; }
[Export ("arrayLength")]
nuint ArrayLength { get; set; }
[Export ("access", ArgumentSemantic.Assign)]
MTLArgumentAccess Access { get; set; }
[Export ("textureType", ArgumentSemantic.Assign)]
MTLTextureType TextureType { get; set; }
[Export ("constantBlockAlignment")]
nuint ConstantBlockAlignment { get; set; }
}
interface IMTLArgumentEncoder { }
[Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0), NoWatch]
[Protocol]
interface MTLArgumentEncoder
{
[Abstract]
[Export ("device")]
IMTLDevice Device { get; }
[Abstract]
[NullAllowed, Export ("label")]
string Label { get; set; }
[Abstract]
[Export ("encodedLength")]
nuint EncodedLength { get; }
[Abstract]
[Export ("alignment")]
nuint Alignment { get; }
[Abstract]
[Export ("setArgumentBuffer:offset:")]
void SetArgumentBuffer (IMTLBuffer argumentBuffer, nuint offset);
[Abstract]
[Export ("setArgumentBuffer:startOffset:arrayElement:")]
void SetArgumentBuffer ([NullAllowed] IMTLBuffer argumentBuffer, nuint startOffset, nuint arrayElement);
[Abstract]
[Export ("setBuffer:offset:atIndex:")]
void SetBuffer ([NullAllowed] IMTLBuffer buffer, nuint offset, nuint index);
[Abstract]
[Export ("setBuffers:offsets:withRange:")]
void SetBuffers (IMTLBuffer[] buffers, IntPtr offsets, NSRange range);
[Abstract]
[Export ("setTexture:atIndex:")]
void SetTexture ([NullAllowed] IMTLTexture texture, nuint index);
[Abstract]
[Export ("setTextures:withRange:")]
void SetTextures (IMTLTexture[] textures, NSRange range);
[Abstract]
[Export ("setSamplerState:atIndex:")]
void SetSamplerState ([NullAllowed] IMTLSamplerState sampler, nuint index);
[Abstract]
[Export ("setSamplerStates:withRange:")]
void SetSamplerStates (IMTLSamplerState[] samplers, NSRange range);
[Abstract]
[Export ("constantDataAtIndex:")]
IntPtr GetConstantData (nuint index);
[Abstract]
[Export ("newArgumentEncoderForBufferAtIndex:")]
[return: NullAllowed]
IMTLArgumentEncoder CreateArgumentEncoder (nuint index);
}
}
#endif

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

@ -163,6 +163,12 @@ namespace Introspection {
return !TestRuntime.CheckXcodeVersion (9, 0);
}
break;
#if !MONOMAC
case "MTLCaptureManager":
if (Runtime.Arch == Arch.SIMULATOR)
return true;
break;
#endif
}
#endif
// This ctors needs to be manually bound
@ -343,6 +349,66 @@ namespace Introspection {
return true;
}
break;
case "MTLArgumentDescriptor":
switch (selectorName) {
case "access":
case "setAccess:":
case "arrayLength":
case "setArrayLength:":
case "constantBlockAlignment":
case "setConstantBlockAlignment:":
case "dataType":
case "setDataType:":
case "index":
case "setIndex:":
case "textureType":
case "setTextureType:":
return true;
}
break;
case "MTLHeapDescriptor":
switch (selectorName) {
case "cpuCacheMode":
case "setCpuCacheMode:":
case "size":
case "setSize:":
case "storageMode":
case "setStorageMode:":
return true;
}
break;
case "MTLPipelineBufferDescriptor":
switch (selectorName) {
case "mutability":
case "setMutability:":
return true;
}
break;
case "MTLPointerType":
switch (selectorName) {
case "access":
case "alignment":
case "dataSize":
case "elementIsArgumentBuffer":
case "elementType":
return true;
}
break;
case "MTLTextureReferenceType":
switch (selectorName) {
case "access":
case "isDepthTexture":
case "textureDataType":
case "textureType":
return true;
}
break;
case "MTLType":
switch (selectorName) {
case "dataType":
return true;
}
break;
case "AVPlayerLooper": // This API got introduced in Xcode 8.0 binding but is not currently present nor in Xcode 8.3 or Xcode 9.0 needs research
switch (selectorName) {
case "isLoopingEnabled":

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

@ -104,6 +104,7 @@ namespace Introspection
"Bancaires", // french
"Bary",
"Batc",
"Bgra", // acrnym for Blue, Green, Red, Alpha
"Bim",
"Biquad",
"Bitangent",

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

@ -16,16 +16,33 @@ namespace MonoTouchFixtures.Metal {
[TestFixture]
public class HeapDescriptorTest {
MTLHeapDescriptor hd = null;
[Test]
public void Properties ()
[SetUp]
public void SetUp ()
{
#if !MONOMAC
TestRuntime.AssertXcodeVersion (8, 0);
if (Runtime.Arch == Arch.SIMULATOR)
Assert.Ignore ("Type is missing on the simulator");
#else
TestRuntime.AssertXcodeVersion (9, 0);
#endif
hd = new MTLHeapDescriptor ();
}
using (var hd = new MTLHeapDescriptor ()) {
[TearDown]
public void TearDown ()
{
if (hd != null)
hd.Dispose ();
hd = null;
}
[Test]
public void Properties ()
{
Assert.That (hd.CpuCacheMode, Is.EqualTo (MTLCpuCacheMode.DefaultCache), "CpuCacheMode");
hd.CpuCacheMode = MTLCpuCacheMode.WriteCombined;
Assert.That (hd.StorageMode, Is.EqualTo (MTLStorageMode.Private), "StorageMode");
@ -42,6 +59,32 @@ namespace MonoTouchFixtures.Metal {
Assert.That (hd2.Handle, Is.Not.EqualTo (hd.Handle), "Handle");
}
}
[Test]
public void GetSetCpuCacheModeTest ()
{
TestRuntime.AssertXcodeVersion (9, 0);
hd.CpuCacheMode = MTLCpuCacheMode.WriteCombined;
Assert.AreEqual (MTLCpuCacheMode.WriteCombined, hd.CpuCacheMode);
}
[Test]
public void GetSetSizeTest ()
{
TestRuntime.AssertXcodeVersion (9, 0);
hd.Size = 2;
Assert.AreEqual (2, hd.Size);
}
[Test]
public void GetSetStorageModeTest ()
{
TestRuntime.AssertXcodeVersion (9, 0);
hd.StorageMode = MTLStorageMode.Private;
Assert.AreEqual (MTLStorageMode.Private, hd.StorageMode);
}
}
}

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

@ -0,0 +1,78 @@
#if !__WATCHOS__
using System;
#if XAMCORE_2_0
using Metal;
#else
using MonoTouch.Metal;
#endif
using NUnit.Framework;
namespace MonoTouchFixtures.Metal {
[TestFixture]
public class MTLArgumentDescriptorTest {
MTLArgumentDescriptor descriptor = null;
[SetUp]
public void SetUp ()
{
TestRuntime.AssertXcodeVersion (9, 0);
descriptor = new MTLArgumentDescriptor ();
}
[TearDown]
public void TearDown ()
{
if (descriptor != null)
descriptor.Dispose ();
descriptor = null;
}
[Test]
public void GetSetAccessTest ()
{
descriptor.Access = MTLArgumentAccess.ReadWrite;
Assert.AreEqual (MTLArgumentAccess.ReadWrite, descriptor.Access);
}
[Test]
public void GetSetArrayLengthTest ()
{
descriptor.ArrayLength = 1;
Assert.AreEqual (1, descriptor.ArrayLength);
}
[Test]
public void GetSetConstantBlockAlignmentTest ()
{
descriptor.ConstantBlockAlignment = 1;
Assert.AreEqual (1, descriptor.ConstantBlockAlignment);
}
[Test]
public void GetSetDataTypeTest ()
{
descriptor.DataType = MTLDataType.Half4;
Assert.AreEqual (MTLDataType.Half4, descriptor.DataType);
}
[Test]
public void GetSetIndexTest ()
{
descriptor.Index = 1;
Assert.AreEqual (1, descriptor.Index);
}
[Test]
public void GetSetTextureTypeTest ()
{
descriptor.TextureType = MTLTextureType.k2DArray;
Assert.AreEqual (MTLTextureType.k2DArray, descriptor.TextureType);
}
}
}
#endif // !__WATCHOS__

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

@ -0,0 +1,36 @@
#if MONOMAC
using System;
using Foundation;
#if XAMCORE_2_0
using Metal;
#else
using MonoTouch.Metal;
#endif
using NUnit.Framework;
namespace MonoTouchFixtures.Metal {
public class MTLDeviceTests {
[SetUp]
public void Setup ()
{
TestRuntime.AssertXcodeVersion (9, 0);
}
[Test]
public void GetAllDevicesTest ()
{
NSObject refObj = new NSObject();
var devices = MTLDevice.GetAllDevices(ref refObj, (IMTLDevice device, NSString notifyName) => { });
Assert.That (devices, Is.Not.Empty, "MTLDevice.GetAllDevices");
Assert.DoesNotThrow (() => {
MTLDevice.RemoveObserver (refObj);
});
}
}
}
#endif

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

@ -0,0 +1,43 @@
#if !__WATCHOS__
using System;
#if XAMCORE_2_0
using Metal;
#else
using MonoTouch.Metal;
#endif
using NUnit.Framework;
namespace MonoTouchFixtures.Metal {
[TestFixture]
public class MTLPipelineBufferDescriptorTest {
MTLPipelineBufferDescriptor descriptor = null;
[SetUp]
public void SetUp ()
{
TestRuntime.AssertXcodeVersion (9, 0);
descriptor = new MTLPipelineBufferDescriptor ();
}
[TearDown]
public void TearDown ()
{
if (descriptor != null)
descriptor.Dispose ();
descriptor = null;
}
[Test]
public void GetSetMutabilityTest ()
{
descriptor.Mutability = MTLMutability.Immutable;
Assert.AreEqual (MTLMutability.Immutable, descriptor.Mutability);
}
}
}
#endif // !__WATCHOS__

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

@ -0,0 +1,66 @@
#if !__WATCHOS__
using System;
#if XAMCORE_2_0
using Metal;
#else
using MonoTouch.Metal;
#endif
using NUnit.Framework;
namespace MonoTouchFixtures.Metal {
[TestFixture]
public class MTLPointerTypeTests {
MTLPointerType ptrType = null;
[SetUp]
public void SetUp ()
{
TestRuntime.AssertXcodeVersion (9, 0);
ptrType = new MTLPointerType ();
}
[TearDown]
public void TearDown ()
{
if (ptrType != null)
ptrType.Dispose ();
ptrType = null;
}
[Test]
public void GetAccessTest ()
{
Assert.AreEqual (MTLArgumentAccess.ReadOnly, ptrType.Access);
}
[Test]
public void GetAlignmentTest ()
{
Assert.AreEqual (0, ptrType.Alignment);
}
[Test]
public void GetDataSizeTest ()
{
Assert.AreEqual (0, ptrType.DataSize);
}
[Test]
public void GetElementIsArgumentBufferTest ()
{
Assert.False (ptrType.ElementIsArgumentBuffer);
}
[Test]
public void GetElementTypeTest ()
{
Assert.AreEqual (MTLDataType.None, ptrType.ElementType);
}
}
}
#endif // !__WATCHOS__

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

@ -0,0 +1,60 @@
#if !__WATCHOS__
using System;
#if XAMCORE_2_0
using Metal;
#else
using MonoTouch.Metal;
#endif
using NUnit.Framework;
namespace MonoTouchFixtures.Metal {
[TestFixture]
public class MTLTextureReferenceTypeTests {
MTLTextureReferenceType reference = null;
[SetUp]
public void SetUp ()
{
TestRuntime.AssertXcodeVersion (9, 0);
reference = new MTLTextureReferenceType ();
}
[TearDown]
public void TearDown ()
{
if (reference != null)
reference.Dispose ();
reference = null;
}
[Test]
public void GetAccessTest ()
{
Assert.AreEqual (MTLArgumentAccess.ReadOnly, reference.Access);
}
[Test]
public void GetIsDepthTextureTest ()
{
Assert.False (reference.IsDepthTexture);
}
[Test]
public void GetTextureDataType ()
{
Assert.AreEqual (MTLDataType.None, reference.TextureDataType);
}
[Test]
public void GetTextureType ()
{
Assert.AreEqual (MTLTextureType.k1D, reference.TextureType);
}
}
}
#endif // !__WATCHOS__

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

@ -656,6 +656,10 @@
<Compile Include="HomeKit\HMSignificantTimeEventTest.cs" />
<Compile Include="UIKit\UIDragDropSessionExtensionsTest.cs" />
<Compile Include="SpriteKit\SKTransformNodeTest.cs" />
<Compile Include="Metal\MTLArgumentDescriptorTest.cs" />
<Compile Include="Metal\MTLPipelineBufferDescriptorTests.cs" />
<Compile Include="Metal\MTLPointerTypeTests.cs" />
<Compile Include="Metal\MTLTextureReferenceType.cs" />
<Compile Include="PassKit\PKPaymentRequestTest.cs" />
<Compile Include="AudioToolbox\AudioComponentTest.cs" />
<Compile Include="UIKit\DirectionalEdgeInsetsTest.cs" />

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

@ -1048,6 +1048,24 @@
<Link>ProjectTestHelpers.cs</Link>
</Compile>
<Compile Include="Unified45.cs" />
<Compile Include="..\monotouch-test\Metal\HeapDescriptorTest.cs">
<Link>Metal\HeapDescriptorTest.cs</Link>
</Compile>
<Compile Include="..\monotouch-test\Metal\MTLArgumentDescriptorTest.cs">
<Link>Metal\MTLArgumentDescriptorTest.cs</Link>
</Compile>
<Compile Include="..\monotouch-test\Metal\MTLPipelineBufferDescriptorTests.cs">
<Link>Metal\MTLPipelineBufferDescriptorTests.cs</Link>
</Compile>
<Compile Include="..\monotouch-test\Metal\MTLPointerTypeTests.cs">
<Link>Metal\MTLPointerTypeTests.cs</Link>
</Compile>
<Compile Include="..\monotouch-test\Metal\MTLTextureReferenceType.cs">
<Link>Metal\MTLTextureReferenceType.cs</Link>
</Compile>
<Compile Include="..\monotouch-test\Metal\MTLDeviceTests.cs">
<Link>Metal\MTLDeviceTests.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />