Hello,
my shader scrambles the values of my constbuffer.
i have a struct like:
struct CameraConstData
{
urd::Matrix projection; // 64 ( 16 floats)
urd::Matrix view; // 64 ( 16 floats)
urd::Vec3 viewPosition; // 12 ( 3 floats)
urd::Vec3 viewDir; // 12 ( 3 floats)
// 104 bytes (26 * 4)
float offset[26];
};
Displaying the constbuffer in the gpu debugger looks fine. 2 matrices and the 2 vectors at the end.
[attachment=29125:Unbenannt.PNG]
Now if i visualize the viewDir vector in the shader like:
// desc heap cbv
cbuffer CameraConstBuffer : register(b0)
{
float4x4 projectionMatrix;
float4x4 viewMatrix;
float3 viewPos;
float3 viewDir;
}
// in pixel shader
float3 vpos = (viewDir); float value = vpos.x; // uses the passed y value
//float value = vpos.y; // uses the passed z value
color = float4(value, value, value, 1.0);
viewDir.x is the y value of the view direction
viewDir.y is the z value of the view direction
and viewDir.z is 0.0
looks like it all got shifted back one position. and its reading buffer index 36-38 instead of 35 - 37!
if i use float viewPos[2] to shift back one offset, it still doesnt work. so its just reading the cbv values false and not indexing them at the wrong offset.
if i switch viewPos with viewDir, viewPos is affected. always the last member of the constbuffer struct.