/// <summary> /// Map buffer as writable, used internally by MapAsWritable() /// </summary> private void MapBufferToPointerWritable() { NOpenCL.CommandQueue commandQueue = OwnerDevice.CommandQueue; IntPtr tmpPtr; using (commandQueue.EnqueueMapBuffer(Buffer, true, NOpenCL.MapFlags.Read | NOpenCL.MapFlags.Write, 0, (long)Buffer.Size, out tmpPtr)) { // Nothing to do... } if (Ptr != tmpPtr) { throw new InvalidOperationException("EnqueueMapBuffer() failed to return original pointer"); } }
/// <summary> /// Copy memory from target device back to source pointer /// </summary> public void Synchronize() { NOpenCL.CommandQueue commandQueue = OwnerDevice.CommandQueue; IntPtr tmpPtr; using (commandQueue.EnqueueMapBuffer(Buffer, true, NOpenCL.MapFlags.Read, 0, (long)Buffer.Size, out tmpPtr)) { // Nothing to do... } if (Ptr != tmpPtr) { throw new InvalidOperationException("EnqueueMapBuffer() failed to return original pointer"); } using (commandQueue.EnqueueUnmapMemObject(Buffer, tmpPtr)) { // Nothing to do... } }