From 2ea0c353537168e3c312d9cae2bec0b1748ade6c Mon Sep 17 00:00:00 2001 From: Timothy Risi Date: Wed, 13 Sep 2017 13:52:37 -0800 Subject: [PATCH 1/4] [Xcode 9] Update Metal for GM --- src/Metal/MTLArrays.cs | 14 ++ src/Metal/MTLEnums.cs | 22 +++ src/Metal/MTLRenderCommandEncoder.cs | 19 +++ src/metal.cs | 229 ++++++++++++++++++++++++++- tests/introspection/ApiTypoTest.cs | 1 + 5 files changed, 283 insertions(+), 2 deletions(-) diff --git a/src/Metal/MTLArrays.cs b/src/Metal/MTLArrays.cs index d35e6ef0ca69..8d737366826f 100644 --- a/src/Metal/MTLArrays.cs +++ b/src/Metal/MTLArrays.cs @@ -91,5 +91,19 @@ public MTLPipelineBufferDescriptor this [nuint index] } } } + +#if !MONOMAC + public partial class MTLTileRenderPipelineColorAttachmentDescriptorArray { + public MTLTileRenderPipelineColorAttachmentDescriptor this [nuint index] + { + get { + return GetObject (index); + } + set { + SetObject (value, index); + } + } + } +#endif } #endif diff --git a/src/Metal/MTLEnums.cs b/src/Metal/MTLEnums.cs index de4a5e6dadfb..5df3314ef4b7 100644 --- a/src/Metal/MTLEnums.cs +++ b/src/Metal/MTLEnums.cs @@ -597,6 +597,23 @@ public enum MTLDataType : nuint { [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, + + [NoMac, iOS (11,0), TV (11,0), NoWatch] R8Unorm = 62, + [NoMac, iOS (11,0), TV (11,0), NoWatch] R8Snorm = 63, + [NoMac, iOS (11,0), TV (11,0), NoWatch] R16Unorm = 64, + [NoMac, iOS (11,0), TV (11,0), NoWatch] R16Snorm = 65, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Rg8Unorm = 66, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Rg8Snorm = 67, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Rg16Unorm = 68, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Rg16Snorm = 69, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgba8Unorm = 70, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgba8Unorm_sRgb = 71, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgba8Snorm = 72, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgba16Unorm = 73, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgba16Snorm = 74, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgb10A2Unorm = 75, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Rg11B10Float = 76, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgb9E5Float = 77, } [Native] @@ -605,6 +622,9 @@ public enum MTLArgumentType : nuint { ThreadgroupMemory= 1, Texture = 2, Sampler = 3, + + [NoMac, iOS (11,0), TV (11,0), NoWatch] ImageblockData = 16, + [NoMac, iOS (11,0), TV (11,0), NoWatch] Imageblock = 17, } [Native] @@ -637,6 +657,8 @@ public enum MTLFeatureSet : nuint { iOS_GPUFamily2_v4 = 9, [iOS (11,0), NoTV, NoWatch, NoMac] iOS_GPUFamily3_v3 = 10, + [iOS (11,0), NoTV, NoWatch, NoMac] + iOS_GPUFamily4_v1 = 11, [Mac (10,11), NoiOS, NoTV, NoWatch] macOS_GPUFamily1_v1 = 10000, diff --git a/src/Metal/MTLRenderCommandEncoder.cs b/src/Metal/MTLRenderCommandEncoder.cs index 497a28b0c4c6..7dac610bf254 100644 --- a/src/Metal/MTLRenderCommandEncoder.cs +++ b/src/Metal/MTLRenderCommandEncoder.cs @@ -21,6 +21,25 @@ public unsafe static void SetScissorRects (this IMTLRenderCommandEncoder This, M fixed (void* handle = scissorRects) This.SetScissorRects ((IntPtr)handle, (nuint)(scissorRects?.Length ?? 0)); } + +#if !MONOMAC + [iOS (11,0), TV (11,0), NoMac, NoWatch] + public unsafe static void SetTileBuffers (this IMTLRenderCommandEncoder This, IMTLBuffer[] buffers, nuint[] offsets, NSRange range) + { + fixed (void* handle = offsets) + This.SetTileBuffers (buffers, (IntPtr)handle, range); + } + + [iOS (11,0), TV (11,0), NoMac, NoWatch] + public unsafe static void SetTileSamplerStates (this IMTLRenderCommandEncoder This, IMTLSamplerState[] samplers, float[] lodMinClamps, float[] lodMaxClamps, NSRange range) + { + fixed (void* minHandle = lodMinClamps) { + fixed (void* maxHandle = lodMaxClamps) { + This.SetTileSamplerStates (samplers, (IntPtr)minHandle, (IntPtr)maxHandle, range); + } + } + } +#endif } } #endif diff --git a/src/metal.cs b/src/metal.cs index a32390c59c5a..a82f2b642e71 100644 --- a/src/metal.cs +++ b/src/metal.cs @@ -30,6 +30,8 @@ namespace XamCore.Metal { delegate void MTLDrawablePresentedHandler (IMTLDrawable drawable); + delegate void MTLNewRenderPipelineStateWithReflectionCompletionHandler (IMTLRenderPipelineState renderPipelineState, MTLRenderPipelineReflection reflection, NSError error); + interface IMTLCommandEncoder {} [iOS (8,0)][Mac (10,11, onlyOn64 : true)] @@ -447,8 +449,7 @@ partial interface MTLComputeCommandEncoder : MTLCommandEncoder { [Export ("waitForFence:")] void Wait (IMTLFence fence); - [Mac (10,13, onlyOn64: true)] - [NoTV][NoiOS] + [Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0)] #if XAMCORE_4_0 [Abstract] #endif @@ -482,6 +483,13 @@ partial interface MTLComputeCommandEncoder : MTLCommandEncoder { #endif [Export ("useHeaps:count:")] void UseHeaps (IMTLHeap[] heaps, nuint count); + + [iOS (11,0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setImageblockWidth:height:")] + void SetImageblock (nuint width, nuint height); } [iOS (8,0)][Mac (10,11, onlyOn64 : true)] @@ -521,6 +529,13 @@ partial interface MTLComputePipelineState { #endif [Export ("staticThreadgroupMemoryLength")] nuint StaticThreadgroupMemoryLength { get; } + + [iOS (11,0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("imageblockMemoryLengthForDimensions:")] + nuint GetImageblockMemoryLength (MTLSize imageblockDimensions); } interface IMTLBlitCommandEncoder {} @@ -905,6 +920,21 @@ partial interface MTLDevice { [Field ("MTLDeviceWasRemovedNotification")] NSString DeviceWasRemoved { get; } #endif + + [iOS (11,0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("newRenderPipelineStateWithTileDescriptor:options:reflection:error:")] + [return: NullAllowed] + IMTLRenderPipelineState NewRenderPipelineState (MTLTileRenderPipelineDescriptor descriptor, MTLPipelineOption options, [NullAllowed] out MTLRenderPipelineReflection reflection, [NullAllowed] out NSError error); + + [iOS (11,0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Async (ResultTypeName="NewRenderPipelineStateResult"), Export ("newRenderPipelineStateWithTileDescriptor:options:completionHandler:")] + void NewRenderPipelineState (MTLTileRenderPipelineDescriptor descriptor, MTLPipelineOption options, MTLNewRenderPipelineStateWithReflectionCompletionHandler completionHandler); } interface IMTLDrawable {} @@ -1317,6 +1347,27 @@ partial interface MTLRenderPipelineState { [Abstract, Export ("device")] IMTLDevice Device { get; } + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [Abstract] + [Export ("maxTotalThreadsPerThreadgroup")] + nuint MaxTotalThreadsPerThreadgroup { get; } + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [Abstract] + [Export ("threadgroupSizeMatchesTileSize")] + bool ThreadgroupSizeMatchesTileSize { get; } + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [Abstract] + [Export ("imageblockSampleLength")] + nuint ImageblockSampleLength { get; } + + [iOS (11,0), TV (11,0), NoMac, NoWatch] + [Abstract] + [Export ("imageblockMemoryLengthForDimensions:")] + nuint GetImageblockMemoryLength (MTLSize imageblockDimensions); + } [iOS (8,0)][Mac (10,11, onlyOn64 : true)] @@ -2088,6 +2139,104 @@ partial interface MTLRenderCommandEncoder : MTLCommandEncoder { #endif [Export ("useHeaps:count:")] void UseHeaps (IMTLHeap[] heaps, nuint count); + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("tileWidth")] + nuint TileWidth { get; } + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("tileHeight")] + nuint TileHeight { get; } + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileBytes:length:atIndex:")] + void SetTileBytes (IntPtr /* void* */ bytes, nuint length, nuint index); + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileBuffer:offset:atIndex:")] + void SetTileBuffer ([NullAllowed] IMTLBuffer buffer, nuint offset, nuint index); + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileBufferOffset:atIndex:")] + void SetTileBufferOffset (nuint offset, nuint index); + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileBuffers:offsets:withRange:")] + void SetTileBuffers (IMTLBuffer[] buffers, IntPtr offsets, NSRange range); + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileTexture:atIndex:")] + void SetTileTexture ([NullAllowed] IMTLTexture texture, nuint index); + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileTextures:withRange:")] + void SetTileTextures (IMTLTexture[] textures, NSRange range); + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileSamplerState:atIndex:")] + void SetTileSamplerState ([NullAllowed] IMTLSamplerState sampler, nuint index); + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileSamplerStates:withRange:")] + void SetTileSamplerStates (IMTLSamplerState[] samplers, NSRange range); + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileSamplerState:lodMinClamp:lodMaxClamp:atIndex:")] + void SetTileSamplerState ([NullAllowed] IMTLSamplerState sampler, float lodMinClamp, float lodMaxClamp, nuint index); + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileSamplerStates:lodMinClamps:lodMaxClamps:withRange:")] + void SetTileSamplerStates (IMTLSamplerState[] samplers, IntPtr /* float[] */ lodMinClamps, IntPtr /* float[] */ lodMaxClamps, NSRange range); + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("dispatchThreadsPerTile:")] + void DispatchThreadsPerTile (MTLSize threadsPerTile); + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setThreadgroupMemoryLength:offset:atIndex:")] + void SetThreadgroupMemoryLength (nuint length, nuint offset, nuint index); } [iOS (8,0)][Mac (10,11, onlyOn64 : true)] @@ -2138,6 +2287,10 @@ interface MTLRenderPipelineReflection { #else NSObject [] FragmentArguments { get; } #endif + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [NullAllowed, Export ("tileArguments")] + MTLArgument[] TileArguments { get; } } [iOS (8,0)][Mac (10,11, onlyOn64 : true)] @@ -2252,6 +2405,34 @@ interface MTLRenderPassDescriptor : NSCopying { [Mac (10,13), iOS (11,0), TV (11,0), NoWatch] [Export ("getSamplePositions:count:")] nuint GetSamplePositions ([NullAllowed] IntPtr positions, nuint count); + + [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [Export ("imageblockSampleLength")] + nuint ImageblockSampleLength { get; set; } + + [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [Export ("threadgroupMemoryLength")] + nuint ThreadgroupMemoryLength { get; set; } + + [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [Export ("tileWidth")] + nuint TileWidth { get; set; } + + [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [Export ("tileHeight")] + nuint TileHeight { get; set; } + + [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [Export ("defaultRasterSampleCount")] + nuint DefaultRasterSampleCount { get; set; } + + [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [Export ("renderTargetWidth")] + nuint RenderTargetWidth { get; set; } + + [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [Export ("renderTargetHeight")] + nuint RenderTargetHeight { get; set; } } @@ -2655,5 +2836,49 @@ interface MTLArgumentEncoder [return: NullAllowed] IMTLArgumentEncoder CreateArgumentEncoder (nuint index); } + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [BaseType (typeof (NSObject))] + interface MTLTileRenderPipelineColorAttachmentDescriptor : NSCopying { + [Export ("pixelFormat", ArgumentSemantic.Assign)] + MTLPixelFormat PixelFormat { get; set; } + } + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [BaseType (typeof (NSObject))] + interface MTLTileRenderPipelineColorAttachmentDescriptorArray { + [Internal] + [Export ("objectAtIndexedSubscript:")] + MTLTileRenderPipelineColorAttachmentDescriptor GetObject (nuint attachmentIndex); + + [Internal] + [Export ("setObject:atIndexedSubscript:")] + void SetObject (MTLTileRenderPipelineColorAttachmentDescriptor attachment, nuint attachmentIndex); + } + + [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [BaseType (typeof (NSObject))] + interface MTLTileRenderPipelineDescriptor : NSCopying { + [Export ("label")] + string Label { get; set; } + + [Export ("tileFunction", ArgumentSemantic.Strong)] + IMTLFunction TileFunction { get; set; } + + [Export ("rasterSampleCount")] + nuint RasterSampleCount { get; set; } + + [Export ("colorAttachments")] + MTLTileRenderPipelineColorAttachmentDescriptorArray ColorAttachments { get; } + + [Export ("threadgroupSizeMatchesTileSize")] + bool ThreadgroupSizeMatchesTileSize { get; set; } + + [Export ("tileBuffers")] + MTLPipelineBufferDescriptorArray TileBuffers { get; } + + [Export ("reset")] + void Reset (); + } } #endif diff --git a/tests/introspection/ApiTypoTest.cs b/tests/introspection/ApiTypoTest.cs index 395a056e6982..c38f9b6aef03 100644 --- a/tests/introspection/ApiTypoTest.cs +++ b/tests/introspection/ApiTypoTest.cs @@ -216,6 +216,7 @@ public virtual bool Skip (MemberInfo methodName, string typo) { "Ies", "Icq", "Identd", + "Imageblock", "Imagefor", "Imap", "Imaps", From 3d4f137c050109eb6b656454d58dab008bc19909 Mon Sep 17 00:00:00 2001 From: Timothy Risi Date: Wed, 13 Sep 2017 14:11:51 -0800 Subject: [PATCH 2/4] Make added abstracts XAMCORE_4_0, fix a couple method names --- src/metal.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/metal.cs b/src/metal.cs index a82f2b642e71..0e41c8e36e37 100644 --- a/src/metal.cs +++ b/src/metal.cs @@ -927,14 +927,14 @@ partial interface MTLDevice { #endif [Export ("newRenderPipelineStateWithTileDescriptor:options:reflection:error:")] [return: NullAllowed] - IMTLRenderPipelineState NewRenderPipelineState (MTLTileRenderPipelineDescriptor descriptor, MTLPipelineOption options, [NullAllowed] out MTLRenderPipelineReflection reflection, [NullAllowed] out NSError error); + IMTLRenderPipelineState CreateRenderPipelineState (MTLTileRenderPipelineDescriptor descriptor, MTLPipelineOption options, [NullAllowed] out MTLRenderPipelineReflection reflection, [NullAllowed] out NSError error); [iOS (11,0), TV (11,0), NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Async (ResultTypeName="NewRenderPipelineStateResult"), Export ("newRenderPipelineStateWithTileDescriptor:options:completionHandler:")] - void NewRenderPipelineState (MTLTileRenderPipelineDescriptor descriptor, MTLPipelineOption options, MTLNewRenderPipelineStateWithReflectionCompletionHandler completionHandler); + void CreateRenderPipelineState (MTLTileRenderPipelineDescriptor descriptor, MTLPipelineOption options, MTLNewRenderPipelineStateWithReflectionCompletionHandler completionHandler); } interface IMTLDrawable {} @@ -1349,22 +1349,30 @@ partial interface MTLRenderPipelineState { IMTLDevice Device { get; } [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 [Abstract] +#endif [Export ("maxTotalThreadsPerThreadgroup")] nuint MaxTotalThreadsPerThreadgroup { get; } [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 [Abstract] +#endif [Export ("threadgroupSizeMatchesTileSize")] bool ThreadgroupSizeMatchesTileSize { get; } [iOS (11, 0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 [Abstract] +#endif [Export ("imageblockSampleLength")] nuint ImageblockSampleLength { get; } [iOS (11,0), TV (11,0), NoMac, NoWatch] +#if XAMCORE_4_0 [Abstract] +#endif [Export ("imageblockMemoryLengthForDimensions:")] nuint GetImageblockMemoryLength (MTLSize imageblockDimensions); From d0dda2e8cbda7fe598597b7d485aabb5a638eda3 Mon Sep 17 00:00:00 2001 From: Timothy Risi Date: Thu, 14 Sep 2017 10:32:24 -0800 Subject: [PATCH 3/4] Fix tests (and add some manual), Fix availability --- src/Metal/MTLArrays.cs | 2 +- src/Metal/MTLEnums.cs | 41 +++++----- src/Metal/MTLRenderCommandEncoder.cs | 6 +- src/metal.cs | 71 +++++++++--------- tests/introspection/ApiSelectorTest.cs | 22 ++++++ ...rPipelineColorAttachmentDescriptorTests.cs | 43 +++++++++++ .../Metal/MTLTileRenderPipelineDescriptor.cs | 74 +++++++++++++++++++ tests/monotouch-test/monotouch-test.csproj | 2 + 8 files changed, 203 insertions(+), 58 deletions(-) create mode 100644 tests/monotouch-test/Metal/MTLTileRenderPipelineColorAttachmentDescriptorTests.cs create mode 100644 tests/monotouch-test/Metal/MTLTileRenderPipelineDescriptor.cs diff --git a/src/Metal/MTLArrays.cs b/src/Metal/MTLArrays.cs index 8d737366826f..6c2a43444548 100644 --- a/src/Metal/MTLArrays.cs +++ b/src/Metal/MTLArrays.cs @@ -92,7 +92,7 @@ public MTLPipelineBufferDescriptor this [nuint index] } } -#if !MONOMAC +#if IOS public partial class MTLTileRenderPipelineColorAttachmentDescriptorArray { public MTLTileRenderPipelineColorAttachmentDescriptor this [nuint index] { diff --git a/src/Metal/MTLEnums.cs b/src/Metal/MTLEnums.cs index 5df3314ef4b7..dd2129513d26 100644 --- a/src/Metal/MTLEnums.cs +++ b/src/Metal/MTLEnums.cs @@ -598,22 +598,22 @@ public enum MTLDataType : nuint { [Mac (10,13), iOS (11,0), TV (11,0), NoWatch] Sampler = 59, [Mac (10,13), iOS (11,0), TV (11,0), NoWatch] Pointer = 60, - [NoMac, iOS (11,0), TV (11,0), NoWatch] R8Unorm = 62, - [NoMac, iOS (11,0), TV (11,0), NoWatch] R8Snorm = 63, - [NoMac, iOS (11,0), TV (11,0), NoWatch] R16Unorm = 64, - [NoMac, iOS (11,0), TV (11,0), NoWatch] R16Snorm = 65, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Rg8Unorm = 66, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Rg8Snorm = 67, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Rg16Unorm = 68, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Rg16Snorm = 69, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgba8Unorm = 70, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgba8Unorm_sRgb = 71, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgba8Snorm = 72, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgba16Unorm = 73, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgba16Snorm = 74, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgb10A2Unorm = 75, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Rg11B10Float = 76, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Rgb9E5Float = 77, + [NoMac, iOS (11,0), NoTV, NoWatch] R8Unorm = 62, + [NoMac, iOS (11,0), NoTV, NoWatch] R8Snorm = 63, + [NoMac, iOS (11,0), NoTV, NoWatch] R16Unorm = 64, + [NoMac, iOS (11,0), NoTV, NoWatch] R16Snorm = 65, + [NoMac, iOS (11,0), NoTV, NoWatch] Rg8Unorm = 66, + [NoMac, iOS (11,0), NoTV, NoWatch] Rg8Snorm = 67, + [NoMac, iOS (11,0), NoTV, NoWatch] Rg16Unorm = 68, + [NoMac, iOS (11,0), NoTV, NoWatch] Rg16Snorm = 69, + [NoMac, iOS (11,0), NoTV, NoWatch] Rgba8Unorm = 70, + [NoMac, iOS (11,0), NoTV, NoWatch] Rgba8Unorm_sRgb = 71, + [NoMac, iOS (11,0), NoTV, NoWatch] Rgba8Snorm = 72, + [NoMac, iOS (11,0), NoTV, NoWatch] Rgba16Unorm = 73, + [NoMac, iOS (11,0), NoTV, NoWatch] Rgba16Snorm = 74, + [NoMac, iOS (11,0), NoTV, NoWatch] Rgb10A2Unorm = 75, + [NoMac, iOS (11,0), NoTV, NoWatch] Rg11B10Float = 76, + [NoMac, iOS (11,0), NoTV, NoWatch] Rgb9E5Float = 77, } [Native] @@ -623,8 +623,8 @@ public enum MTLArgumentType : nuint { Texture = 2, Sampler = 3, - [NoMac, iOS (11,0), TV (11,0), NoWatch] ImageblockData = 16, - [NoMac, iOS (11,0), TV (11,0), NoWatch] Imageblock = 17, + [NoMac, iOS (11,0), NoTV, NoWatch] ImageblockData = 16, + [NoMac, iOS (11,0), NoTV, NoWatch] Imageblock = 17, } [Native] @@ -683,7 +683,10 @@ public enum MTLFeatureSet : nuint { TVOS_GPUFamily1_v1 = 30000, [NoiOS, TV (10,0), NoWatch, NoMac] - tvOS_GPUFamily1_v2 = 30001 + tvOS_GPUFamily1_v2 = 30001, + + [NoiOS, TV (11,0), NoWatch, NoMac] + tvOS_GPUFamily2_v1 = 30003, } [iOS (9,0)][Mac (10,11)] diff --git a/src/Metal/MTLRenderCommandEncoder.cs b/src/Metal/MTLRenderCommandEncoder.cs index 7dac610bf254..0cc9c36b1dbb 100644 --- a/src/Metal/MTLRenderCommandEncoder.cs +++ b/src/Metal/MTLRenderCommandEncoder.cs @@ -22,15 +22,15 @@ public unsafe static void SetScissorRects (this IMTLRenderCommandEncoder This, M This.SetScissorRects ((IntPtr)handle, (nuint)(scissorRects?.Length ?? 0)); } -#if !MONOMAC - [iOS (11,0), TV (11,0), NoMac, NoWatch] +#if IOS + [iOS (11,0), NoTV, NoMac, NoWatch] public unsafe static void SetTileBuffers (this IMTLRenderCommandEncoder This, IMTLBuffer[] buffers, nuint[] offsets, NSRange range) { fixed (void* handle = offsets) This.SetTileBuffers (buffers, (IntPtr)handle, range); } - [iOS (11,0), TV (11,0), NoMac, NoWatch] + [iOS (11,0), NoTV, NoMac, NoWatch] public unsafe static void SetTileSamplerStates (this IMTLRenderCommandEncoder This, IMTLSamplerState[] samplers, float[] lodMinClamps, float[] lodMaxClamps, NSRange range) { fixed (void* minHandle = lodMinClamps) { diff --git a/src/metal.cs b/src/metal.cs index 0e41c8e36e37..7f2a70d819cf 100644 --- a/src/metal.cs +++ b/src/metal.cs @@ -449,7 +449,8 @@ partial interface MTLComputeCommandEncoder : MTLCommandEncoder { [Export ("waitForFence:")] void Wait (IMTLFence fence); - [Mac (10,13, onlyOn64: true), iOS (11,0), TV (11,0)] + [Mac (10,13, onlyOn64: true)] + [iOS (11,0), NoTV] #if XAMCORE_4_0 [Abstract] #endif @@ -484,7 +485,7 @@ partial interface MTLComputeCommandEncoder : MTLCommandEncoder { [Export ("useHeaps:count:")] void UseHeaps (IMTLHeap[] heaps, nuint count); - [iOS (11,0), TV (11,0), NoMac, NoWatch] + [iOS (11,0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif @@ -530,7 +531,7 @@ partial interface MTLComputePipelineState { [Export ("staticThreadgroupMemoryLength")] nuint StaticThreadgroupMemoryLength { get; } - [iOS (11,0), TV (11,0), NoMac, NoWatch] + [iOS (11,0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif @@ -921,7 +922,7 @@ partial interface MTLDevice { NSString DeviceWasRemoved { get; } #endif - [iOS (11,0), TV (11,0), NoMac, NoWatch] + [iOS (11,0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif @@ -929,11 +930,11 @@ partial interface MTLDevice { [return: NullAllowed] IMTLRenderPipelineState CreateRenderPipelineState (MTLTileRenderPipelineDescriptor descriptor, MTLPipelineOption options, [NullAllowed] out MTLRenderPipelineReflection reflection, [NullAllowed] out NSError error); - [iOS (11,0), TV (11,0), NoMac, NoWatch] + [iOS (11,0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif - [Async (ResultTypeName="NewRenderPipelineStateResult"), Export ("newRenderPipelineStateWithTileDescriptor:options:completionHandler:")] + [Export ("newRenderPipelineStateWithTileDescriptor:options:completionHandler:")] void CreateRenderPipelineState (MTLTileRenderPipelineDescriptor descriptor, MTLPipelineOption options, MTLNewRenderPipelineStateWithReflectionCompletionHandler completionHandler); } @@ -1348,28 +1349,28 @@ partial interface MTLRenderPipelineState { [Abstract, Export ("device")] IMTLDevice Device { get; } - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("maxTotalThreadsPerThreadgroup")] nuint MaxTotalThreadsPerThreadgroup { get; } - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("threadgroupSizeMatchesTileSize")] bool ThreadgroupSizeMatchesTileSize { get; } - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("imageblockSampleLength")] nuint ImageblockSampleLength { get; } - [iOS (11,0), TV (11,0), NoMac, NoWatch] + [iOS (11,0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif @@ -2148,98 +2149,98 @@ partial interface MTLRenderCommandEncoder : MTLCommandEncoder { [Export ("useHeaps:count:")] void UseHeaps (IMTLHeap[] heaps, nuint count); - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("tileWidth")] nuint TileWidth { get; } - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("tileHeight")] nuint TileHeight { get; } - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("setTileBytes:length:atIndex:")] void SetTileBytes (IntPtr /* void* */ bytes, nuint length, nuint index); - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("setTileBuffer:offset:atIndex:")] void SetTileBuffer ([NullAllowed] IMTLBuffer buffer, nuint offset, nuint index); - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("setTileBufferOffset:atIndex:")] void SetTileBufferOffset (nuint offset, nuint index); - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("setTileBuffers:offsets:withRange:")] void SetTileBuffers (IMTLBuffer[] buffers, IntPtr offsets, NSRange range); - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("setTileTexture:atIndex:")] void SetTileTexture ([NullAllowed] IMTLTexture texture, nuint index); - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("setTileTextures:withRange:")] void SetTileTextures (IMTLTexture[] textures, NSRange range); - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("setTileSamplerState:atIndex:")] void SetTileSamplerState ([NullAllowed] IMTLSamplerState sampler, nuint index); - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("setTileSamplerStates:withRange:")] void SetTileSamplerStates (IMTLSamplerState[] samplers, NSRange range); - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("setTileSamplerState:lodMinClamp:lodMaxClamp:atIndex:")] void SetTileSamplerState ([NullAllowed] IMTLSamplerState sampler, float lodMinClamp, float lodMaxClamp, nuint index); - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("setTileSamplerStates:lodMinClamps:lodMaxClamps:withRange:")] void SetTileSamplerStates (IMTLSamplerState[] samplers, IntPtr /* float[] */ lodMinClamps, IntPtr /* float[] */ lodMaxClamps, NSRange range); - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif [Export ("dispatchThreadsPerTile:")] void DispatchThreadsPerTile (MTLSize threadsPerTile); - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] #if XAMCORE_4_0 [Abstract] #endif @@ -2296,7 +2297,7 @@ interface MTLRenderPipelineReflection { NSObject [] FragmentArguments { get; } #endif - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] [NullAllowed, Export ("tileArguments")] MTLArgument[] TileArguments { get; } } @@ -2414,31 +2415,31 @@ interface MTLRenderPassDescriptor : NSCopying { [Export ("getSamplePositions:count:")] nuint GetSamplePositions ([NullAllowed] IntPtr positions, nuint count); - [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [iOS (11, 0), NoTV, NoWatch, NoMac] [Export ("imageblockSampleLength")] nuint ImageblockSampleLength { get; set; } - [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [iOS (11, 0), NoTV, NoWatch, NoMac] [Export ("threadgroupMemoryLength")] nuint ThreadgroupMemoryLength { get; set; } - [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [iOS (11, 0), NoTV, NoWatch, NoMac] [Export ("tileWidth")] nuint TileWidth { get; set; } - [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [iOS (11, 0), NoTV, NoWatch, NoMac] [Export ("tileHeight")] nuint TileHeight { get; set; } - [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [iOS (11, 0), NoTV, NoWatch, NoMac] [Export ("defaultRasterSampleCount")] nuint DefaultRasterSampleCount { get; set; } - [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [iOS (11, 0), NoTV, NoWatch, NoMac] [Export ("renderTargetWidth")] nuint RenderTargetWidth { get; set; } - [iOS (11, 0), TV (11,0), NoWatch, NoMac] + [iOS (11, 0), NoTV, NoWatch, NoMac] [Export ("renderTargetHeight")] nuint RenderTargetHeight { get; set; } } @@ -2845,14 +2846,14 @@ interface MTLArgumentEncoder IMTLArgumentEncoder CreateArgumentEncoder (nuint index); } - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] [BaseType (typeof (NSObject))] interface MTLTileRenderPipelineColorAttachmentDescriptor : NSCopying { [Export ("pixelFormat", ArgumentSemantic.Assign)] MTLPixelFormat PixelFormat { get; set; } } - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] [BaseType (typeof (NSObject))] interface MTLTileRenderPipelineColorAttachmentDescriptorArray { [Internal] @@ -2864,7 +2865,7 @@ interface MTLTileRenderPipelineColorAttachmentDescriptorArray { void SetObject (MTLTileRenderPipelineColorAttachmentDescriptor attachment, nuint attachmentIndex); } - [iOS (11, 0), TV (11,0), NoMac, NoWatch] + [iOS (11, 0), NoTV, NoMac, NoWatch] [BaseType (typeof (NSObject))] interface MTLTileRenderPipelineDescriptor : NSCopying { [Export ("label")] diff --git a/tests/introspection/ApiSelectorTest.cs b/tests/introspection/ApiSelectorTest.cs index 874e668c34fd..7f371696a167 100644 --- a/tests/introspection/ApiSelectorTest.cs +++ b/tests/introspection/ApiSelectorTest.cs @@ -421,6 +421,28 @@ protected virtual bool Skip (Type type, string selectorName) return true; } break; + case "MTLTileRenderPipelineColorAttachmentDescriptor": + switch (selectorName) { + case "pixelFormat": + case "setPixelFormat:": + return true; + } + break; + case "MTLTileRenderPipelineDescriptor": + switch (selectorName) { + case "colorAttachments": + case "label": + case "setLabel:": + case "rasterSampleCount": + case "setRasterSampleCount:": + case "threadgroupSizeMatchesTileSize": + case "setThreadgroupSizeMatchesTileSize:": + case "tileBuffers": + case "tileFunction": + case "setTileFunction:": + 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": diff --git a/tests/monotouch-test/Metal/MTLTileRenderPipelineColorAttachmentDescriptorTests.cs b/tests/monotouch-test/Metal/MTLTileRenderPipelineColorAttachmentDescriptorTests.cs new file mode 100644 index 000000000000..3d705faa0f78 --- /dev/null +++ b/tests/monotouch-test/Metal/MTLTileRenderPipelineColorAttachmentDescriptorTests.cs @@ -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 MTLTileRenderPipelineColorAttachmentDescriptorTests { + MTLTileRenderPipelineColorAttachmentDescriptor descriptor = null; + + [SetUp] + public void SetUp () + { + TestRuntime.AssertXcodeVersion (9, 0); + descriptor = new MTLTileRenderPipelineColorAttachmentDescriptor (); + } + + [TearDown] + public void TearDown () + { + if (descriptor != null) + descriptor.Dispose (); + descriptor = null; + } + + [Test] + public void GetSetPixelFormat () + { + descriptor.PixelFormat = MTLPixelFormat.RGBA8Snorm; + Assert.AreEqual (MTLPixelFormat.RGBA8Snorm, descriptor.PixelFormat); + } + } +} + +#endif // !__WATCHOS__ \ No newline at end of file diff --git a/tests/monotouch-test/Metal/MTLTileRenderPipelineDescriptor.cs b/tests/monotouch-test/Metal/MTLTileRenderPipelineDescriptor.cs new file mode 100644 index 000000000000..98066a3009e4 --- /dev/null +++ b/tests/monotouch-test/Metal/MTLTileRenderPipelineDescriptor.cs @@ -0,0 +1,74 @@ +#if !__WATCHOS__ + +using System; + +#if XAMCORE_2_0 +using Metal; +#else +using MonoTouch.Metal; +#endif + +using NUnit.Framework; + +namespace MonoTouchFixtures.Metal { + + [TestFixture] + public class MTLTileRenderPipelineDescriptorTests { + MTLTileRenderPipelineDescriptor descriptor = null; + + [SetUp] + public void SetUp () + { + TestRuntime.AssertXcodeVersion (9, 0); + descriptor = new MTLTileRenderPipelineDescriptor (); + } + + [TearDown] + public void TearDown () + { + if (descriptor != null) + descriptor.Dispose (); + descriptor = null; + } + + [Test] + public void ColorAttachmentsTest () + { + var attachments = descriptor.ColorAttachments; + Assert.NotNull (attachments); + } + + [Test] + public void GetSetLabelTest () + { + descriptor.Label = "Foo"; + Assert.AreEqual ("Foo", descriptor.Label); + } + + [Test] + public void GetSetRasterSampleCount () + { + descriptor.RasterSampleCount = 2; + Assert.AreEqual (2, descriptor.RasterSampleCount); + } + + [Test] + public void GetSetThreadgroupSizeMatchesTileSize () + { + descriptor.ThreadgroupSizeMatchesTileSize = true; + Assert.AreEqual (true, descriptor.ThreadgroupSizeMatchesTileSize); + + descriptor.ThreadgroupSizeMatchesTileSize = false; + Assert.AreEqual (false, descriptor.ThreadgroupSizeMatchesTileSize); + } + + [Test] + public void GetTileBuffers () + { + var buffers = descriptor.TileBuffers; + Assert.NotNull (buffers); + } + } +} + +#endif // !__WATCHOS__ \ No newline at end of file diff --git a/tests/monotouch-test/monotouch-test.csproj b/tests/monotouch-test/monotouch-test.csproj index ba58a7ac7372..e0720375fcc5 100644 --- a/tests/monotouch-test/monotouch-test.csproj +++ b/tests/monotouch-test/monotouch-test.csproj @@ -685,6 +685,8 @@ + + From e1c7d2e870ba0e145d8d363cbd780b32857ef2fa Mon Sep 17 00:00:00 2001 From: Timothy Risi Date: Thu, 14 Sep 2017 12:33:58 -0800 Subject: [PATCH 4/4] New monotouch-tests should be iOS only --- .../MTLTileRenderPipelineColorAttachmentDescriptorTests.cs | 2 +- tests/monotouch-test/Metal/MTLTileRenderPipelineDescriptor.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/monotouch-test/Metal/MTLTileRenderPipelineColorAttachmentDescriptorTests.cs b/tests/monotouch-test/Metal/MTLTileRenderPipelineColorAttachmentDescriptorTests.cs index 3d705faa0f78..db3fd3ebbdd9 100644 --- a/tests/monotouch-test/Metal/MTLTileRenderPipelineColorAttachmentDescriptorTests.cs +++ b/tests/monotouch-test/Metal/MTLTileRenderPipelineColorAttachmentDescriptorTests.cs @@ -1,4 +1,4 @@ -#if !__WATCHOS__ +#if __IOS__ using System; diff --git a/tests/monotouch-test/Metal/MTLTileRenderPipelineDescriptor.cs b/tests/monotouch-test/Metal/MTLTileRenderPipelineDescriptor.cs index 98066a3009e4..5e8d7f66ba33 100644 --- a/tests/monotouch-test/Metal/MTLTileRenderPipelineDescriptor.cs +++ b/tests/monotouch-test/Metal/MTLTileRenderPipelineDescriptor.cs @@ -1,4 +1,4 @@ -#if !__WATCHOS__ +#if __IOS__ using System;