Issues With Input Layout

Started by
12 comments, last by eppo 11 years, 5 months ago
An input layout describes (part of) the structure of a typeless stream of vertex data. The elements in the input layout need to match up with (at least) all the elements in a VS_INPUT structure. The VS elements can be a smaller subset of the input layout beginning at the first element, but can never contain elements unknown to the input layout.

If you want to use a single vertexbuffer and 'Position, TexCoord, Normal, Weights, Bones' as vertex shader inputs you'll have to create an input layout that refers to those elements, but contains byte offsets (D3D11_INPUT_ELEMENT_DESC.AlignedByteOffset) that skip over the unused data in the vertex stream (Tangent).
Advertisement
so again i ask, what is the point of the Semantic Name then? i thought that was a position point that signified where each element resided ( register wise ). I currently have the aligned byte offset set for each element in my array, so that element Weights is set to be 48, which is 12 float's from the beginning, which is correct given

Position is 3 floats, offset 0
TexCoord is 2 floats, offset 12
Normal is 3 floats, offset 20
Tangent is 4 floats, offset 32
Weights is 4 floats, offset 48
Bones is 4 floats, offset 64

so according to what you said, the aligned byte offset should tell the vertex shader that my Weights start at byte 48, which is what i want. but this is not whats happening
Code makes the man
from pix, the input layout is such

Input Layout 0x06ECAF40
Slot SemanticName SemanticIndex Format InputSlot AlignedByteOffset InputSlotClass InstanceDataStepRate
0 Position 0 DXGI_FORMAT_R32G32B32_FLOAT 0 0 D3D11_INPUT_PER_VERTEX_DATA 0
1 TexCoord 0 DXGI_FORMAT_R32G32_FLOAT 0 12 D3D11_INPUT_PER_VERTEX_DATA 0
2 Normal 0 DXGI_FORMAT_R32G32B32_FLOAT 0 20 D3D11_INPUT_PER_VERTEX_DATA 0
3 Tangent 0 DXGI_FORMAT_R32G32B32A32_FLOAT 0 32 D3D11_INPUT_PER_VERTEX_DATA 0
4 Weights 0 DXGI_FORMAT_R32G32B32A32_FLOAT 0 48 D3D11_INPUT_PER_VERTEX_DATA 0
5 Bones 0 DXGI_FORMAT_R32G32B32A32_FLOAT 0 64 D3D11_INPUT_PER_VERTEX_DATA 0

and the shader input signature and output signature are

// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// Position 0 xyz 0 NONE float xyz
// TexCoord 0 xy 1 NONE float xy
// Normal 0 xyz 2 NONE float xyz
// Weights 0 xyzw 3 NONE float xyzw
// Bones 0 xyzw 4 NONE float xyzw
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_Position 0 xyzw 0 POS float xyzw
// TexCoord 0 xy 1 NONE float xy
// Normal 0 xyz 2 NONE float xyz
// PositionView 0 xyz 3 NONE float
// EyeVector 0 xyz 4 NONE float
Code makes the man
The bytes offsets you've supplied specify the offsets in the vertex buffer. They have nothing to do with vertex shader input registers (these are all 4 * 4 bytes floats). For example, the format DXGI_FORMAT_R8_UNORM is stored as an 8 bits integer, but expands to a 32 bits float when written into a VS register. So, as there is no direct relation between byte sizes, the IA uses semantics to couple values.

If the vertex shader expects the fourth element to have a semantic 'Weights', then the input layout should have an identical fourth element. So in this case you need to throw the Tangent semantic out of the input layout and create a separate layout for the normal mapped case.

This topic is closed to new replies.

Advertisement