Ejemplo n.º 1
0
        internal NativeBuffer(Device device, BufferTypeEnum bufferType, int length)
        {
            this.device     = device;
            this.BufferType = bufferType;

            Length = length;
            CreateBuffer();
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 internal NativeBuffer(IDevice device, BufferTypeEnum bufferType, int length, BufferInternalFormat internalFormat)
 {
     this.device         = device;
     this.internalFormat = internalFormat;
     this.BufferType     = bufferType;
     GlBufferType        = BufferTypeToBindFlags(bufferType);
     CreateBuffer();
 }
Ejemplo n.º 4
0
        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");
            }
        }
Ejemplo n.º 5
0
 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));
 }
Ejemplo n.º 6
0
 // 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));
 }
Ejemplo n.º 7
0
 public NativeBuffer <T> CreateBuffer <T>(BufferTypeEnum bufferType, T[] data) where T : struct
 {
     return(new NativeBuffer <T>(device, bufferType, data));
 }
Ejemplo n.º 8
0
 // Safe multithread call
 public NativeBuffer <T> CreateBuffer <T>(BufferTypeEnum bufferType, int size) where T : struct
 {
     return(new NativeBuffer <T>(device, bufferType, size));
 }
Ejemplo n.º 9
0
 public NativeBuffer <T> CreateBuffer <T>(BufferTypeEnum bufferType, ReadOnlySpan <T> data, BufferInternalFormat format = BufferInternalFormat.None) where T : unmanaged => Device.CreateBuffer <T>(bufferType, data, format);
Ejemplo n.º 10
0
 public NativeBuffer <T> CreateBuffer <T>(BufferTypeEnum bufferType, int size) where T : unmanaged => Device.CreateBuffer <T>(bufferType, size);