internal NativeBuffer(Device device, BufferTypeEnum bufferType, int length) { this.device = device; this.BufferType = bufferType; Length = length; CreateBuffer(); }
internal NativeBuffer(IDevice device, BufferTypeEnum bufferType, ReadOnlySpan <T> data, BufferInternalFormat internalFormat) { this.device = device; this.internalFormat = internalFormat; this.BufferType = bufferType; GlBufferType = BufferTypeToBindFlags(bufferType); CreateBufferWithData(data); }
internal NativeBuffer(IDevice device, BufferTypeEnum bufferType, int length, BufferInternalFormat internalFormat) { this.device = device; this.internalFormat = internalFormat; this.BufferType = bufferType; GlBufferType = BufferTypeToBindFlags(bufferType); CreateBuffer(); }
private static BindFlags BufferTypeToBindFlags(BufferTypeEnum bufferType) { switch (bufferType) { case BufferTypeEnum.StructuredBuffer: case BufferTypeEnum.StructuredBufferPixelOnly: case BufferTypeEnum.StructuredBufferVertexOnly: return(BindFlags.ShaderResource | BindFlags.UnorderedAccess); case BufferTypeEnum.Vertex: return(BindFlags.VertexBuffer); case BufferTypeEnum.Index: return(BindFlags.IndexBuffer); case BufferTypeEnum.ConstPixel: case BufferTypeEnum.ConstVertex: return(BindFlags.ConstantBuffer); default: throw new Exception("Unsupported buffer type"); } }
public NativeBuffer <T> CreateBuffer <T>(BufferTypeEnum bufferType, ReadOnlySpan <T> data, BufferInternalFormat format = BufferInternalFormat.None) where T : unmanaged { return(new NativeBuffer <T>(device, bufferType, data, format)); }
// Safe multithread call public NativeBuffer <T> CreateBuffer <T>(BufferTypeEnum bufferType, int size, BufferInternalFormat format = BufferInternalFormat.None) where T : unmanaged { return(new NativeBuffer <T>(device, bufferType, size, format)); }
public NativeBuffer <T> CreateBuffer <T>(BufferTypeEnum bufferType, T[] data) where T : struct { return(new NativeBuffer <T>(device, bufferType, data)); }
// Safe multithread call public NativeBuffer <T> CreateBuffer <T>(BufferTypeEnum bufferType, int size) where T : struct { return(new NativeBuffer <T>(device, bufferType, size)); }
public NativeBuffer <T> CreateBuffer <T>(BufferTypeEnum bufferType, ReadOnlySpan <T> data, BufferInternalFormat format = BufferInternalFormat.None) where T : unmanaged => Device.CreateBuffer <T>(bufferType, data, format);
public NativeBuffer <T> CreateBuffer <T>(BufferTypeEnum bufferType, int size) where T : unmanaged => Device.CreateBuffer <T>(bufferType, size);