예제 #1
0
        /// <summary>
        /// Copy a float array to a buffer.
        /// </summary>
        ///
        /// <param name="source">The array.</param>
        /// <param name="targetBuffer">The buffer.</param>
        public void Array2Buffer(float[] source, ComputeBuffer <float> targetBuffer)
        {
            GCHandle arrCHandle = GCHandle.Alloc(source, GCHandleType.Pinned);

            commands.Write(targetBuffer, true, 0, source.Length, arrCHandle.AddrOfPinnedObject(), null);
            arrCHandle.Free();
        }
예제 #2
0
 /// <summary>Writes variable to device</summary>
 /// <param name="Values">Values to write to device</param>
 /// <param name="CQ">Command queue to use</param>
 /// <param name="BlockingWrite">TRUE to return only after completed writing.</param>
 /// <param name="events">OpenCL Event associated to this operation</param>
 public void WriteToDevice(byte[] Values, ComputeCommandQueue CQ, bool BlockingWrite, ICollection<ComputeEventBase> events)
 {
     if (Values.Length != OriginalVarLength) throw new Exception("Values length should be the same as allocated length");
     if (CreatedFromGLBuffer && (!AcquiredInOpenCL)) throw new Exception("Attempting to use a variable created from OpenGL buffer without acquiring. Should use CLGLInteropFunctions to properly acquire and release these variables");
     unsafe
     {
         fixed (void* ponteiro = Values)
         {
             CQ.Write<byte>((ComputeBuffer<byte>)VarPointer, BlockingWrite, 0, Values.Length, (IntPtr)ponteiro, events);
         }
     }
 }
예제 #3
0
 /// <summary>Writes variable to device</summary>
 /// <param name="Values">Values to write to device</param>
 /// <param name="CQ">Command queue to use</param>
 /// <param name="BlockingWrite">TRUE to return only after completed writing.</param>
 /// <param name="events">OpenCL Event associated to this operation</param>
 public void WriteToDevice(int[] Values, ComputeCommandQueue CQ, bool BlockingWrite, ICollection<ComputeEventBase> events)
 {
     if (Values.Length != OriginalVarLength) throw new Exception("Values length should be the same as allocated length");
     unsafe
     {
         fixed (void* ponteiro = Values)
         {
             CQ.Write<int>((ComputeBuffer<int>)VarPointer, BlockingWrite, 0, Values.Length, (IntPtr)ponteiro, events);
         }
     }
 }
예제 #4
0
 private unsafe void WriteToDevice(void* p, ComputeCommandQueue CQ, bool BlockingWrite, ICollection<ComputeEventBase> events)
 {
     CQ.Write((ComputeImage)VarPointer, BlockingWrite, new SysIntX3(0, 0, 0), new SysIntX3(width, height, 1), 0, 0, new IntPtr(p), events);
 }
예제 #5
0
 private unsafe void WriteToDevice(void* p, ComputeCommandQueue CQ, bool BlockingWrite, ICollection<ComputeEventBase> events)
 {
     if (CreatedFromGLBuffer && (!AcquiredInOpenCL)) throw new Exception("Attempting to use a variable created from OpenGL buffer without acquiring. Should use CLGLInteropFunctions to properly acquire and release these variables");
     CQ.Write((ComputeImage)VarPointer, BlockingWrite, new SysIntX3(0, 0, 0), new SysIntX3(width, height, 1), 0, 0, new IntPtr(p), events);
 }