0

Does input order for a SM 4.0 vertex shader matter?

e.g. is

struct App2VS
{
    float3 position : POSITION;
    float4 color : COLOR0;
    float3 normal : NORMAL;
        ...
};

equivalent to

struct App2VS
{
    float4 color : COLOR0;
    float3 position : POSITION;
    float3 normal : NORMAL;
        ...
};
jameszhao00
  • 7,213
  • 15
  • 62
  • 112

1 Answers1

2

No it shouldn't matter. The mapping information is performed by the Input Layout.

Essentially the input layout maps a given struct element to a specific input "register". These input registers are then used to load the struct used by HLSL. The HLSL struct is not a real memory mapping as those input register (ie POSITION or COLOR0) are not actual memory locations.

Goz
  • 61,365
  • 24
  • 124
  • 204
  • Thought so. Do you know in what situations a different ordering could cause different behaviors though? It works with {position, color, } in the HLSL but if I change it to {color, position, } in the HLSL color values are used as position. (No changes in the C++ input layout/vertex declaration) – jameszhao00 Dec 22 '10 at 20:49
  • Fixed it... I was unknowingly sharing an InputLayout :( – jameszhao00 Dec 22 '10 at 22:51