From d2c4ce8696f9fc80ce772b511b5c7f3d00422e86 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 30 Mar 2016 20:31:59 -0400 Subject: [PATCH 1/4] pch: Update Visual Studio version check --- Source/PCH/pch.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/PCH/pch.h b/Source/PCH/pch.h index 66cda470e6..1ea2279f39 100644 --- a/Source/PCH/pch.h +++ b/Source/PCH/pch.h @@ -67,8 +67,8 @@ #ifdef _WIN32 -#if _MSC_FULL_VER < 190023026 -#error Please update your build environment to Visual Studio 2015 or later! +#if _MSC_FULL_VER < 190023918 +#error Please update your build environment to Visual Studio 2015 Update 2 or later! #endif #include From 33c22ffab7554802573da60d7cc5655fa90688a3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 30 Mar 2016 20:45:40 -0400 Subject: [PATCH 2/4] D3D: Amend code to fix a new VS warning Fixes warning C4334 --- Source/Core/VideoBackends/D3D/Render.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index dd6fafcdb9..189b4466a4 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -1030,7 +1030,7 @@ void Renderer::ApplyState(bool bUseDstAlpha) for (unsigned int stage = 0; stage < 8; stage++) { // TODO: cache SamplerState directly, not d3d object - gx_state.sampler[stage].max_anisotropy = 1 << g_ActiveConfig.iMaxAnisotropy; + gx_state.sampler[stage].max_anisotropy = UINT64_C(1) << g_ActiveConfig.iMaxAnisotropy; D3D::stateman->SetSampler(stage, gx_state_cache.Get(gx_state.sampler[stage])); } From b3c77fd96a4eb5ada025b3b7937757a3456434bf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 30 Mar 2016 20:58:55 -0400 Subject: [PATCH 3/4] VertexLoaderTest: Amend code to fix new warnings in Visual Studio Fixes warning C4334 --- Source/UnitTests/VideoCommon/VertexLoaderTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp b/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp index 9ca8befc95..fd0b23b0d4 100644 --- a/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp +++ b/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp @@ -221,7 +221,7 @@ TEST_P(VertexLoaderSpeedTest, PositionDirectAll) m_vtx_attr.g0.PosFormat = format; m_vtx_attr.g0.PosElements = elements; elements += 2; - size_t elem_size = 1 << (format / 2); + size_t elem_size = static_cast(1) << (format / 2); CreateAndCheckSizes(elements * elem_size, elements * sizeof(float)); for (int i = 0; i < 1000; ++i) RunVertices(100000); @@ -239,7 +239,7 @@ TEST_P(VertexLoaderSpeedTest, TexCoordSingleElement) m_vtx_attr.g0.Tex0CoordFormat = format; m_vtx_attr.g0.Tex0CoordElements = elements; elements += 1; - size_t elem_size = 1 << (format / 2); + size_t elem_size = static_cast(1) << (format / 2); CreateAndCheckSizes(2 * sizeof(s8) + elements * elem_size, 2 * sizeof(float) + elements * sizeof(float)); for (int i = 0; i < 1000; ++i) From 8d9221a71e235393db3c03322e1324f400d0d915 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 3 Apr 2016 19:08:47 -0400 Subject: [PATCH 4/4] MathUtilTest: Fix tests on MSVC - Document compiler bug MSVC's implementation of numeric_limits currently generates incorrect signaling NaNs. The resulting values are actually quiet NaNs instead. This commit is based off of a solution by shuffle2. The only difference is a template specialization for floats is also added to cover all bases --- Source/Core/Common/MathUtil.h | 26 ++++++++++++++++++++++++ Source/UnitTests/Common/MathUtilTest.cpp | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Source/Core/Common/MathUtil.h b/Source/Core/Common/MathUtil.h index 3ca5c1b770..236c554437 100644 --- a/Source/Core/Common/MathUtil.h +++ b/Source/Core/Common/MathUtil.h @@ -12,6 +12,32 @@ namespace MathUtil { + +template +constexpr T SNANConstant() +{ + return std::numeric_limits::signaling_NaN(); +} + +#ifdef _MSC_VER + +// MSVC needs a workaround, because its std::numeric_limits::signaling_NaN() +// will use __builtin_nans, which is improperly handled by the compiler and generates +// a bad constant. Here we go back to the version MSVC used before the builtin. +// TODO: Remove this and use numeric_limits directly whenever this bug is fixed. +template <> +constexpr double SNANConstant() +{ + return (_CSTD _Snan._Double); +} +template <> +constexpr float SNANConstant() +{ + return (_CSTD _Snan._Float); +} + +#endif + template constexpr T Clamp(const T val, const T& min, const T& max) { diff --git a/Source/UnitTests/Common/MathUtilTest.cpp b/Source/UnitTests/Common/MathUtilTest.cpp index f7427cc8c3..0eabd14694 100644 --- a/Source/UnitTests/Common/MathUtilTest.cpp +++ b/Source/UnitTests/Common/MathUtilTest.cpp @@ -23,13 +23,13 @@ TEST(MathUtil, Clamp) TEST(MathUtil, IsQNAN) { EXPECT_TRUE(MathUtil::IsQNAN(std::numeric_limits::quiet_NaN())); - EXPECT_FALSE(MathUtil::IsQNAN(std::numeric_limits::signaling_NaN())); + EXPECT_FALSE(MathUtil::IsQNAN(MathUtil::SNANConstant())); } TEST(MathUtil, IsSNAN) { EXPECT_FALSE(MathUtil::IsSNAN(std::numeric_limits::quiet_NaN())); - EXPECT_TRUE(MathUtil::IsSNAN(std::numeric_limits::signaling_NaN())); + EXPECT_TRUE(MathUtil::IsSNAN(MathUtil::SNANConstant())); } TEST(MathUtil, IntLog2)