Calling CreateInputLayout
creates an Input Layout that works only for a shader with the exact same Semantic locations using a single buffer for vertex data.
For example:
VSInput1
{
float3 Position : POSITION;
float2 TexCoord0 : TEXCOORD0;
float3 Normal : NORMAL;
};
does not translate over correctly to:
VSInput2
{
float3 Position : POSITION;
float3 Normal : NORMAL;
};
i.e., while using the shader attached to VSInput2
and Input Layout from VSInput1
, TEXCOORD0
from VSInput1
will be used in the place of NORMAL
from VSInput2
despite using the Input Layout from VSInput1
stating that NORMAL
is after TEXCOORD0
.
This behavior indicates that CreateInputLayout
only uses Semantics to determine if a shader possesses them, and otherwise disregards variable location in memory.
This is horrible because it would require one of these two options:
1) Create a new Input Layout using the compiled shader code of the VSInput2
shader.
This would take more memory to create a new Input Layout for each buffer requiring the use of multiple shaders (taking into consideration shadows). OpenGL handles the noncontiguous memory locations with ease by determining the location where in the buffer the data should reside. Apparently, DX11 does not.
2) Break the vertex data down into separate buffers.
This would be slower than having the memory in order, i.e. jumping to a location just to return to the next location in the previous buffer.
From MS website:
the data may be reinterpreted when read from a register
Is there a way to ensure the register is interpreted in the manner required above without having to write the shader in asm?
If asm is required, then how would the Input Layout be created?