Jump to content
  • Advertisement
Sign in to follow this  
DarkRonin

DX11 Shader signature question

This topic is 447 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

Hi Guys,

Just wondering if you could assist me with some basic theory here.

Why is it that CreateInputLayout() requires both the input description and shader input signature.

Quote

D3D11_INPUT_ELEMENT_DESC inputDescP[] = { "POSITION", 0 ,DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 };
        
const BYTE signature_fvf_xy[] = { // removed for sake of post size };

ID3D11InputLayout* inputLayoutXY;

int result = test->CreateInputLayout(inputDescP, 1, signature_fvf_xy, sizeof(signature_fvf_xy), &inputLayoutXY);

Seems like a redundant operation.

If the input signature is allready defined by the coder, then why is the input signature of the shader needed as well (if it has to be the same anyway)?

As far as I can tell, there is no way to successfully create an input layout with the input description alone. Why the requirement of doubling up on the same information?

Thanks in advance :)

Edited by lonewolff
Sorry guys. Browser wont allow me to format the post correctly.

Share this post


Link to post
Share on other sites
Advertisement

(Sorry guys. Browser wont allow me to format the post correctly. No matter how I edit this thing, I can't separate the last paragraphs out of the code. Tried Chrome and IE)

Share this post


Link to post
Share on other sites

The shader signature defines a structure that will be consumed by the vertex shader code. The input description defines a structure that exists across a set of buffers in memory. The IA stage is a translater that reads one format from memory and rearranges it into the format expected by the VS code. 

You can't translate from one format to another unless you know what both the formats are.

Share this post


Link to post
Share on other sites

Validation.

Because different states can be specified in isolation from each other, part of an API's job is to validate the current combination of states in order to ensure that it's OK to draw with them.

Traditionally this could only be done at run time because older API's had no way of knowing what the final combination of states used for a draw call would be until the draw call is made.

Direct3D 10 moved a lot of validation from run time to object creation time, and Direct3D 11 continued with this. One place you see it is in the use of immutable state objects, gathering groups of related states used at different parts of the pipeline together. Another place you see it is in the tight coupling of input layouts with vertex shaders.

Think back to Direct3D 9 and try to imagine how vertex declarations might work. What happens if the vertex declaration provides an input that the vertex shader doesn't consume? What happens if the vertex shader consumes an input that the declaration doesn't provide? How are format conversions worked out? There are rules for all of these things, but because the API doesn't have a way to know which combination of declaration and shader will be used together it can't work things out until run time, typically when you make a draw call.

Under Direct3D 10+ because they're linked at creation time the validation can also be done at creation time, meaning that this step can be skipped at run time and run time gets faster.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!