summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClay John <claynjohn@gmail.com>2024-10-22 13:10:32 -0700
committerGitHub <noreply@github.com>2024-10-22 13:10:32 -0700
commit533c616cb86ff7bb940d58ffbbcc1a3eca0aa33d (patch)
tree5606fde6fbec1150b1e2b09b4a4d059d5d335b0f
parentb3bcb2dc14691f7729984128dca26a844f662fa1 (diff)
parentd5d509bbd68f829f5cb9dbf3e0ee5c1a349f9a4f (diff)
downloadredot-engine-533c616cb86ff7bb940d58ffbbcc1a3eca0aa33d.tar.gz
Merge pull request #98391 from RandomShaper/rd_thread_switch
Implement thread ownership change for RenderingDevice
-rw-r--r--servers/rendering/rendering_device.cpp4
-rw-r--r--servers/rendering/rendering_device.h2
-rw-r--r--servers/rendering/rendering_server_default.cpp2
3 files changed, 8 insertions, 0 deletions
diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp
index 942d5631e4..6eb1386749 100644
--- a/servers/rendering/rendering_device.cpp
+++ b/servers/rendering/rendering_device.cpp
@@ -7260,6 +7260,10 @@ void RenderingDevice::_bind_methods() {
BIND_ENUM_CONSTANT(DEBUG_PASS);
}
+void RenderingDevice::make_current() {
+ render_thread_id = Thread::get_caller_id();
+}
+
RenderingDevice::~RenderingDevice() {
finalize();
diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h
index 71ffbfbd88..c440e11cd4 100644
--- a/servers/rendering/rendering_device.h
+++ b/servers/rendering/rendering_device.h
@@ -1496,6 +1496,8 @@ public:
static RenderingDevice *get_singleton();
+ void make_current();
+
RenderingDevice();
~RenderingDevice();
diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp
index 20f1f9ad6f..2ec693cbbf 100644
--- a/servers/rendering/rendering_server_default.cpp
+++ b/servers/rendering/rendering_server_default.cpp
@@ -370,6 +370,8 @@ Size2i RenderingServerDefault::get_maximum_viewport_size() const {
void RenderingServerDefault::_assign_mt_ids(WorkerThreadPool::TaskID p_pump_task_id) {
server_thread = Thread::get_caller_id();
server_task_id = p_pump_task_id;
+ // This is needed because the main RD is created on the main thread.
+ RenderingDevice::get_singleton()->make_current();
}
void RenderingServerDefault::_thread_exit() {