/// <summary> /// Enqueues a command to map a part of a <see cref="OpenCLImage"/> into the host address space. /// </summary> /// <param name="image"> The <see cref="OpenCLImage"/> to map. </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="flags"> A list of properties for the mapping mode. </param> /// <param name="offset"> The <paramref name="image"/> element position where mapping starts. </param> /// <param name="region"> The region of elements to map. </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> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param> /// <remarks> If <paramref name="blocking"/> is <c>true</c> this method will not return until the command completes. If <paramref name="blocking"/> is <c>false</c> this method will return immediately after the command is enqueued. </remarks> public IntPtr Map(OpenCLImage image, bool blocking, OpenCLMemoryMappingFlags flags, SysIntX3 offset, SysIntX3 region, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null) { int eventWaitListSize; CLEventHandle[] eventHandles = OpenCLTools.ExtractHandles(events, out eventWaitListSize); CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null; IntPtr mappedPtr, rowPitch, slicePitch; OpenCLErrorCode error = OpenCLErrorCode.Success; mappedPtr = CL10.EnqueueMapImage(Handle, image.Handle, blocking, flags, ref offset, ref region, out rowPitch, out slicePitch, eventWaitListSize, eventHandles, newEventHandle, out error); OpenCLException.ThrowOnError(error); if (newEvents != null) { lock (newEvents) { newEvents.Add(new OpenCLEvent(newEventHandle[0], this)); } } return(mappedPtr); }
/// <summary> /// Enqueues a command to read data from a <see cref="OpenCLImage"/>. /// </summary> /// <param name="source"> The <see cref="OpenCLImage"/> to read from. </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="offset"> The <paramref name="source"/> element position where reading starts. </param> /// <param name="region"> The region of elements to read. </param> /// <param name="rowPitch"> The <see cref="OpenCLImage.RowPitch"/> of <paramref name="source"/> or 0. </param> /// <param name="slicePitch"> The <see cref="OpenCLImage.SlicePitch"/> of <paramref name="source"/> or 0. </param> /// <param name="destination"> A pointer to a preallocated memory area to read the data into. </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> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param> /// <remarks> If <paramref name="blocking"/> is <c>true</c> this method will not return until the command completes. If <paramref name="blocking"/> is <c>false</c> this method will return immediately after the command is enqueued. </remarks> public void Read(OpenCLImage source, bool blocking, SysIntX3 offset, SysIntX3 region, long rowPitch, long slicePitch, IntPtr destination, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null) { int eventWaitListSize; CLEventHandle[] eventHandles = OpenCLTools.ExtractHandles(events, out eventWaitListSize); CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null; OpenCLErrorCode error = CL10.EnqueueReadImage(Handle, source.Handle, blocking, ref offset, ref region, new IntPtr(rowPitch), new IntPtr(slicePitch), destination, eventWaitListSize, eventHandles, newEventHandle); OpenCLException.ThrowOnError(error); if (newEvents != null) { lock (newEvents) { newEvents.Add(new OpenCLEvent(newEventHandle[0], this)); } } }
/// <summary> /// Enqueues a command to copy data between <see cref="OpenCLImage"/>s. /// </summary> /// <param name="source"> The <see cref="OpenCLImage"/> to copy from. </param> /// <param name="destination"> The <see cref="OpenCLImage"/> 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> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param> public void Copy(OpenCLImage source, OpenCLImage destination, SysIntX3 sourceOffset, SysIntX3 destinationOffset, SysIntX3 region, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null) { int eventWaitListSize; CLEventHandle[] eventHandles = OpenCLTools.ExtractHandles(events, out eventWaitListSize); CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null; OpenCLErrorCode error = CL10.EnqueueCopyImage(Handle, source.Handle, destination.Handle, ref sourceOffset, ref destinationOffset, ref region, eventWaitListSize, eventHandles, newEventHandle); OpenCLException.ThrowOnError(error); if (newEvents != null) { lock (newEvents) { newEvents.Add(new OpenCLEvent(newEventHandle[0], this)); } } }
/// <summary> /// Enqueues a command to write data to a <see cref="OpenCLImage"/>. /// </summary> /// <param name="destination"> The <see cref="OpenCLImage"/> 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="rowPitch"> The <see cref="OpenCLImage.RowPitch"/> of <paramref name="destination"/> or 0. </param> /// <param name="slicePitch"> The <see cref="OpenCLImage.SlicePitch"/> of <paramref name="destination"/> or 0. </param> /// <param name="source"> The content written to the <see cref="OpenCLImage"/>. </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> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param> /// <remarks> If <paramref name="blocking"/> is <c>true</c> this method will not return until the command completes. If <paramref name="blocking"/> is <c>false</c> this method will return immediately after the command is enqueued. </remarks> public void Write(OpenCLImage destination, bool blocking, SysIntX3 destinationOffset, SysIntX3 region, long rowPitch, long slicePitch, IntPtr source, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { int eventWaitListSize; CLEventHandle[] eventHandles = OpenCLTools.ExtractHandles(events, out eventWaitListSize); CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null; OpenCLErrorCode error = CL10.EnqueueWriteImage(Handle, destination.Handle, blocking, ref destinationOffset, ref region, new IntPtr(rowPitch), new IntPtr(slicePitch), source, eventWaitListSize, eventHandles, newEventHandle); OpenCLException.ThrowOnError(error); if (newEvents != null) { lock (newEvents) { newEvents.Add(new OpenCLEvent(newEventHandle[0], this)); } } }
/// <summary> /// Enqueues a command to map a part of a <see cref="OpenCLImage"/> into the host address space. /// </summary> /// <param name="image"> The <see cref="OpenCLImage"/> to map. </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="flags"> A list of properties for the mapping mode. </param> /// <param name="offset"> The <paramref name="image"/> element position where mapping starts. </param> /// <param name="region"> The region of elements to map. </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> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param> /// <remarks> If <paramref name="blocking"/> is <c>true</c> this method will not return until the command completes. If <paramref name="blocking"/> is <c>false</c> this method will return immediately after the command is enqueued. </remarks> public IntPtr Map(OpenCLImage image, bool blocking, OpenCLMemoryMappingFlags flags, SysIntX3 offset, SysIntX3 region, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { int eventWaitListSize; CLEventHandle[] eventHandles = OpenCLTools.ExtractHandles(events, out eventWaitListSize); CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null; IntPtr mappedPtr, rowPitch, slicePitch; OpenCLErrorCode error = OpenCLErrorCode.Success; mappedPtr = CL10.EnqueueMapImage(Handle, image.Handle, blocking, flags, ref offset, ref region, out rowPitch, out slicePitch, eventWaitListSize, eventHandles, newEventHandle, out error); OpenCLException.ThrowOnError(error); if (newEvents != null) { lock (newEvents) { newEvents.Add(new OpenCLEvent(newEventHandle[0], this)); } } return mappedPtr; }
/// <summary> /// Enqueues a command to copy data between <see cref="OpenCLImage"/>s. /// </summary> /// <param name="source"> The <see cref="OpenCLImage"/> to copy from. </param> /// <param name="destination"> The <see cref="OpenCLImage"/> 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> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param> public void Copy(OpenCLImage source, OpenCLImage destination, SysIntX3 sourceOffset, SysIntX3 destinationOffset, SysIntX3 region, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { int eventWaitListSize; CLEventHandle[] eventHandles = OpenCLTools.ExtractHandles(events, out eventWaitListSize); CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null; OpenCLErrorCode error = CL10.EnqueueCopyImage(Handle, source.Handle, destination.Handle, ref sourceOffset, ref destinationOffset, ref region, eventWaitListSize, eventHandles, newEventHandle); OpenCLException.ThrowOnError(error); if (newEvents != null) { lock (newEvents) { newEvents.Add(new OpenCLEvent(newEventHandle[0], this)); } } }
/// <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="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, OpenCLImage destination, bool blocking, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { Write(destination, blocking, new SysIntX3(), new SysIntX3(destination.Width, destination.Height, (destination.Depth == 0) ? 1 : destination.Depth), 0, 0, source, events, newEvents); }
/// <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="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(OpenCLImage source, IntPtr destination, bool blocking, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { Read(source, blocking, new SysIntX3(), new SysIntX3(source.Width, source.Height, (source.Depth == 0) ? 1 : source.Depth), 0, 0, destination, 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="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(OpenCLImage source, OpenCLBufferBase destination, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { Copy(source, destination, new SysIntX3(), 0, new SysIntX3(source.Width, source.Height, (source.Depth == 0) ? 1 : source.Depth), events, newEvents); }
/// <summary> /// Enqueues a command to copy data from a buffer to an image. /// </summary> /// <typeparam name="T"> The type of data in <paramref name="source"/>. </typeparam> /// <param name="source"> The buffer to copy from. </param> /// <param name="destination"> The image to copy to. </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 CopyBufferToImage(OpenCLBufferBase source, OpenCLImage destination, IReadOnlyList<OpenCLEventBase> events = null, IList<OpenCLEventBase> newEvents = null) { Copy(source, destination, 0, new SysIntX3(), new SysIntX3(destination.Width, destination.Height, (destination.Depth == 0) ? 1 : destination.Depth), events, newEvents); }