public void Apply(SharpDX.Direct3D11.DeviceContext context) { if (VertexShader != null) { if (VertexShader.ConstantBufferSlots != null) { VertexShader.ConstantBufferSlots .Where(slot => slot.BackingStore != null && slot.BackingStore.Buffer != null) .ForEach(slot => { var data = new SharpDX.DataBox(slot.BackingStore.Buffer.Ptr); context.UpdateSubresource(data, slot.Buffer); context.VertexShader.SetConstantBuffer(slot.Index, slot.Buffer); }); } } if (GeometryShader != null) { if (GeometryShader.ConstantBufferSlots != null) { GeometryShader.ConstantBufferSlots .Where(slot => slot.BackingStore != null && slot.BackingStore.Buffer != null) .ForEach(slot => { var data = new SharpDX.DataBox(slot.BackingStore.Buffer.Ptr); context.UpdateSubresource(data, slot.Buffer); context.GeometryShader.SetConstantBuffer(slot.Index, slot.Buffer); }); } } if (PixelShader != null) { if (PixelShader.ConstantBufferSlots != null) { PixelShader.ConstantBufferSlots .Where(slot => slot.BackingStore != null && slot.BackingStore.Buffer != null) .ForEach(slot => { var data = new SharpDX.DataBox(slot.BackingStore.Buffer.Ptr); context.UpdateSubresource(data, slot.Buffer); context.PixelShader.SetConstantBuffer(slot.Index, slot.Buffer); }); } } /* // set textures Textures.ForEach((t, i) => context.PixelShader.SetShaderResource(i, t.ShaderResourceView)); // sampler Samplers.ForEach((s, i) => context.PixelShader.SetSampler(i, s.State)); */ }