Hi !
I work with DX11 and memory alignment is not correct (i am under windows 64 bit), this is what I have from CPU's program (variables declarations):
__declspec(align(16))
struct VertexInfo
{
XMFLOAT4A positions;
XMFLOAT4A normals ;
XMFLOAT4A texCoords ;
};
And my input layout from cpu side :
D3D11_INPUT_ELEMENT_DESC layout[6];
layout[indexLayout].SemanticName = "POSITION";
layout[indexLayout].SemanticIndex = 0;
layout[indexLayout].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;//16 bytes
layout[indexLayout].InputSlot = 0;
layout[indexLayout].AlignedByteOffset = 0;
layout[indexLayout].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
layout[indexLayout].InstanceDataStepRate = 0;
indexLayout++ ;
layout[indexLayout].SemanticName = "NORMAL";
layout[indexLayout].SemanticIndex = 0;
layout[indexLayout].Format = DXGI_FORMAT_R16G16B16A16_FLOAT;//8 bytes
layout[indexLayout].InputSlot = 0;
layout[indexLayout].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
layout[indexLayout].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
layout[indexLayout].InstanceDataStepRate = 0;
indexLayout++ ;
layout[indexLayout].SemanticName = "COLOR";
layout[indexLayout].SemanticIndex = 0;
layout[indexLayout].Format = DXGI_FORMAT_R8G8B8A8_UNORM;//DXGI_FORMAT_R32G32B32A32_FLOAT a la place ?? //4 bytes
layout[indexLayout].InputSlot = 0;
layout[indexLayout].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
layout[indexLayout].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
layout[indexLayout].InstanceDataStepRate = 0;
indexLayout++ ;
layout[indexLayout].SemanticName = "TEXCOORD";
layout[indexLayout].SemanticIndex = 0;
layout[indexLayout].Format = DXGI_FORMAT_R8G8B8A8_UNORM;//4 bytes
layout[indexLayout].InputSlot = 0;
layout[indexLayout].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
layout[indexLayout].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
layout[indexLayout].InstanceDataStepRate = 0;
indexLayout++ ;
layout[indexLayout].SemanticName = "SV_POSITION";
layout[indexLayout].SemanticIndex = 0;
layout[indexLayout].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;//laisser à 32 ? //16 bytes
layout[indexLayout].InputSlot = 0;
layout[indexLayout].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
layout[indexLayout].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
layout[indexLayout].InstanceDataStepRate = 0;
indexLayout++ ;
layout[indexLayout].SemanticName = "POSITION";
layout[indexLayout].SemanticIndex = 1;
layout[indexLayout].Format = DXGI_FORMAT_R32G32B32A32_FLOAT; //16 bytes
layout[indexLayout].InputSlot = 0;
layout[indexLayout].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
layout[indexLayout].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
layout[indexLayout].InstanceDataStepRate = 0;
indexLayout++ ; And this is my vertex shader struct, the input paralmeters in hlsl:
struct vsIn
{
float4 position : POSITION ;
float4 normal : NORMAL ;
float4 color : COLOR0 ;
float4 texCoord : TEXCOORD0 ;
};
Somebody can help me about data alignment, it seems to be wrong...
If you need more infos/code, don't hesitate to ask me ! ![]()