Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Constant buffer padding for array of structs

$
0
0
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

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>