summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-07-23 15:55:50 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-07-23 15:55:50 +0200
commit9b7f5f5fa58df2a33e42b6c466e9231da9427bef (patch)
tree3ab42e1ed7ed5d29e7f3bb9d35d93ab7208bd7de
parent29e1bdee2b48247d858f6985fc4e8f2c509de037 (diff)
parent52a2836861a4e544ce58908c50e457b18656239e (diff)
downloadredot-engine-9b7f5f5fa58df2a33e42b6c466e9231da9427bef.tar.gz
Merge pull request #94655 from bruvzg/ffp-contract-2
Disable FP contraction.
-rw-r--r--platform/android/detect.py2
-rw-r--r--platform/linuxbsd/detect.py2
-rw-r--r--platform/macos/detect.py2
-rw-r--r--platform/windows/detect.py4
-rw-r--r--thirdparty/libwebp/patches/godot-msvc-arm64-fpstrict-fix.patch18
-rw-r--r--thirdparty/libwebp/sharpyuv/sharpyuv_gamma.c6
6 files changed, 34 insertions, 0 deletions
diff --git a/platform/android/detect.py b/platform/android/detect.py
index 0b182aca90..0a10754e24 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -190,6 +190,8 @@ def configure(env: "SConsEnvironment"):
env.Append(CCFLAGS=["-mfix-cortex-a53-835769"])
env.Append(CPPDEFINES=["__ARM_ARCH_8A__"])
+ env.Append(CCFLAGS=["-ffp-contract=off"])
+
# Link flags
env.Append(LINKFLAGS="-Wl,--gc-sections -Wl,--no-undefined -Wl,-z,now".split())
diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index 303a88ab26..d1de760f34 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -179,6 +179,8 @@ def configure(env: "SConsEnvironment"):
env.Append(CCFLAGS=["-fsanitize-recover=memory"])
env.Append(LINKFLAGS=["-fsanitize=memory"])
+ env.Append(CCFLAGS=["-ffp-contract=off"])
+
# LTO
if env["lto"] == "auto": # Full LTO for production.
diff --git a/platform/macos/detect.py b/platform/macos/detect.py
index 70cb00c6ff..1ce7c86c7b 100644
--- a/platform/macos/detect.py
+++ b/platform/macos/detect.py
@@ -96,6 +96,8 @@ def configure(env: "SConsEnvironment"):
env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.13"])
env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.13"])
+ env.Append(CCFLAGS=["-ffp-contract=off"])
+
cc_version = get_compiler_version(env)
cc_version_major = cc_version["apple_major"]
cc_version_minor = cc_version["apple_minor"]
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 3671bbef08..bfbf7d3ebc 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -467,6 +467,8 @@ def configure_msvc(env: "SConsEnvironment", vcvars_msvc_config):
if env["arch"] == "x86_32":
env["x86_libtheora_opt_vc"] = True
+ env.Append(CCFLAGS=["/fp:strict"])
+
env.AppendUnique(CCFLAGS=["/Gd", "/GR", "/nologo"])
env.AppendUnique(CCFLAGS=["/utf-8"]) # Force to use Unicode encoding.
env.AppendUnique(CXXFLAGS=["/TP"]) # assume all sources are C++
@@ -675,6 +677,8 @@ def configure_mingw(env: "SConsEnvironment"):
if env["arch"] in ["x86_32", "x86_64"]:
env["x86_libtheora_opt_gcc"] = True
+ env.Append(CCFLAGS=["-ffp-contract=off"])
+
mingw_bin_prefix = get_mingw_bin_prefix(env["mingw_prefix"], env["arch"])
if env["use_llvm"]:
diff --git a/thirdparty/libwebp/patches/godot-msvc-arm64-fpstrict-fix.patch b/thirdparty/libwebp/patches/godot-msvc-arm64-fpstrict-fix.patch
new file mode 100644
index 0000000000..b0be515ea8
--- /dev/null
+++ b/thirdparty/libwebp/patches/godot-msvc-arm64-fpstrict-fix.patch
@@ -0,0 +1,18 @@
+diff --git a/thirdparty/libwebp/sharpyuv/sharpyuv_gamma.c b/thirdparty/libwebp/sharpyuv/sharpyuv_gamma.c
+index 09028428ac..3184e2b80f 100644
+--- a/thirdparty/libwebp/sharpyuv/sharpyuv_gamma.c
++++ b/thirdparty/libwebp/sharpyuv/sharpyuv_gamma.c
+@@ -26,7 +26,13 @@ static uint32_t kGammaToLinearTabS[GAMMA_TO_LINEAR_TAB_SIZE + 2];
+ #define LINEAR_TO_GAMMA_TAB_SIZE (1 << LINEAR_TO_GAMMA_TAB_BITS)
+ static uint32_t kLinearToGammaTabS[LINEAR_TO_GAMMA_TAB_SIZE + 2];
+
++// -- GODOT start --
++#if defined(_MSC_VER)
++static const double kGammaF = 2.222222222222222;
++#else
+ static const double kGammaF = 1. / 0.45;
++#endif
++// -- GODOT end --
+ #define GAMMA_TO_LINEAR_BITS 16
+
+ static volatile int kGammaTablesSOk = 0;
diff --git a/thirdparty/libwebp/sharpyuv/sharpyuv_gamma.c b/thirdparty/libwebp/sharpyuv/sharpyuv_gamma.c
index 09028428ac..73b75e98b4 100644
--- a/thirdparty/libwebp/sharpyuv/sharpyuv_gamma.c
+++ b/thirdparty/libwebp/sharpyuv/sharpyuv_gamma.c
@@ -26,7 +26,13 @@ static uint32_t kGammaToLinearTabS[GAMMA_TO_LINEAR_TAB_SIZE + 2];
#define LINEAR_TO_GAMMA_TAB_SIZE (1 << LINEAR_TO_GAMMA_TAB_BITS)
static uint32_t kLinearToGammaTabS[LINEAR_TO_GAMMA_TAB_SIZE + 2];
+// -- GODOT start --
+#if defined(_MSC_VER)
+static const double kGammaF = 2.222222222222222;
+#else
static const double kGammaF = 1. / 0.45;
+#endif
+// -- GODOT end --
#define GAMMA_TO_LINEAR_BITS 16
static volatile int kGammaTablesSOk = 0;