コード例 #1
0
        public static void SetBuffers(this IMTLArgumentEncoder encoder, IMTLBuffer[] buffers, nuint[] offsets, NSRange range)
        {
            if (buffers == null)
            {
                throw new ArgumentNullException(nameof(buffers));
            }
            if (offsets == null)
            {
                throw new ArgumentNullException(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
                {
                    encoder.SetBuffers((IntPtr)buffersPtr, (IntPtr)offsetsPtr, range);
                }
            }
            GC.KeepAlive(buffers)
        }
コード例 #2
0
 public void TearDown()
 {
     library?.Dispose();
     library = null;
     function?.Dispose();
     function = null;
     encoder?.Dispose();
     encoder = null;
 }
コード例 #3
0
        public void SetUp()
        {
            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]);
            encoder  = function.CreateArgumentEncoder(0);
        }
コード例 #4
0
 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);
 }