You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-23 15:16:17 +00:00
Merge pull request #79696 from reduz/call-on-render-thread
Add ability to call code on rendering thread
This commit is contained in:
@@ -97,6 +97,8 @@ class RenderingServerDefault : public RenderingServer {
|
||||
|
||||
void _free(RID p_rid);
|
||||
|
||||
void _call_on_render_thread(const Callable &p_callable);
|
||||
|
||||
public:
|
||||
//if editor is redrawing when it shouldn't, enable this and put a breakpoint in _changes_changed()
|
||||
//#define DEBUG_CHANGES
|
||||
@@ -991,6 +993,15 @@ public:
|
||||
virtual void init() override;
|
||||
virtual void finish() override;
|
||||
|
||||
virtual void call_on_render_thread(const Callable &p_callable) override {
|
||||
if (Thread::get_caller_id() == server_thread) {
|
||||
command_queue.flush_if_pending();
|
||||
_call_on_render_thread(p_callable);
|
||||
} else {
|
||||
command_queue.push(this, &RenderingServerDefault::_call_on_render_thread, p_callable);
|
||||
}
|
||||
}
|
||||
|
||||
/* TESTING */
|
||||
|
||||
virtual double get_frame_setup_time_cpu() const override;
|
||||
|
||||
Reference in New Issue
Block a user