Jump to content

  • Log In with Google      Sign In   
  • Create Account

Why Does CreateInputLayout Work With This Descriptor?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Hornsj3   Members   -  Reputation: 191

Like
0Likes
Like

Posted 25 June 2012 - 03:35 PM

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
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
		},
	  
	};


Here's my Vertex Shader
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;
}


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.

Sponsor:

#2 MJP   Moderators   -  Reputation: 11339

Like
3Likes
Like

Posted 25 June 2012 - 07:00 PM

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.


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

#3 Hornsj3   Members   -  Reputation: 191

Like
0Likes
Like

Posted 25 June 2012 - 10:15 PM

Thanks.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS