Exemplo n.º 1
0
        public Buffer <T> CreateBuffer <T>(MemoryFlags flags, long size, IntPtr hostAddress)
            where T : struct
        {
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(size));
            }
            else if (size == 0)
            {
                throw new ArgumentException("Invalid buffer size.", nameof(size));
            }

            if (hostAddress == IntPtr.Zero && (flags & (MemoryFlags.UseHostPointer | MemoryFlags.CopyHostPointer)) != 0)
            {
                throw new ArgumentException("Invalid host address.", nameof(hostAddress));
            }
            if (hostAddress != IntPtr.Zero && (flags & (MemoryFlags.UseHostPointer | MemoryFlags.CopyHostPointer)) == 0)
            {
                throw new ArgumentException("Invalid host address.", nameof(hostAddress));
            }

            BufferSafeHandle handle = UnsafeNativeMethods.CreateBuffer(Handle, flags, (IntPtr)size, hostAddress);

            return(new Buffer <T>(this, handle));
        }
Exemplo n.º 2
0
        internal Buffer(Context context, Buffer <T> parent, BufferSafeHandle handle)
            : base(context, handle)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }

            _parent = parent;
        }
Exemplo n.º 3
0
        public Buffer <T> CreateSubBuffer(MemoryFlags flags, BufferRegion regionInfo)
        {
            BufferSafeHandle subBuffer = UnsafeNativeMethods.CreateSubBuffer(Handle, flags, regionInfo);

            return(new Buffer <T>(Context, this, subBuffer));
        }
Exemplo n.º 4
0
 internal Buffer(Context context, BufferSafeHandle handle)
     : base(context, handle)
 {
 }