public void GLUnmapBufferObject(UInt32 bufferId)
 {
     CudaUtil.Call(CudaMem.cuGLUnmapBufferObject(bufferId));
     ptr          = DevicePtr2D.Zero;
     widthInBytes = 0;
     height       = 0;
 }
Beispiel #2
0
        /// <summary>
        /// Allocates a 2D block of memory, and returns a pointer pointing to it. Rows are NOT padded,
        /// and may not meet the hardware's alignment requirements.
        /// </summary>
        /// <param name="widthInBytes">The number of bytes to allocate for each row.</param>
        /// <param name="height">The number of rows to allocate</param>
        /// <returns>A pointer to the new block</returns>
        public static DevicePtr2D AllocRaw(uint widthInBytes, uint height)
        {
            DevicePtr2D result = new DevicePtr2D();

            result.pitch = widthInBytes;

            CudaUtil.Call(CudaMem.cuMemAlloc(out result.ptr, widthInBytes * height));
            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Copies data from host memory to device memory. No size checks are performed, it is
        /// up to the programmer to ensure the destination is large enough to hold the data.
        /// </summary>
        /// <param name="src">The source buffer</param>
        /// <param name="dest">The destination pointer</param>
        /// <param name="widthInBytes">The size of each row in bytes</param>
        /// <param name="height">The number of rows</param>
        public static void CopyRaw2D(IntPtr srcPtr, DevicePtr2D dest, IntPtr widthInBytes, IntPtr height)
        {
            if (srcPtr == IntPtr.Zero || dest == DevicePtr2D.Zero)
            {
                throw new NullPointerException();
            }

            CudaUtil.Call(CudaMem.memcpy2DHelper(
                              MemoryType.Host, 0, 0, srcPtr, (uint)widthInBytes,
                              MemoryType.Device, 0, 0, (IntPtr)dest.ptr, (uint)dest.Pitch,
                              (uint)widthInBytes, (uint)height)
                          );
        }
 internal DeviceBuffer2D(DevicePtr2D ptr, uint widthInBytes, uint height)
 {
     this.ptr          = ptr;
     this.widthInBytes = widthInBytes;
     this.height       = height;
 }