From 899512e82cf691359283415fed52063cfa615d6b Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Sun, 15 Mar 2020 15:49:43 -0700 Subject: [PATCH] A few more use cases for constexpr --- Inc/DirectXMath.h | 16 ++++++++-------- Inc/DirectXPackedVector.inl | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Inc/DirectXMath.h b/Inc/DirectXMath.h index 65eaa61..c4de03c 100644 --- a/Inc/DirectXMath.h +++ b/Inc/DirectXMath.h @@ -1730,12 +1730,12 @@ namespace DirectX static_assert(PermuteW <= 7, "PermuteW template parameter out of range"); #if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) - const uint32_t Shuffle = _MM_SHUFFLE(PermuteW & 3, PermuteZ & 3, PermuteY & 3, PermuteX & 3); + constexpr uint32_t Shuffle = _MM_SHUFFLE(PermuteW & 3, PermuteZ & 3, PermuteY & 3, PermuteX & 3); - const bool WhichX = PermuteX > 3; - const bool WhichY = PermuteY > 3; - const bool WhichZ = PermuteZ > 3; - const bool WhichW = PermuteW > 3; + constexpr bool WhichX = PermuteX > 3; + constexpr bool WhichY = PermuteY > 3; + constexpr bool WhichZ = PermuteZ > 3; + constexpr bool WhichW = PermuteW > 3; return Internal::PermuteHelper::Permute(V1, V2); #else @@ -1746,8 +1746,8 @@ namespace DirectX } // Special-case permute templates - template<> inline XMVECTOR XM_CALLCONV XMVectorPermute<0, 1, 2, 3>(FXMVECTOR V1, FXMVECTOR) noexcept { return V1; } - template<> inline XMVECTOR XM_CALLCONV XMVectorPermute<4, 5, 6, 7>(FXMVECTOR, FXMVECTOR V2) noexcept { return V2; } + template<> inline constexpr XMVECTOR XM_CALLCONV XMVectorPermute<0, 1, 2, 3>(FXMVECTOR V1, FXMVECTOR) noexcept { return V1; } + template<> inline constexpr XMVECTOR XM_CALLCONV XMVectorPermute<4, 5, 6, 7>(FXMVECTOR, FXMVECTOR V2) noexcept { return V2; } #if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) template<> inline XMVECTOR XM_CALLCONV XMVectorPermute<0, 1, 4, 5>(FXMVECTOR V1, FXMVECTOR V2) noexcept { return _mm_movelh_ps(V1, V2); } @@ -1835,7 +1835,7 @@ namespace DirectX } // Specialized swizzles - template<> inline XMVECTOR XM_CALLCONV XMVectorSwizzle<0, 1, 2, 3>(FXMVECTOR V) noexcept { return V; } + template<> inline constexpr XMVECTOR XM_CALLCONV XMVectorSwizzle<0, 1, 2, 3>(FXMVECTOR V) noexcept { return V; } #if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) template<> inline XMVECTOR XM_CALLCONV XMVectorSwizzle<0, 1, 0, 1>(FXMVECTOR V) noexcept { return _mm_movelh_ps(V, V); } diff --git a/Inc/DirectXPackedVector.inl b/Inc/DirectXPackedVector.inl index 31bce12..c6133ca 100644 --- a/Inc/DirectXPackedVector.inl +++ b/Inc/DirectXPackedVector.inl @@ -2618,8 +2618,8 @@ inline void XM_CALLCONV XMStoreFloat3SE XMFLOAT3A tmp; XMStoreFloat3A(&tmp, V); - static const float maxf9 = float(0x1FF << 7); - static const float minf9 = float(1.f / (1 << 16)); + static constexpr float maxf9 = float(0x1FF << 7); + static constexpr float minf9 = float(1.f / (1 << 16)); float x = (tmp.x >= 0.f) ? ((tmp.x > maxf9) ? maxf9 : tmp.x) : 0.f; float y = (tmp.y >= 0.f) ? ((tmp.y > maxf9) ? maxf9 : tmp.y) : 0.f;