Sign in to follow this  

Why Does CreateInputLayout Work With This Descriptor?

This topic is 2031 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I'm playing around with the Input Layout stage of the pipeline and I have a question.

Here's my Input Layout descriptor element
[CODE]
D3D11_INPUT_ELEMENT_DESC inputLayoutDesc[] =
{
{
"TEXCOORD", //Semantic name
0, //Semantic Index
DXGI_FORMAT_R32G32_FLOAT, //DXGI Format
0, //Input Slot
D3D11_APPEND_ALIGNED_ELEMENT, //Number of bytes from start of array to this element
D3D11_INPUT_PER_VERTEX_DATA, //Input Classification (we are using per vertex not per instance data)
0 //Instance data step rate, 0 for Per-Vertex data
},
{
"POSITION", //Semantic name
0, //Semantic Index
DXGI_FORMAT_R32G32B32_FLOAT, //DXGI Format
0, //Input Slot
D3D11_APPEND_ALIGNED_ELEMENT, //Number of bytes from start of array to this element
D3D11_INPUT_PER_VERTEX_DATA, //Input Classification (we are using per vertex not per instance data)
0 //Instance data step rate, 0 for Per-Vertex data
},

};
[/CODE]


Here's my Vertex Shader
[CODE]
struct VS_INPUT
{
float3 Pos : POSITION0;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION; //Screen-space position
};

PS_INPUT VS(VS_INPUT input)
{
PS_INPUT output = (PS_INPUT)0;
output.Pos = float4(input.Pos, 1.0f);

return output;
}
[/CODE]


This works fine...meaning I am able to create my input layout object and set it to the input assembler stage.

My question is, why does this work?

From what I have read the input layout has to match the vertex shader input signature. This clearly does not. It seems to me as long as it can match the Position semantic it will allow me to create the object and set it.

It seems like this should not work because it does not exactly match the expected input to the vertex shader.

Share this post


Link to post
Share on other sites
[quote name='Hornsj3' timestamp='1340660154' post='4952797']
From what I have read the input layout has to match the vertex shader input signature. This clearly does not. It seems to me as long as it can match the Position semantic it will allow me to create the object and set it.
[/quote]

That is incorrect. For the Draw call to work, the input layout has to have [i]at minimum[/i] the elements that are taken as input by the vertex shader. This means it is totally valid to have [i]more[/i] than the required elements for a vertex shader.

Share this post


Link to post
Share on other sites

This topic is 2031 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this