void DoRender()
        {    // Retrieve existing pipeline states for backup
            RawColor4 oldBlendFactor;
            int       oldSampleMask;
            int       oldStencil;
            var       oldPSBufs = context.PixelShader.GetConstantBuffers(0, 1);

            using (var oldVS = context.VertexShader.Get())
                using (var oldPS = context.PixelShader.Get())
                    using (var oldGS = context.GeometryShader.Get())
                        using (var oldSamp = context.PixelShader.GetSamplers(0, 1).FirstOrDefault())
                            using (var oldBlendState = context.OutputMerger.GetBlendState(out oldBlendFactor, out oldSampleMask))
                                using (var oldIA = context.InputAssembler.InputLayout)
                                    using (var oldDepth = context.OutputMerger.GetDepthStencilState(out oldStencil))
                                    {
                                        #region DrawingLogic
                                        // There is no input layout for this renderer
                                        context.InputAssembler.InputLayout = null;
                                        // The triangle strip input topology
                                        context.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleStrip;
                                        // Disable depth write
                                        context.OutputMerger.SetDepthStencilState(disableDepthWrite);
                                        // Set the additive blend state
                                        if (!UseLightenBlend)
                                        {
                                            context.OutputMerger.SetBlendState(blendState, null, 0xFFFFFFFF);
                                        }
                                        else
                                        {
                                            context.OutputMerger.SetBlendState(blendStateLight, Color.White, 0xFFFFFFFF);
                                        }
                                        // Assign consume particle buffer SRV to vertex shader
                                        context.VertexShader.SetShaderResource(0, particleSRVs[1]);
                                        context.VertexShader.Set(vertexShader);
                                        // Set pixel shader resources
                                        context.PixelShader.SetShaderResource(0, particleTextureSRV);
                                        context.PixelShader.SetSampler(0, linearSampler);
                                        context.PixelShader.Set(pixelShader);
                                        SetConstants();
                                        // Draw the number of quad instances stored in the
                                        // indirectArgsBuffer. The vertex shader will rely upon
                                        // the SV_VertexID and SV_InstanceID input semantics
                                        context.DrawInstancedIndirect(indirectArgsBuffer, 0);
                                        #endregion

                                        // Restore previous pipeline state
                                        context.VertexShader.Set(oldVS);
                                        context.PixelShader.SetConstantBuffers(0, oldPSBufs);
                                        context.PixelShader.Set(oldPS);
                                        context.GeometryShader.Set(oldGS);
                                        context.PixelShader.SetSampler(0, oldSamp);
                                        context.InputAssembler.InputLayout = oldIA;
                                        // Restore previous blend and depth state
                                        context.OutputMerger.SetBlendState(oldBlendState, oldBlendFactor, oldSampleMask);
                                        context.OutputMerger.SetDepthStencilState(oldDepth, oldStencil);
                                    }
        }
Ejemplo n.º 2
0
 public void Draw(DeviceContext ctx)
 {
     if (this.props.AllowIndexBuffer)
     {
         ctx.DrawIndexedInstancedIndirect(this.buffer.Buffer, this.Prop.DrawOffset);
     }
     else
     {
         ctx.DrawInstancedIndirect(this.buffer.Buffer, this.Prop.DrawOffset);
     }
 }
Ejemplo n.º 3
0
        protected override void DrawIndirectCore(DeviceBuffer indirectBuffer, uint offset, uint drawCount, uint stride)
        {
            PreDrawCommand();

            D3D11Buffer d3d11Buffer   = Util.AssertSubtype <DeviceBuffer, D3D11Buffer>(indirectBuffer);
            int         currentOffset = (int)offset;

            for (uint i = 0; i < drawCount; i++)
            {
                _context.DrawInstancedIndirect(d3d11Buffer.Buffer, currentOffset);
                currentOffset += (int)stride;
            }
        }
Ejemplo n.º 4
0
 public void Draw(DeviceContext ctx)
 {
     if (this.props.AllowIndexBuffer)
     {
         ctx.DrawIndexedInstancedIndirect(this.buffer.Buffer, this.Prop.DrawOffset);
     }
     else
     {
         ctx.DrawInstancedIndirect(this.buffer.Buffer, this.Prop.DrawOffset);
     }
 }
Ejemplo n.º 5
0
 public override void Draw(DeviceContext ctx)
 {
     ctx.DrawInstancedIndirect(this.indbuffer.Buffer, 0);
 }
Ejemplo n.º 6
0
 public void Draw(DeviceContext ctx)
 {
     ctx.DrawInstancedIndirect(this.indbuffer.Buffer, 0);
 }