I'm trying to figure out what the rules are for linking the outputs of one shader stage to the inputs of the next. Since D3D11 does not have any error checking for linkage between shader stages, I have written some code to check them by comparing the
D3D11_SIGNATURE_PARAMETER_DESC struct from each input and matching it to an output of the previous stage. The code for checking the signatures is here.
This mostly works, except when there are certain special inputs to a stage that don't get passed from the previous stage. One example is the
SV_IsFrontFace input to the pixel shader. Another example is the
SV_PrimitiveID input to any stage after the vertex shader.
I've been googling and reading msdn.microsoft.com and so far it's totally unclear to me exactly how these special SV semantics work. In particular:
Q1. Does the ordering of them matter? Or must they occur AFTER all inputs that are passed in from the previous stage?
Q2. Some of these "special" SV values can be identified by looking at the
SystemValueType field of the
D3D11_SIGNATURE_PARAMETER_DESC. For example
SV_IsFrontFace can be identified by checking if the
SystemValueType field is
D3D_NAME_IS_FRONT_FACE. However, what about
SV_GSInstanceID? There doesn't seem to be a corresponding value in the
D3D_NAME enumeration for that.
Q3. Is there a link where the rules for shader input parameter linkage is explained clearly? Or better yet, code for validating shader signatures?