In one of my shaders i have a cbuffer that contains two floats like this:
cbuffer cCameraParams
{
float gfx_gCamProjA;
float gfx_gCamProjB;
}
In my C++ app code, my shader update function individually assigns the value for gfx_gCamProjA and gfxCamProjB. Both of them have different values. When i debug my shader code using the Visual Studio Graphics Diagnostics Tool, i see that gfx_gCamProjA and gfx_gCamProjB both have the same values where they should not. The debug tool shows gfx_gCamProjB being replaced by the value of gfx_gCamProjA.
I don't understand because in my c++ code gfx_gCamProjB is assigned second but shader debug shows the value of gfx_gCamProjA for both. Adding 3 floats like the code below seems to fix the problem though:
cbuffer cCameraParams
{
float gfx_gCamProjA;
float pad1;
float pad2;
float pad3;
float gfx_gCamProjB;
}
I'm using the shaderreflection to get each constant buffer variable's memory offset so i'm sure i'm using the right byte address offset to assign the value. Also, the values i'm assigning from are also floating point values(4-bytes). So i don't really know what or where i am doing wrong. Any help anyone can give is greatly appreciated.
Thanks!