Exemplo n.º 1
0
        public static DX11RawBuffer CreateWriteable(DxDevice device, int size, RawBufferBindings binding)
        {
            BufferDescription bd = new BufferDescription()
            {
                BindFlags           = BindFlags.ShaderResource,
                CpuAccessFlags      = CpuAccessFlags.None,
                OptionFlags         = ResourceOptionFlags.BufferAllowRawViews,
                SizeInBytes         = size,
                Usage               = ResourceUsage.Default,
                StructureByteStride = 4
            };

            bd.BindFlags |= binding.WriteMode == eRawBufferWriteMode.Uav ? BindFlags.UnorderedAccess : 0;
            bd.BindFlags |= binding.AllowIndexBuffer ? BindFlags.IndexBuffer : 0;
            bd.BindFlags |= binding.AllowVertexBuffer ? BindFlags.VertexBuffer : 0;
            bd.BindFlags |= binding.WriteMode == eRawBufferWriteMode.StreamOut ? BindFlags.StreamOutput : 0;


            return(new DX11RawBuffer(device, bd, IntPtr.Zero, binding.WriteMode == eRawBufferWriteMode.Uav));
        }
Exemplo n.º 2
0
        public static DX11RawBuffer CreateImmutable(DxDevice device, DataStream initial, RawBufferBindings binding)
        {
            BufferDescription bd = new BufferDescription()
            {
                BindFlags      = BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                OptionFlags    = ResourceOptionFlags.BufferAllowRawViews,
                SizeInBytes    = (int)initial.Length,
                Usage          = ResourceUsage.Immutable
            };

            //Ignore UAV/StreamOut, since our buffer is immutable
            bd.BindFlags |= binding.AllowIndexBuffer ? BindFlags.IndexBuffer : 0;
            bd.BindFlags |= binding.AllowVertexBuffer ? BindFlags.VertexBuffer : 0;
            return(new DX11RawBuffer(device, bd, initial.DataPointer, false));
        }