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)); }
internal Buffer(Context context, Buffer <T> parent, BufferSafeHandle handle) : base(context, handle) { if (parent == null) { throw new ArgumentNullException(nameof(parent)); } _parent = parent; }
public Buffer <T> CreateSubBuffer(MemoryFlags flags, BufferRegion regionInfo) { BufferSafeHandle subBuffer = UnsafeNativeMethods.CreateSubBuffer(Handle, flags, regionInfo); return(new Buffer <T>(Context, this, subBuffer)); }
internal Buffer(Context context, BufferSafeHandle handle) : base(context, handle) { }