diff --git a/src/Metal/MTLArrays.cs b/src/Metal/MTLArrays.cs index d35e6ef0ca69..6c2a43444548 100644 --- a/src/Metal/MTLArrays.cs +++ b/src/Metal/MTLArrays.cs @@ -91,5 +91,19 @@ public MTLPipelineBufferDescriptor this [nuint index] } } } + +#if IOS + 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..dd2129513d26 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), 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] @@ -605,6 +622,9 @@ public enum MTLArgumentType : nuint { ThreadgroupMemory= 1, Texture = 2, Sampler = 3, + + [NoMac, iOS (11,0), NoTV, NoWatch] ImageblockData = 16, + [NoMac, iOS (11,0), NoTV, 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, @@ -661,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 497a28b0c4c6..0cc9c36b1dbb 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 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), NoTV, 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 73a50ad32544..6ce8f7226603 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)] @@ -448,7 +450,7 @@ partial interface MTLComputeCommandEncoder : MTLCommandEncoder { void Wait (IMTLFence fence); [Mac (10,13, onlyOn64: true)] - [NoTV][NoiOS] + [iOS (11,0), NoTV] #if XAMCORE_4_0 [Abstract] #endif @@ -482,6 +484,13 @@ partial interface MTLComputeCommandEncoder : MTLCommandEncoder { #endif [Export ("useHeaps:count:")] void UseHeaps (IMTLHeap[] heaps, nuint count); + + [iOS (11,0), NoTV, 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 +530,13 @@ partial interface MTLComputePipelineState { #endif [Export ("staticThreadgroupMemoryLength")] nuint StaticThreadgroupMemoryLength { get; } + + [iOS (11,0), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("imageblockMemoryLengthForDimensions:")] + nuint GetImageblockMemoryLength (MTLSize imageblockDimensions); } interface IMTLBlitCommandEncoder {} @@ -905,6 +921,21 @@ partial interface MTLDevice { [Field ("MTLDeviceWasRemovedNotification")] NSString DeviceWasRemoved { get; } #endif + + [iOS (11,0), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("newRenderPipelineStateWithTileDescriptor:options:reflection:error:")] + [return: NullAllowed] + IMTLRenderPipelineState CreateRenderPipelineState (MTLTileRenderPipelineDescriptor descriptor, MTLPipelineOption options, [NullAllowed] out MTLRenderPipelineReflection reflection, [NullAllowed] out NSError error); + + [iOS (11,0), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("newRenderPipelineStateWithTileDescriptor:options:completionHandler:")] + void CreateRenderPipelineState (MTLTileRenderPipelineDescriptor descriptor, MTLPipelineOption options, MTLNewRenderPipelineStateWithReflectionCompletionHandler completionHandler); } interface IMTLDrawable {} @@ -1317,6 +1348,35 @@ partial interface MTLRenderPipelineState { [Abstract, Export ("device")] IMTLDevice Device { get; } + + [iOS (11, 0), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("maxTotalThreadsPerThreadgroup")] + nuint MaxTotalThreadsPerThreadgroup { get; } + + [iOS (11, 0), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("threadgroupSizeMatchesTileSize")] + bool ThreadgroupSizeMatchesTileSize { get; } + + [iOS (11, 0), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("imageblockSampleLength")] + nuint ImageblockSampleLength { get; } + + [iOS (11,0), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("imageblockMemoryLengthForDimensions:")] + nuint GetImageblockMemoryLength (MTLSize imageblockDimensions); + } [iOS (8,0)][Mac (10,11, onlyOn64 : true)] @@ -2088,6 +2148,104 @@ partial interface MTLRenderCommandEncoder : MTLCommandEncoder { #endif [Export ("useHeaps:count:")] void UseHeaps (IMTLHeap[] heaps, nuint count); + + [iOS (11, 0), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("tileWidth")] + nuint TileWidth { get; } + + [iOS (11, 0), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("tileHeight")] + nuint TileHeight { get; } + + [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), 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), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileBufferOffset:atIndex:")] + void SetTileBufferOffset (nuint offset, nuint index); + + [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), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileTexture:atIndex:")] + void SetTileTexture ([NullAllowed] IMTLTexture texture, nuint index); + + [iOS (11, 0), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileTextures:withRange:")] + void SetTileTextures (IMTLTexture[] textures, NSRange range); + + [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), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("setTileSamplerStates:withRange:")] + void SetTileSamplerStates (IMTLSamplerState[] samplers, NSRange range); + + [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), 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), NoTV, NoMac, NoWatch] +#if XAMCORE_4_0 + [Abstract] +#endif + [Export ("dispatchThreadsPerTile:")] + void DispatchThreadsPerTile (MTLSize threadsPerTile); + + [iOS (11, 0), NoTV, 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 +2296,10 @@ interface MTLRenderPipelineReflection { #else NSObject [] FragmentArguments { get; } #endif + + [iOS (11, 0), NoTV, NoMac, NoWatch] + [NullAllowed, Export ("tileArguments")] + MTLArgument[] TileArguments { get; } } [iOS (8,0)][Mac (10,11, onlyOn64 : true)] @@ -2252,6 +2414,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), NoTV, NoWatch, NoMac] + [Export ("imageblockSampleLength")] + nuint ImageblockSampleLength { get; set; } + + [iOS (11, 0), NoTV, NoWatch, NoMac] + [Export ("threadgroupMemoryLength")] + nuint ThreadgroupMemoryLength { get; set; } + + [iOS (11, 0), NoTV, NoWatch, NoMac] + [Export ("tileWidth")] + nuint TileWidth { get; set; } + + [iOS (11, 0), NoTV, NoWatch, NoMac] + [Export ("tileHeight")] + nuint TileHeight { get; set; } + + [iOS (11, 0), NoTV, NoWatch, NoMac] + [Export ("defaultRasterSampleCount")] + nuint DefaultRasterSampleCount { get; set; } + + [iOS (11, 0), NoTV, NoWatch, NoMac] + [Export ("renderTargetWidth")] + nuint RenderTargetWidth { get; set; } + + [iOS (11, 0), NoTV, NoWatch, NoMac] + [Export ("renderTargetHeight")] + nuint RenderTargetHeight { get; set; } } @@ -2655,5 +2845,49 @@ interface MTLArgumentEncoder [return: NullAllowed] IMTLArgumentEncoder CreateArgumentEncoder (nuint index); } + + [iOS (11, 0), NoTV, NoMac, NoWatch] + [BaseType (typeof (NSObject))] + interface MTLTileRenderPipelineColorAttachmentDescriptor : NSCopying { + [Export ("pixelFormat", ArgumentSemantic.Assign)] + MTLPixelFormat PixelFormat { get; set; } + } + + [iOS (11, 0), NoTV, 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), NoTV, 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/ApiSelectorTest.cs b/tests/introspection/ApiSelectorTest.cs index 57971dd533f7..7f371696a167 100644 --- a/tests/introspection/ApiSelectorTest.cs +++ b/tests/introspection/ApiSelectorTest.cs @@ -421,6 +421,34 @@ 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": + return true; + } + break; case "NSQueryGenerationToken": // A test was added in monotouch tests to ensure the selector works switch (selectorName) { case "encodeWithCoder:": 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", diff --git a/tests/monotouch-test/Metal/MTLTileRenderPipelineColorAttachmentDescriptorTests.cs b/tests/monotouch-test/Metal/MTLTileRenderPipelineColorAttachmentDescriptorTests.cs new file mode 100644 index 000000000000..db3fd3ebbdd9 --- /dev/null +++ b/tests/monotouch-test/Metal/MTLTileRenderPipelineColorAttachmentDescriptorTests.cs @@ -0,0 +1,43 @@ +#if __IOS__ + +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..5e8d7f66ba33 --- /dev/null +++ b/tests/monotouch-test/Metal/MTLTileRenderPipelineDescriptor.cs @@ -0,0 +1,74 @@ +#if __IOS__ + +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 fa1b6e082403..34cc76708d9c 100644 --- a/tests/monotouch-test/monotouch-test.csproj +++ b/tests/monotouch-test/monotouch-test.csproj @@ -686,6 +686,8 @@ + +