Sign in to follow this  
e5431

DX10: HLSL semantic must be the same?

Recommended Posts

Hi. Here is a piece of code from Tutorial 10. Do semantic names have to be the same? I mean, Tex parameter in the first structure has marked as TEXCOORD0 and the same one in the second has TEXCOORD1 semantic name. Isn't more common to use the same semantic for the same values? And another question: why it works fine? :) struct VS_INPUT { float3 Pos : POSITION; //position float3 Norm : NORMAL; //normal float2 Tex : TEXCOORD0; //texture coordinate }; struct PS_INPUT { float4 Pos : SV_POSITION; float3 Norm : TEXCOORD0; float2 Tex : TEXCOORD1; };

Share this post


Link to post
Share on other sites
If you use the debug layer, I'm guessing you'll see errors/warnings about mismatches. The reason it works is because D3D10 does shader linkage based on registers, not on semantics. The semantics are just there to separate system semantics from user semantics and to assist the user to make sure their shader signatures line up correctly (which is only checked in the debug layer).

Share this post


Link to post
Share on other sites
Semantics are used to perform matching - the exact name of the semantic doesn't matter unless it's a system generated or interpreted value (starting SV_).

Your code fragments are showing two input declarations; what you actually want to match is the output of the VS and the input of the PS - it's connecting stages that must have matching linkage and its perfectly possible for the input to one stage to be quite different to the input into the next stage.

hth
Jack

Share this post


Link to post
Share on other sites

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