Thomas Vandenberghe

  • Content count

  • Joined

  • Last visited

Community Reputation

104 Neutral

About Thomas Vandenberghe

  • Rank
  1. xnamath byte alignment

    I've come across this problem while following Beginning DirectX 11 Game Programming. During the cube demo the view and projection matrix are being transposed. If I'm using local XMMatrix as the parameter it works fine, if I'm using the member variable however it crashes with the error: Unhandled exception at 0x00D4F279 in DX11Project.exe: 0xC0000005: Access violation reading location 0xFFFFFFFF.   I've come upon a few answers where they state XMMatrix expects objects which are 16-byte aligned and some objects created would be 8-byte aligned which would cause the crash.   Has anyone else come across this sort of problem, and would there be any way to fix it without creating local variables?       The member variables are declared in Cube.h class Cube : public DX11Base { //... XMMATRIX m_viewMatrix; XMMATRIX m_projMatrix; //... };   The code crashes when I'm using: m_viewMatrix = XMMatrixIdentity(); m_projMatrix = XMMatrixPerspectiveFovLH(XM_PIDIV4, 800.0f/600.0f, 0.01f, 100.0f); m_viewMatrix = XMMatrixTranspose(m_viewMatrix); m_projMatrix = XMMatrixTranspose(m_projMatrix);   It works fine when I'm using: XMMATRIX view(XMMatrixIdentity()); XMMATRIX proj(XMMatrixPerspectiveFovLH(XM_PIDIV4, 800.0f/600.0f, 0.01f, 100.0f)); m_viewMatrix = XMMatrixTranspose(view); m_projMatrix = XMMatrixTranspose(proj);   Edit: I just found that by defining _XM_NO_INTRINSICS_ in your preprocessor also makes it work, however this will disable the optimization: