summaryrefslogtreecommitdiffstats
path: root/servers/rendering_server.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2023-07-20 11:49:59 +0200
committerJuan Linietsky <reduzio@gmail.com>2023-07-26 12:28:00 +0200
commitc7fb6cea3d745c6d06d26b99e083f3fdf3cd7e8b (patch)
treeb9675e2fe517885faa17dc5da36af42af79efe47 /servers/rendering_server.cpp
parent202e4b2c1e7f8b25738b93d0e4d5066453d3edf3 (diff)
downloadredot-engine-c7fb6cea3d745c6d06d26b99e083f3fdf3cd7e8b.tar.gz
Add ability to call code on rendering thread
As more users use compute in Godot 4, the way they do is most likely incompatible when running on separate threads and will start erroring soon as we improve the thread safety of the render thread. To properly run code on the render thread, this function was added. Use like this: ```GDScript func initialize_compute_code(): .... func update_compute_code(custom_data): ... func _ready(): RenderingServer.call_on_render_thread( initialize_compute_code ) func _process(): RenderingServer.call_on_render_thread( update_compute_code.bind(with_data) ) ```
Diffstat (limited to 'servers/rendering_server.cpp')
-rw-r--r--servers/rendering_server.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index 4c6b765157..1c720ff149 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -2808,6 +2808,8 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &RenderingServer::draw, DEFVAL(true), DEFVAL(0.0));
ClassDB::bind_method(D_METHOD("get_rendering_device"), &RenderingServer::get_rendering_device);
ClassDB::bind_method(D_METHOD("create_local_rendering_device"), &RenderingServer::create_local_rendering_device);
+
+ ClassDB::bind_method(D_METHOD("call_on_render_thread", "callable"), &RenderingServer::call_on_render_thread);
}
void RenderingServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry3D::MeshData &p_mesh_data) {