Beispiel #1
0
        public BaseIndirectBuffer(DxDevice device, T args)
        {
            this.device = device;

            int size = Marshal.SizeOf(args);

            BufferDescription bd = new BufferDescription();

            bd.Usage = ResourceUsage.Default;
            bd.StructureByteStride = 0;
            bd.SizeInBytes         = size;
            bd.CpuAccessFlags      = CpuAccessFlags.None;
            bd.BindFlags           = BindFlags.None;
            bd.OptionFlags         = ResourceOptionFlags.DrawIndirectArguments;

            DataStream dsb = new DataStream(size, false, true);

            dsb.Position = 0;
            dsb.Write <T>(args);
            dsb.Position = 0;

            this.ArgumentBuffer = new SharpDX.Direct3D11.Buffer(device.Device, dsb, bd);
            dsb.Dispose();

            this.WriteBuffer = DX11StructuredBuffer.CreateWriteable(device, size / 4, 4);
        }
Beispiel #2
0
        public DX11StructuredBuffer CopyToStructuredBuffer(RenderContext context)
        {
            if (this.format != SharpDX.DXGI.Format.R32_UInt)
            {
                throw new Exception("Only Large indices formats supported");
            }
            DX11StructuredBuffer sb = DX11StructuredBuffer.CreateWriteable <uint>(this.device, this.IndicesCount);

            context.Context.CopyResource(this.Buffer, sb.Buffer);
            return(sb);
        }