Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualunbird

Posted 17 August 2013 - 03:41 AM

The transpose for the matrix is needed since the mul wants it in column-major order. Also, you have a (probably) padding mismatch between your C++ struct and the shader constant. In HLSL, if a (vector) value crosses a float4 border, it will be aligned to the next float4. Your C++ struct should look something like this.
 

struct ConstantBuffer
{
    float  value1;
    float pad1, pad2, pad3; // dummy pads
    Matrix value2;
} g_CBData;
I haven't checked this. But you can check the offsets with the C++ offsetof macro and on the shader side by looking at the HLSL assembly (or shader reflection). Use fxc.exe with the option /Fx to dump the assembly.

Edit: Ahhh, beaten wink.png

#1unbird

Posted 17 August 2013 - 03:41 AM

The transpose for the matrix is needed since the mul wants it in column-major order. Also, you have a (probably) padding mismatch between your C++ struct and the shader constant. In HLSL, if a (vector) value crosses a float4 border, it will be aligned to the next float4. Your C++ struct should look something like this.

struct ConstantBuffer
{
    float  value1;
    float pad1, pad2, pad3; // dummy pads
    Matrix value2;
} g_CBData;
I haven't checked this. But you can check the offsets with the C++ offsetof macro and on the shader side by looking at the HLSL assembly (or shader reflection). Use fxc.exe with the option /Fx to dump the assembly.

PARTNERS