|
@@ -12,10 +12,23 @@ index 5af0691a2..1982c27c1 100644
|
|
|
namespace std
|
|
|
{
|
|
|
diff --git a/common/sys/intrinsics.h b/common/sys/intrinsics.h
|
|
|
-index 3f0619cac..6948e4a74 100644
|
|
|
+index 3f0619cac..58f5c3bb4 100644
|
|
|
--- a/common/sys/intrinsics.h
|
|
|
+++ b/common/sys/intrinsics.h
|
|
|
-@@ -30,8 +30,14 @@
|
|
|
+@@ -11,6 +11,12 @@
|
|
|
+
|
|
|
+ #include <immintrin.h>
|
|
|
+
|
|
|
++// -- GODOT start --
|
|
|
++#if defined(__WIN32__) && defined(__MINGW32__)
|
|
|
++#include <unistd.h>
|
|
|
++#endif
|
|
|
++// -- GODOT end --
|
|
|
++
|
|
|
+ #if defined(__BMI__) && defined(__GNUC__) && !defined(__INTEL_COMPILER)
|
|
|
+ #if !defined(_tzcnt_u32)
|
|
|
+ #define _tzcnt_u32 __tzcnt_u32
|
|
|
+@@ -30,8 +36,14 @@
|
|
|
#endif
|
|
|
|
|
|
#if defined(__WIN32__)
|
|
@@ -32,6 +45,23 @@ index 3f0619cac..6948e4a74 100644
|
|
|
#endif
|
|
|
|
|
|
/* normally defined in pmmintrin.h, but we always need this */
|
|
|
+@@ -413,8 +425,16 @@ namespace embree
|
|
|
+
|
|
|
+ __forceinline void pause_cpu(const size_t N = 8)
|
|
|
+ {
|
|
|
++// -- GODOT start --
|
|
|
+ for (size_t i=0; i<N; i++)
|
|
|
++#if !(defined(__WIN32__) && defined(__MINGW32__))
|
|
|
++// -- GODOT end --
|
|
|
+ _mm_pause();
|
|
|
++// -- GODOT start --
|
|
|
++#else
|
|
|
++ usleep(1);
|
|
|
++#endif
|
|
|
++// -- GODOT end --
|
|
|
+ }
|
|
|
+
|
|
|
+ /* prefetches */
|
|
|
diff --git a/common/sys/library.cpp b/common/sys/library.cpp
|
|
|
index e448b195d..8ec918660 100644
|
|
|
--- a/common/sys/library.cpp
|
|
@@ -47,6 +77,44 @@ index e448b195d..8ec918660 100644
|
|
|
}
|
|
|
|
|
|
/* closes the shared library */
|
|
|
+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
|
|
|
+ {
|
|
|
+ while (flag.load())
|
|
|
+ {
|
|
|
++// -- GODOT start --
|
|
|
++#if !(defined (__WIN32__) && defined (__MINGW32__))
|
|
|
++// -- GODOT end --
|
|
|
+ _mm_pause();
|
|
|
+ _mm_pause();
|
|
|
++// -- GODOT start --
|
|
|
++#else
|
|
|
++ usleep(1);
|
|
|
++#endif
|
|
|
++// -- GODOT end --
|
|
|
+ }
|
|
|
+
|
|
|
+ bool expected = false;
|
|
|
+@@ -74,8 +82,16 @@ namespace embree
|
|
|
+ {
|
|
|
+ while(flag.load())
|
|
|
+ {
|
|
|
++// -- GODOT start --
|
|
|
++#if !(defined (__WIN32__) && defined(__MINGW32__))
|
|
|
++// -- GODOT end --
|
|
|
+ _mm_pause();
|
|
|
+ _mm_pause();
|
|
|
++// -- GODOT start --
|
|
|
++#else
|
|
|
++ usleep(1);
|
|
|
++#endif
|
|
|
++// -- GODOT end --
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
diff --git a/common/sys/platform.h b/common/sys/platform.h
|
|
|
index 96f9aab01..08617452f 100644
|
|
|
--- a/common/sys/platform.h
|
|
@@ -71,6 +139,39 @@ index 96f9aab01..08617452f 100644
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
/// Error handling and debugging
|
|
|
+diff --git a/common/sys/sysinfo.cpp b/common/sys/sysinfo.cpp
|
|
|
+index eb0a10eaf..74438260d 100644
|
|
|
+--- a/common/sys/sysinfo.cpp
|
|
|
++++ b/common/sys/sysinfo.cpp
|
|
|
+@@ -233,7 +233,7 @@ namespace embree
|
|
|
+
|
|
|
+ __noinline int64_t get_xcr0()
|
|
|
+ {
|
|
|
+-#if defined (__WIN32__)
|
|
|
++#if defined (__WIN32__) /* -- GODOT start -- */ && !defined (__MINGW32__) /* -- GODOT end -- */
|
|
|
+ int64_t xcr0 = 0; // int64_t is workaround for compiler bug under VS2013, Win32
|
|
|
+ xcr0 = _xgetbv(0);
|
|
|
+ return xcr0;
|
|
|
+diff --git a/common/tasking/taskschedulerinternal.cpp b/common/tasking/taskschedulerinternal.cpp
|
|
|
+index 2152e92f4..923d62f83 100644
|
|
|
+--- a/common/tasking/taskschedulerinternal.cpp
|
|
|
++++ b/common/tasking/taskschedulerinternal.cpp
|
|
|
+@@ -361,7 +361,15 @@ namespace embree
|
|
|
+ if ((loopIndex % LOOP_YIELD_THRESHOLD) == 0)
|
|
|
+ yield();
|
|
|
+ else
|
|
|
++// -- GODOT start --
|
|
|
++#if !defined(__MINGW32__)
|
|
|
++// -- GODOT end --
|
|
|
+ _mm_pause();
|
|
|
++// -- GODOT start --
|
|
|
++#else
|
|
|
++ usleep(1);
|
|
|
++#endif
|
|
|
++// -- GODOT end --
|
|
|
+ loopIndex++;
|
|
|
+ #else
|
|
|
+ yield();
|
|
|
diff --git a/common/tasking/taskschedulertbb.h b/common/tasking/taskschedulertbb.h
|
|
|
index 98dba2687..369e5edf0 100644
|
|
|
--- a/common/tasking/taskschedulertbb.h
|