Games for Windows and the DirectX SDK blog

Technical tips, tricks, and news about game development for Microsoft platforms including desktop, Xbox One, and UWP

Project maintained by walbourn Hosted on GitHub Pages — Theme by mattgraham
Home | Posts by Tag | Posts by Month

DirectXMath 3.08


Originally posted to Chuck Walbourn's Blog on MSDN,

DirectXMath version 3.08 is included in the Windows 10 SDK November 2015 update (10586) that ships with VS 2015 Update 1 with the Windows Tools 1.2 for Windows 10.

This new version includes the following:

  • Added use of ``_mm_sfence`` for Stream methods
  • Fixed bug with non-uniform scaling transforms for BoundingOrientedBox
  • Added asserts for Near/FarZ in XMMatrix* methods
  • Added use of =default for PODs with VS 2013/2015
  • Additional SSE and ARM-NEON optimizations for PackedVector functions

It’s a fairly minor update compared to DirectXMath 3.07, but does have one interesting side-effect worth discussing further. Because of the use of the C++11 =default construct, existing DirectXMath code may generate new previously latent warnings when building with VS 2013 or VS 2015:

warning C4101: 'X': unreferenced local variable

warning C4701: potentially uninitialized local variable 'X' used

The warnings are easy to address, but may surprise developers when they pop up in existing code. Note that the =default construct is not merely syntactic fluff: In some use cases, it can make the compiler generate much better code by understanding the constructor does nothing at all and the type in question is in fact ‘trivial plain-old-data’. This mostly shows up in the cases of inheritance, so it may not be obviously different in simple codegen cases. It does, however, cause these compiler to notice when a variable is not actually used or initialized.


The fix for non-uniform scaling transformations is trivial to apply to older versions of the library:

inline void XM_CALLCONV BoundingOrientedBox::Transform(BoundingOrientedBox& Out, FXMMATRIX M) const
    // Load the box.
    XMVECTOR vCenter = XMLoadFloat3(&Center);
    XMVECTOR vExtents = XMLoadFloat3(&Extents);
    XMVECTOR vOrientation = XMLoadFloat4(&Orientation);


    // Composite the box rotation and the transform rotation.
    nM.r[0] = XMVector3Normalize(M.r[0]);
    nM.r[1] = XMVector3Normalize(M.r[1]);
    nM.r[2] = XMVector3Normalize(M.r[2]);
    nM.r[3] = g_XMIdentityR3;
    XMVECTOR Rotation = XMQuaternionRotationMatrix(nM);
    vOrientation = XMQuaternionMultiply(vOrientation, Rotation);

    // Transform the center.
    vCenter = XMVector3Transform(vCenter, M);

    // Scale the box extents.
    XMVECTOR dX = XMVector3Length(M.r[0]);
    XMVECTOR dY = XMVector3Length(M.r[1]);
    XMVECTOR dZ = XMVector3Length(M.r[2]);

    XMVECTOR VectorScale = XMVectorSelect(dY, dX, g_XMSelect1000); // !!swapped dX and dY
    VectorScale = XMVectorSelect(dZ, VectorScale, g_XMSelect1100); // !!swapped dZ and VectorScale
    vExtents = vExtents * VectorScale;

    // Store the box.
    XMStoreFloat3(&Out.Center, vCenter);
    XMStoreFloat3(&Out.Extents, vExtents);
    XMStoreFloat4(&Out.Orientation, vOrientation);

Xbox One: DirectXMath 3.08 shipped in the Xbox One XDK (July 2015 or later)

GitHub: Note that DirectXMath is now hosted on GitHub.

Related: Known Issues: DirectXMath 3.03, DirectXMath 3.06, DirectXMath 3.09, DirectXMath 3.10, DirectXMath 3.11