예제 #1
0
        /// <summary>
        /// Unmap mapped buffer, used internally by MapAsWritable()
        /// </summary>
        private void UnmapBufferToPointer()
        {
            NOpenCL.CommandQueue commandQueue = OwnerDevice.CommandQueue;

            using (commandQueue.EnqueueUnmapMemObject(Buffer, Ptr)) {
                // Nothing to do...
            }
        }
예제 #2
0
        /// <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");
            }
        }
예제 #3
0
        /// <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...
            }
        }