I am confused why this code works because the lights array is not 16 bytes aligned.
struct Light
{
float4 position;
float radius;
float intensity;
// How does this work without adding
// uint _pad0, _pad1;
};
cbuffer lightData : register(b0)
{
uint lightCount;
uint _pad0;
uint _pad1;
uint _pad2;
// Shouldn't the shader be not able to read the second element in the light struct
// Because after float intensity, we need 8 more bytes to make it 16 byte aligned?
Light lights[NUM_LIGHTS];
}
This has erased everything I thought I knew about constant buffer alignment. Any explanation will help clear my head.
Thank you
↧