I've read this: http://msdn.microsoft.com/en-us/library/windows/desktop/ff476898%28v=vs.85%29.aspx#Shader_Constant_Buffer but there's not much information in it. When creating a constant buffer do I have to worry about what I put in it and in what order? Do I have to stick to a multiplicity of some power of 2 in bytes or something?
You need to make sure that any variable you use within the constant buffer does not cross a 16 byte alignment boundary, or you won't be able to access it from the shader.
For example, you could have a constant buffer that looks like this:
You won't be able to read the last component (color) from your shader, since it's split between two 16 byte boundaries.
This can be solved by rearranging the order of the buffer, like this:
Or you can add some padding, like this:
The first way is preferred since it has less data to send, but sometimes you have no other choice than padding.