public static void SetBuffers(this IMTLIntersectionFunctionTable table, IMTLBuffer[] buffers, nuint[] offsets, NSRange range) { if (buffers == null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(buffers)); } if (offsets == null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(offsets)); } var bufferPtrArray = buffers.Length <= 1024 ? stackalloc IntPtr[buffers.Length] : new IntPtr [buffers.Length]; // get all intptr from the array to pass to the lower level call for (var i = 0; i < buffers.Length; i++) { bufferPtrArray [i] = buffers [i].Handle; } unsafe { fixed(void *buffersPtr = bufferPtrArray) fixed(void *offsetsPtr = offsets) // can use fixed { table.SetBuffers((IntPtr)buffersPtr, (IntPtr)offsetsPtr, range); } } GC.KeepAlive(buffers); }
public void SetUp() { TestRuntime.AssertXcodeVersion(12, 0); device = MTLDevice.SystemDefault; // some older hardware won't have a default if (device == null) { Assert.Inconclusive("Metal is not supported"); } library = device.CreateDefaultLibrary(); if (library == null) // this happens on a simulator { Assert.Inconclusive("Could not get the functions library for the device."); } if (library.FunctionNames.Length == 0) { Assert.Inconclusive("Could not get functions for the pipeline."); } function = library.CreateFunction(library.FunctionNames [0]); pipelineState = device.CreateComputePipelineState(function, MTLPipelineOption.ArgumentInfo, out MTLComputePipelineReflection reflection, out NSError error); if (error != null) { Assert.Inconclusive($"Could not create pipeline {error}"); } descriptor = MTLIntersectionFunctionTableDescriptor.Create(); functionTable = pipelineState.CreateIntersectionFunctionTable(descriptor); }