// // Unit tests for MPSStateBatch // // Authors: // Alex Soto // // // Copyright 2019 Microsoft Corporation. // #if !__WATCHOS__ using System; using Foundation; using Metal; using MetalPerformanceShaders; using NUnit.Framework; namespace MonoTouchFixtures.MetalPerformanceShaders { [TestFixture] [Preserve (AllMembers = true)] public class MPSStateBatchTests { IMTLDevice device; NSArray cache; [OneTimeSetUp] public void Metal () { TestRuntime.AssertDevice (); TestRuntime.AssertXcodeVersion (10, 0); TestRuntime.AssertNotVirtualMachine (); device = MTLDevice.SystemDefault; // some older hardware won't have a default if (device is null || !MPSKernel.Supports (device)) Assert.Inconclusive ("Metal is not supported"); cache = NSArray.FromNSObjects ( new MPSState (device, MTLTextureDescriptor.CreateTexture2DDescriptor (MTLPixelFormat.RGBA32Float, 220, 220, false)), new MPSState (device, MTLTextureDescriptor.CreateTexture2DDescriptor (MTLPixelFormat.RGBA32Float, 221, 221, false)), new MPSState (device, MTLTextureDescriptor.CreateTexture2DDescriptor (MTLPixelFormat.RGBA32Float, 222, 222, false)), new MPSState (device, MTLTextureDescriptor.CreateTexture2DDescriptor (MTLPixelFormat.RGBA32Float, 223, 223, false)), new MPSState (device, MTLTextureDescriptor.CreateTexture2DDescriptor (MTLPixelFormat.RGBA32Float, 224, 224, false)), new MPSState (device, MTLTextureDescriptor.CreateTexture2DDescriptor (MTLPixelFormat.RGBA32Float, 225, 225, false)) ); } [Test] public void IncrementReadCountTest () => Assert.DoesNotThrow (() => MPSStateBatch.IncrementReadCount (cache, 5), "IncrementReadCount"); [Test] public void MPSImageBatchResourceSizeTest () { var size = MPSStateBatch.GetResourceSize (cache); Assert.That (size, Is.GreaterThan ((nuint) 0), "idx"); } } } #endif // !__WATCHOS__