Coming from an OpenGL background, I have recently been playing around with DirectX11 and so far it's going alright. I am however getting sort of stuck on how to properly make use of constant buffers and how to use them with different shaders in an efficient way.
As far as I understand, you need to make use of the constant buffers to pass variables from code to the shaders and ideally "sort" them by update execution for efficiency. It makes sense and I get that part, I'm a bit stuck however on when I need to work with multiple different shaders. As an example:
Let's say I have 2 shaders that have some variables that needs updating every frame. Shader 1 needs 1 float and shader 2 needs 2 floats to keep it simple.
Ideally I would use one constant buffer for both of them (I guess?) as they both need to update every frame. But when you create the buffer, you need to supply its bytewidth which is different for both the shaders. How would I handle a situation like that? Is there a way to update the constant buffer or is it a thing to make the constant buffer a "max" size or something?
I can't imagine it's efficient to make a constant buffer for every shader that has a different set of variables. Perhaps there is some other way? Any info is much appreciated!