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.
http://msdn.microsoft.com/en-us/library/windows/desktop/ff728724(v=vs.85).aspx
Q3. Is there a link where the rules for shader input parameter linkage is explained clearly? Or better yet, code for validating shader signatures?
D3D_NAME_INSTANCE_ID
? As for ordering, AFAIK the order of outputs and inputs has to match, so any newSV
inputs in a shader stage would indeed have to come at the end of the list. \$\endgroup\$SV_GSInstanceID
andSV_InstanceID
are the same thing or not, but they seem like distinct semantics. \$\endgroup\$