I have issues with constant buffer member alignments. I have the following C++ struct:
namespace Renderer {
using DirectX::SimpleMath::Matrix;
using DirectX::SimpleMath::Vector3;
using DirectX::SimpleMath::Vector2;
struct alignas(16) CCameraMatrixBuffer
{
Matrix ViewProjection;
//--
Matrix View;
//--
Matrix Projection;
//--
Vector3 CamPositionWS;
int CameraUnderwater;
//--
Vector3 CamDirectionWS;
unsigned int RoomNumber;
//--
Vector2 ViewSize;
Vector2 InvViewSize;
//--
unsigned int Frame;
//--
};
}
and this HLSL counterpart:
cbuffer CameraMatrixBuffer : register(b0)
{
float4x4 ViewProjection;
float4x4 View;
float4x4 Projection;
float3 CamPositionWS;
int CameraUnderwater;
float3 CamDirectionWS;
unsigned int RoomNumber;
float2 ViewSize;
float2 InvViewSize;
unsigned int Frame;
};
however, when i debug the shader, CamDirectionWS shows the following:
The 1024.000f
is part of the ViewSize (the resolution).
Can someone tell me whats wrong with it?