From 3c4b607faf5a250d4dc8ffe198f47e1dd9b42c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Thu, 21 Jan 2021 11:59:04 +0100 Subject: [PATCH] Fix freeze-crash in lightmapper under MinGW-GCC --- thirdparty/embree/common/sys/intrinsics.h | 2 +- thirdparty/embree/common/sys/mutex.h | 6 ++++-- .../embree/common/tasking/taskschedulerinternal.cpp | 2 +- thirdparty/embree/patches/godot-changes.patch | 10 ++++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/thirdparty/embree/common/sys/intrinsics.h b/thirdparty/embree/common/sys/intrinsics.h index 58f5c3bb4e6..1e0fd25eabd 100644 --- a/thirdparty/embree/common/sys/intrinsics.h +++ b/thirdparty/embree/common/sys/intrinsics.h @@ -432,7 +432,7 @@ namespace embree _mm_pause(); // -- GODOT start -- #else - usleep(1); + __builtin_ia32_pause(); #endif // -- GODOT end -- } diff --git a/thirdparty/embree/common/sys/mutex.h b/thirdparty/embree/common/sys/mutex.h index f0f55340a96..cbd9f95697d 100644 --- a/thirdparty/embree/common/sys/mutex.h +++ b/thirdparty/embree/common/sys/mutex.h @@ -54,7 +54,8 @@ namespace embree _mm_pause(); // -- GODOT start -- #else - usleep(1); + __builtin_ia32_pause(); + __builtin_ia32_pause(); #endif // -- GODOT end -- } @@ -89,7 +90,8 @@ namespace embree _mm_pause(); // -- GODOT start -- #else - usleep(1); + __builtin_ia32_pause(); + __builtin_ia32_pause(); #endif // -- GODOT end -- } diff --git a/thirdparty/embree/common/tasking/taskschedulerinternal.cpp b/thirdparty/embree/common/tasking/taskschedulerinternal.cpp index 923d62f83c8..456baf87442 100644 --- a/thirdparty/embree/common/tasking/taskschedulerinternal.cpp +++ b/thirdparty/embree/common/tasking/taskschedulerinternal.cpp @@ -367,7 +367,7 @@ namespace embree _mm_pause(); // -- GODOT start -- #else - usleep(1); + __builtin_ia32_pause(); #endif // -- GODOT end -- loopIndex++; diff --git a/thirdparty/embree/patches/godot-changes.patch b/thirdparty/embree/patches/godot-changes.patch index 31873da9c53..6ccfd8eb121 100644 --- a/thirdparty/embree/patches/godot-changes.patch +++ b/thirdparty/embree/patches/godot-changes.patch @@ -90,7 +90,7 @@ diff --git a/common/sys/mutex.h b/common/sys/mutex.h index 1164210f2..f0f55340a 100644 --- a/common/sys/mutex.h +++ b/common/sys/mutex.h -@@ -47,8 +47,16 @@ namespace embree +@@ -47,8 +47,17 @@ namespace embree { while (flag.load()) { @@ -101,13 +101,14 @@ index 1164210f2..f0f55340a 100644 _mm_pause(); +// -- GODOT start -- +#else -+ usleep(1); ++ __builtin_ia32_pause(); ++ __builtin_ia32_pause(); +#endif +// -- GODOT end -- } bool expected = false; -@@ -74,8 +82,16 @@ namespace embree +@@ -74,8 +82,17 @@ namespace embree { while(flag.load()) { @@ -118,7 +119,8 @@ index 1164210f2..f0f55340a 100644 _mm_pause(); +// -- GODOT start -- +#else -+ usleep(1); ++ __builtin_ia32_pause(); ++ __builtin_ia32_pause(); +#endif +// -- GODOT end -- }