From 699157de20dded40a2e8237dea2455505de67fe0 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Sun, 13 Nov 2022 23:26:09 -0600 Subject: [PATCH] VideoCommon: Explicitly disable fp_contract for CPUCull --- Source/Core/VideoCommon/CPUCull.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/Core/VideoCommon/CPUCull.cpp b/Source/Core/VideoCommon/CPUCull.cpp index c552f3595455..4ad27448b945 100644 --- a/Source/Core/VideoCommon/CPUCull.cpp +++ b/Source/Core/VideoCommon/CPUCull.cpp @@ -13,6 +13,20 @@ #include "VideoCommon/VideoConfig.h" #include "VideoCommon/XFMemory.h" +// We really want things like c.w * a.x - a.w * c.x to stay symmetric, so they cancel to zero on +// degenerate triangles. Make sure the compiler doesn't optimize in fmas where not requested. +#ifdef _MSC_VER +#pragma fp_contract(off) +#else +// GCC doesn't support any in-file way to turn off fp contract yet +// Not ideal, but worst case scenario its cpu cull is worse at detecting degenerate triangles +// (Most likely to happen on arm, as we don't compile the cull code for x86 fma) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma STDC FP_CONTRACT OFF +#pragma GCC diagnostic pop +#endif + #if defined(_M_X86) || defined(_M_X86_64) #define USE_SSE #elif defined(_M_ARM_64)