/// <summary> /// Binds the states. /// </summary> /// <param name="context">The context.</param> /// <param name="type">The type.</param> public void BindStates(DeviceContextProxy context, StateType type) { if (type == StateType.None) { return; } if (EnumHelper.HasFlag(type, StateType.BlendState)) { context.SetBlendState(BlendState); } if (EnumHelper.HasFlag(type, StateType.DepthStencilState)) { context.SetDepthStencilState(DepthStencilState); } if (EnumHelper.HasFlag(type, StateType.RasterState)) { context.SetRasterState(RasterState); } }
public void BindStates(DeviceContextProxy context, StateType type) { if (type == StateType.None || IsNULL) { return; } if (EnumHelper.HasFlag(type, StateType.BlendState)) { context.SetBlendState(BlendState, BlendFactor, SampleMask); } if (EnumHelper.HasFlag(type, StateType.DepthStencilState)) { context.SetDepthStencilState(DepthStencilState, StencilRef); } if (EnumHelper.HasFlag(type, StateType.RasterState)) { context.SetRasterState(RasterState); } }
/// <summary> /// Called when [render]. /// </summary> /// <param name="context">The context.</param> /// <param name="deviceContext">The device context.</param> protected override void OnRender(RenderContext context, DeviceContextProxy deviceContext) { perFrameCB.UploadDataToBuffer(deviceContext, ref FrameVariables); // Clear binding updatePass.ComputeShader.BindUAV(deviceContext, currentStateSlot, null); updatePass.ComputeShader.BindUAV(deviceContext, newStateSlot, null); // Render existing particles renderPass.BindShader(deviceContext); renderPass.BindStates(deviceContext, StateType.RasterState | StateType.DepthStencilState); renderPass.VertexShader.BindTexture(deviceContext, renderStateSlot, BufferProxies[0]); renderPass.PixelShader.BindTexture(deviceContext, textureSlot, textureView); renderPass.PixelShader.BindSampler(deviceContext, samplerSlot, textureSampler); deviceContext.InputLayout = VertexLayout; int firstSlot = 0; InstanceBuffer?.AttachBuffer(deviceContext, ref firstSlot); deviceContext.SetBlendState(blendState, blendFactor, sampleMask); deviceContext.DrawInstancedIndirect(particleCountGSIABuffer.Buffer, 0); InvalidateRenderer();//Since particle is running all the time. Invalidate once finished rendering }