public void Setup(ID3D11Device device, ID3D11DeviceContext context) { if (!m_vertexAttributes.Any()) { return; } if (!m_inputLayout) { var hr = device.CreateVertexShader(m_vs_blob.GetBufferPointer(), m_vs_blob.GetBufferSize(), null, out m_vs); hr.ThrowIfFailed(); hr = device.CreatePixelShader(m_ps_blob.GetBufferPointer(), m_ps_blob.GetBufferSize(), null, out m_ps); hr.ThrowIfFailed(); hr = device.CreateInputLayout(ref m_layout[0], (uint)m_layout.Length, m_vs_blob.GetBufferPointer(), m_vs_blob.GetBufferSize(), out m_inputLayout); hr.ThrowIfFailed(); } // setup shader pipeline Span <IntPtr> classes = stackalloc IntPtr[] { }; context.VSSetShader(m_vs, ref MemoryMarshal.GetReference(classes), (uint)classes.Length); context.PSSetShader(m_ps, ref MemoryMarshal.GetReference(classes), (uint)classes.Length); context.IASetInputLayout(m_inputLayout); }
public static IComObject <ID3D11PixelShader> CreatePixelShader(this ID3D11Device device, ID3D10Blob blob, ID3D11ClassLinkage classLinkage = null) { if (device == null) { throw new ArgumentNullException(nameof(device)); } if (blob == null) { throw new ArgumentNullException(nameof(blob)); } device.CreatePixelShader(blob.GetBufferPointer(), blob.GetBufferSize(), classLinkage, out var shader).ThrowOnError(); return(new ComObject <ID3D11PixelShader>(shader)); }
public static IComObject <ID3D11InputLayout> CreateInputLayout(this ID3D11Device device, D3D11_INPUT_ELEMENT_DESC[] inputElements, ID3D10Blob blob) { if (device == null) { throw new ArgumentNullException(nameof(device)); } if (blob == null) { throw new ArgumentNullException(nameof(blob)); } if (inputElements == null) { throw new ArgumentNullException(nameof(inputElements)); } if (inputElements.Length == 0) { throw new ArgumentException(null, nameof(inputElements)); } device.CreateInputLayout(inputElements, inputElements.Length, blob.GetBufferPointer(), blob.GetBufferSize(), out var layout).ThrowOnError(); return(new ComObject <ID3D11InputLayout>(layout)); }