public void ReadFromBuffer <T>(ComputeBuffer <T> source, ref T[] destination, bool blocking, long sourceOffset, long destinationOffset, long region, IList <ComputeEvent> events) where T : unmanaged
        {
            GCHandle destinationGCHandle  = GCHandle.Alloc(destination, GCHandleType.Pinned);
            IntPtr   destinationOffsetPtr = Marshal.UnsafeAddrOfPinnedArrayElement(destination, (int)destinationOffset);

            if (blocking)
            {
                Read(source, blocking, sourceOffset, region, destinationOffsetPtr, events);
                destinationGCHandle.Free();
            }
            else
            {
                bool userEventsWritable        = events != null && !events.IsReadOnly;
                IList <ComputeEvent> eventList = userEventsWritable ? events : Events;
                Read(source, blocking, sourceOffset, region, destinationOffsetPtr, eventList);
                ComputeEvent newEvent = (ComputeEvent)eventList[eventList.Count - 1];
                newEvent.TrackGCHandle(destinationGCHandle);
            }
        }
Esempio n. 2
0
 public ComputeCommandStatusArgs(ComputeEvent ev, ComputeCommandExecutionStatus status)
 {
     Event  = ev;
     Status = status;
 }