/// <summary> /// Creates a new <see cref="OpenCLSubBuffer{T}"/> from a specified <see cref="OpenCLBuffer{T}"/>. /// </summary> /// <param name="buffer"> The buffer to create the <see cref="OpenCLSubBuffer{T}"/> from. </param> /// <param name="flags"> A bit-field that is used to specify allocation and usage information about the <see cref="OpenCLBuffer{T}"/>. </param> /// <param name="offset"> The index of the element of <paramref name="buffer"/>, where the <see cref="OpenCLSubBuffer{T}"/> starts. </param> /// <param name="count"> The number of elements of <paramref name="buffer"/> to include in the <see cref="OpenCLSubBuffer{T}"/>. </param> public OpenCLSubBuffer(OpenCLBuffer buffer, OpenCLMemoryFlags flags, long offset, long count) : base(buffer.Context, flags, buffer.ElementType, new long[] { count }) { SysIntX2 region = new SysIntX2(offset * Marshal.SizeOf(buffer.ElementType), count * Marshal.SizeOf(buffer.ElementType)); OpenCLErrorCode error; CLMemoryHandle handle = CL11.CreateSubBuffer(Handle, flags, OpenCLBufferCreateType.Region, ref region, out error); OpenCLException.ThrowOnError(error); Init(); }
/// <summary> /// /// </summary> /// <param name="x2"></param> /// <param name="z"></param> public SysIntX3(SysIntX2 x2, long z) : this(x2.X, x2.Y, new IntPtr(z)) { }
/// <summary> /// Enqueues a command to copy data from a source buffer to a destination buffer. /// </summary> /// <typeparam name="T"> The type of data in the buffers. </typeparam> /// <param name="source"> The buffer 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> /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> a new event identifying this command is attached to the end of the collection. </param> public void CopyBuffer(OpenCLBufferBase source, OpenCLBufferBase destination, SysIntX2 sourceOffset, SysIntX2 destinationOffset, SysIntX2 region, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { Copy(source, destination, new SysIntX3(sourceOffset, 0), new SysIntX3(destinationOffset, 0), new SysIntX3(region, 1), 0, 0, 0, 0, events, newEvents); }
/// <summary> /// Enqueues a command to write data to an image. /// </summary> /// <param name="source"> A pointer to a memory area to read from. </param> /// <param name="destination"> The image to write to. </param> /// <param name="blocking"> The mode of operation of this command. If <c>true</c> this call will not return until the command has finished execution. </param> /// <param name="destinationOffset"> The <paramref name="destination"/> element position where writing starts. </param> /// <param name="region"> The region of elements to write. </param> /// <param name="destinationRowPitch"> The size of a row of pixels of <paramref name="destination"/> in bytes. </param> /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> a new event identifying this command is attached to the end of the collection. </param> public void WriteToImage(IntPtr source, OpenCLImage2D destination, bool blocking, SysIntX2 destinationOffset, SysIntX2 region, long destinationRowPitch, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { Write(destination, blocking, new SysIntX3(destinationOffset, 0), new SysIntX3(region, 1), destinationRowPitch, 0, source, events, newEvents); }
/// <summary> /// Enqueues a command to write data to a buffer. /// </summary> /// <typeparam name="T"> The type of data in the buffer. </typeparam> /// <param name="source"> The array to read from. </param> /// <param name="destination"> The buffer to write to. </param> /// <param name="blocking"> The mode of operation of this command. If <c>true</c> this call will not return until the command has finished execution. </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 write. </param> /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> a new event identifying this command is attached to the end of the collection. </param> /*public void WriteToBuffer(Array source, OpenCLBufferBase destination, bool blocking, SysIntX2 sourceOffset, SysIntX2 destinationOffset, SysIntX2 region, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { WriteToBuffer(source, destination, blocking, sourceOffset, destinationOffset, region, 0, 0, events, newEvents); }*/ public void WriteToBuffer(IntPtr source, OpenCLBufferBase destination, bool blocking, SysIntX2 sourceOffset, SysIntX2 destinationOffset, SysIntX2 region, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { WriteToBuffer(source, destination, blocking, sourceOffset, destinationOffset, region, 0, 0, events, newEvents); }
/// <summary> /// Enqueues a command to write data to a buffer. /// </summary> /// <typeparam name="T"> The type of data in the buffer. </typeparam> /// <param name="source"> The array to read from. </param> /// <param name="destination"> The buffer to write to. </param> /// <param name="blocking"> The mode of operation of this command. If <c>true</c> this call will not return until the command has finished execution. </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 write. </param> /// <param name="sourceRowPitch"> The size of a row of elements of <paramref name="source"/> in bytes. </param> /// <param name="destinationRowPitch"> The size of a row of elements of <paramref name="destination"/> in bytes. </param> /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> a new event identifying this command is attached to the end of the collection. </param> /*public void WriteToBuffer(Array source, OpenCLBufferBase destination, bool blocking, SysIntX2 sourceOffset, SysIntX2 destinationOffset, SysIntX2 region, long sourceRowPitch, long destinationRowPitch, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { GCHandle sourceGCHandle = GCHandle.Alloc(source, GCHandleType.Pinned); if (blocking) { Write(destination, blocking, new SysIntX3(sourceOffset, 0), new SysIntX3(destinationOffset, 0), new SysIntX3(region, 1), sourceRowPitch, 0, destinationRowPitch, 0, sourceGCHandle.AddrOfPinnedObject(), events, newEvents); sourceGCHandle.Free(); } else { IList<OpenCLEventBase> eventList = (newEvents != null) ? newEvents : Events; Write(destination, blocking, new SysIntX3(sourceOffset, 0), new SysIntX3(destinationOffset, 0), new SysIntX3(region, 1), sourceRowPitch, 0, destinationRowPitch, 0, sourceGCHandle.AddrOfPinnedObject(), events, eventList); OpenCLEvent newEvent = (OpenCLEvent)eventList.Last(); newEvent.TrackGCHandle(sourceGCHandle); } }*/ public void WriteToBuffer(IntPtr source, OpenCLBufferBase destination, bool blocking, SysIntX2 sourceOffset, SysIntX2 destinationOffset, SysIntX2 region, long sourceRowPitch, long destinationRowPitch, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { if (blocking) { Write(destination, blocking, new SysIntX3(sourceOffset, 0), new SysIntX3(destinationOffset, 0), new SysIntX3(region, 1), sourceRowPitch, 0, destinationRowPitch, 0, source, events, newEvents); } else { IList<OpenCLEventBase> eventList = (newEvents != null) ? newEvents : Events; Write(destination, blocking, new SysIntX3(sourceOffset, 0), new SysIntX3(destinationOffset, 0), new SysIntX3(region, 1), sourceRowPitch, 0, destinationRowPitch, 0, source, events, eventList); } }
public void ReadFromBuffer(OpenCLBufferBase source, IntPtr destination, bool blocking, SysIntX2 sourceOffset, SysIntX2 region, long sourceRowPitch, long destinationRowPitch, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { if (blocking) { Read(source, blocking, new SysIntX3(sourceOffset, 0), new SysIntX3(0, 0, 0), new SysIntX3(region, 1), sourceRowPitch, 0, destinationRowPitch, 0, destination, events, newEvents); } else { IList<OpenCLEventBase> eventList = (newEvents != null) ? newEvents : Events; Read(source, blocking, new SysIntX3(sourceOffset, 0), new SysIntX3(0, 0, 0), new SysIntX3(region, 1), sourceRowPitch, 0, destinationRowPitch, 0, destination, events, eventList); } }
/// <summary> /// Enqueues a command to read data from an image. /// </summary> /// <param name="source"> The image to read from. </param> /// <param name="destination"> A valid pointer to a preallocated memory area to write to. </param> /// <param name="blocking"> The mode of operation of this command. If <c>true</c> this call will not return until the command has finished execution. </param> /// <param name="sourceOffset"> The <paramref name="source"/> element position where reading starts. </param> /// <param name="region"> The region of elements to read. </param> /// <param name="sourceRowPitch"> The size of a row of pixels of <paramref name="destination"/> in bytes. </param> /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> a new event identifying this command is attached to the end of the collection. </param> public void ReadFromImage(OpenCLImage2D source, IntPtr destination, bool blocking, SysIntX2 sourceOffset, SysIntX2 region, long sourceRowPitch, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { Read(source, blocking, new SysIntX3(sourceOffset, 0), new SysIntX3(region, 1), sourceRowPitch, 0, destination, events, newEvents); }
/// <summary> /// Enqueues a command to read data from a buffer. /// </summary> /// <typeparam name="T"> The type of data in the buffer. </typeparam> /// <param name="source"> The buffer to read from. </param> /// <param name="destination"> The array to write to. </param> /// <param name="blocking"> The mode of operation of this command. If <c>true</c> this call will not return until the command has finished execution. </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 read. </param> /// <param name="sourceRowPitch"> The size of a row of elements of <paramref name="source"/> in bytes. </param> /// <param name="destinationRowPitch"> The size of a row of elements of <paramref name="destination"/> in bytes. </param> /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> a new event identifying this command is attached to the end of the collection. </param> public void ReadFromBuffer(OpenCLBufferBase source, ref Array destination, bool blocking, SysIntX2 sourceOffset, SysIntX2 destinationOffset, SysIntX2 region, long sourceRowPitch, long destinationRowPitch, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { GCHandle destinationGCHandle = GCHandle.Alloc(destination, GCHandleType.Pinned); if (blocking) { Read(source, blocking, new SysIntX3(sourceOffset, 0), new SysIntX3(destinationOffset, 0), new SysIntX3(region, 1), sourceRowPitch, 0, destinationRowPitch, 0, destinationGCHandle.AddrOfPinnedObject(), events, newEvents); destinationGCHandle.Free(); } else { IList<OpenCLEventBase> eventList = (newEvents != null) ? newEvents : Events; Read(source, blocking, new SysIntX3(sourceOffset, 0), new SysIntX3(destinationOffset, 0), new SysIntX3(region, 1), sourceRowPitch, 0, destinationRowPitch, 0, destinationGCHandle.AddrOfPinnedObject(), events, eventList); OpenCLEvent newEvent = (OpenCLEvent)eventList.Last(); newEvent.TrackGCHandle(destinationGCHandle); } }
public void ReadFromBuffer(OpenCLBufferBase source, IntPtr destination, bool blocking, SysIntX2 sourceOffset, SysIntX2 region, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { ReadFromBuffer(source, destination, blocking, sourceOffset, region, 0, 0, events, newEvents); }
/// <summary> /// Enqueues a command to copy data from an image to a buffer. /// </summary> /// <typeparam name="T"> The type of data in <paramref name="destination"/>. </typeparam> /// <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> /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> a new event identifying this command is attached to the end of the collection. </param> public void CopyImageToBuffer(OpenCLImage2D source, OpenCLBufferBase destination, SysIntX2 sourceOffset, long destinationOffset, SysIntX2 region, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { Copy(source, destination, new SysIntX3(sourceOffset, 0), destinationOffset, new SysIntX3(region, 1), events, newEvents); }
/// <summary> /// Enqueues a command to copy data from a source image to a destination image. /// </summary> /// <param name="source"> The image to copy from. </param> /// <param name="destination"> The image 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> /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> a new event identifying this command is attached to the end of the collection. </param> public void CopyImage(OpenCLImage3D source, OpenCLImage2D destination, SysIntX3 sourceOffset, SysIntX2 destinationOffset, SysIntX2 region, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { Copy(source, destination, sourceOffset, new SysIntX3(destinationOffset, 0), new SysIntX3(region, 1), events, newEvents); }