///<summary> ///Enqueues a command to copy data from <see cref = "ComputeImage"/> to buffer. ///</summary> ///<param name = "source"> The image to copy from. </param> ///<param name = "destination"> The buffer to copy to. </param> ///<param name = "sourceOffset"> The <paramref name = "source"/> element position where reading starts. </param> ///<param name = "destinationOffset"> The <paramref name = "destination"/> element position where writing starts. </param> ///<param name = "region"> The region of elements to copy. </param> ///<paramref name = "events"/> is not <c> null </c> or read-only a new <param name = "events"> A collection of events that need to complete before this command <see cref = "ComputeEvent"/> identifying this command is created and attached to the end of the collection. </param> public void Copy <T>(ComputeImage source, ComputeBufferBase <T> destination, SysIntX3 sourceOffset, long destinationOffset, SysIntX3 region, ICollection <ComputeEventBase> events) where T : struct { int sizeofT = Marshal.SizeOf(typeof(T)); int eventWaitListSize; CLEventHandle[] eventHandles = ComputeTools.ExtractHandles(events, out eventWaitListSize); bool eventsWritable = (events != null && !events.IsReadOnly); CLEventHandle[] newEventHandle = (eventsWritable) ? new CLEventHandle[1] : null; ComputeErrorCode error = CL12.EnqueueCopyImageToBuffer(Handle, source.Handle, destination.Handle, ref sourceOffset, ref region, new IntPtr(destinationOffset * sizeofT), eventWaitListSize, eventHandles, newEventHandle); ComputeException.ThrowOnError(error); if (eventsWritable) { events.Add(new ComputeEvent(newEventHandle[0], this)); } }