summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-09-23 11:50:23 +0200
committerGitHub <noreply@github.com>2020-09-23 11:50:23 +0200
commit9a463cb1d62a174aa34f608c0281963cdad255e9 (patch)
tree7f67de1413dfbcee027e27223f0710bbe1880d3e
parent78304b904ffd4816a3f2957fb3ddf2b20a13d66a (diff)
parentf3c6ac1d7183a9aea2809ee283a5cd899caf9f3d (diff)
Merge pull request #42263 from Faless/js/servers_no_threads
Ignore thread models when compiling with NO_THREAD
-rw-r--r--main/main.cpp4
-rw-r--r--servers/physics_2d/physics_server_2d_sw.cpp4
-rw-r--r--servers/physics_2d/physics_server_2d_wrap_mt.h4
3 files changed, 12 insertions, 0 deletions
diff --git a/main/main.cpp b/main/main.cpp
index ced8d7227a..a039283235 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1274,9 +1274,13 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
if (rtm >= 0 && rtm < 3) {
+#ifdef NO_THREADS
+ rtm = OS::RENDER_THREAD_UNSAFE; // No threads available on this platform.
+#else
if (editor) {
rtm = OS::RENDER_THREAD_SAFE;
}
+#endif
OS::get_singleton()->_render_thread_mode = OS::RenderThreadMode(rtm);
}
diff --git a/servers/physics_2d/physics_server_2d_sw.cpp b/servers/physics_2d/physics_server_2d_sw.cpp
index ffdaab0d92..1b396190e9 100644
--- a/servers/physics_2d/physics_server_2d_sw.cpp
+++ b/servers/physics_2d/physics_server_2d_sw.cpp
@@ -1342,6 +1342,10 @@ PhysicsServer2DSW::PhysicsServer2DSW() {
island_count = 0;
active_objects = 0;
collision_pairs = 0;
+#ifdef NO_THREADS
+ using_threads = false;
+#else
using_threads = int(ProjectSettings::get_singleton()->get("physics/2d/thread_model")) == 2;
+#endif
flushing_queries = false;
};
diff --git a/servers/physics_2d/physics_server_2d_wrap_mt.h b/servers/physics_2d/physics_server_2d_wrap_mt.h
index bc918b20f4..586dbe9e12 100644
--- a/servers/physics_2d/physics_server_2d_wrap_mt.h
+++ b/servers/physics_2d/physics_server_2d_wrap_mt.h
@@ -317,6 +317,9 @@ public:
template <class T>
static PhysicsServer2D *init_server() {
+#ifdef NO_THREADS
+ return memnew(T); // Always single unsafe when no threads are available.
+#else
int tm = GLOBAL_DEF("physics/2d/thread_model", 1);
if (tm == 0) { // single unsafe
return memnew(T);
@@ -325,6 +328,7 @@ public:
} else { // multi threaded
return memnew(PhysicsServer2DWrapMT(memnew(T), true));
}
+#endif
}
#undef ServerNameWrapMT