Skip to content

Instantly share code, notes, and snippets.

View douduck08's full-sized avatar

douduck08 douduck08

View GitHub Profile
@douduck08
douduck08 / VertexShader.cpp
Last active October 19, 2021 10:19 — forked from Cody-Duncan/gist:d85740563ceea99f6619
DirectX11 Generate Input Layout from Vertex Shader using D3DReflect.
//Function Creates an input layout from the vertex shader, after compilation.
//Input layout can be reused with any vertex shaders that use the same input layout.
HRESULT CreateInputLayoutDescFromVertexShaderSignature( ID3DBlob* pShaderBlob, ID3D11Device* pD3DDevice, ID3D11InputLayout** pInputLayout, int* inputLayoutByteLength )
{
// Reflect shader info
ID3D11ShaderReflection* pVertexShaderReflection = nullptr;
HRESULT hr = S_OK;
if ( FAILED( D3DReflect( pShaderBlob->GetBufferPointer(), pShaderBlob->GetBufferSize(), IID_ID3D11ShaderReflection, (void**) &pVertexShaderReflection ) ) )
{
@douduck08
douduck08 / reflect_inputlayout.cpp
Created October 19, 2021 11:12 — forked from mobius/reflect_inputlayout.cpp
Reflect DX11 Vertex shader to create input layout
HRESULT CreateInputLayoutDescFromVertexShaderSignature( ID3DBlob* pShaderBlob, ID3D11Device* pD3DDevice, ID3D11InputLayout** pInputLayout )
{
// Reflect shader info
ID3D11ShaderReflection* pVertexShaderReflection = NULL;
if ( FAILED( D3DReflect( pShaderBlob->GetBufferPointer(), pShaderBlob->GetBufferSize(), IID_ID3D11ShaderReflection, (void**) &pVertexShaderReflection ) ) )
{
return S_FALSE;
}
// Get shader info