Compare commits

...

4 Commits

Author SHA1 Message Date
Haoyu Qiu
d9946806c4
Merge ddb925967f into 533c616cb8 2024-10-22 22:13:40 +02:00
Clay John
533c616cb8
Merge pull request #98391 from RandomShaper/rd_thread_switch
Some checks are pending
🔗 GHA / 📊 Static checks (push) Waiting to run
🔗 GHA / 🤖 Android (push) Blocked by required conditions
🔗 GHA / 🍏 iOS (push) Blocked by required conditions
🔗 GHA / 🐧 Linux (push) Blocked by required conditions
🔗 GHA / 🍎 macOS (push) Blocked by required conditions
🔗 GHA / 🏁 Windows (push) Blocked by required conditions
🔗 GHA / 🌐 Web (push) Blocked by required conditions
🔗 GHA / 🪲 Godot CPP (push) Blocked by required conditions
Implement thread ownership change for RenderingDevice
2024-10-22 13:10:32 -07:00
Pedro J. Estébanez
d5d509bbd6 Implement thread ownership change for RenderingDevice 2024-10-21 20:56:42 +02:00
Haoyu Qiu
ddb925967f Translate main thread name in the editor instead of running project 2024-10-19 09:42:36 +08:00
5 changed files with 13 additions and 2 deletions

View File

@ -419,7 +419,7 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
msg.push_back(error_str);
ERR_FAIL_NULL(script_lang);
msg.push_back(script_lang->debug_get_stack_level_count() > 0);
msg.push_back(Thread::get_caller_id() == Thread::get_main_id() ? String(RTR("Main Thread")) : itos(Thread::get_caller_id()));
msg.push_back(Thread::get_caller_id());
if (allow_focus_steal_fn) {
allow_focus_steal_fn();
}

View File

@ -332,8 +332,10 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread
if (p_msg == "debug_enter") {
ERR_FAIL_COND(p_data.size() != 4);
const Thread::ID caller_id = p_data[3];
ThreadDebugged td;
td.name = p_data[3];
td.name = (caller_id == Thread::get_main_id()) ? TTR("Main Thread") : itos(caller_id);
td.error = p_data[1];
td.can_debug = p_data[0];
td.has_stackdump = p_data[2];
@ -1904,6 +1906,7 @@ ScriptEditorDebugger::ScriptEditorDebugger() {
thread_hb->add_child(memnew(Label(TTR("Thread:"))));
threads = memnew(OptionButton);
thread_hb->add_child(threads);
threads->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
threads->set_h_size_flags(SIZE_EXPAND_FILL);
threads->connect(SceneStringName(item_selected), callable_mp(this, &ScriptEditorDebugger::_select_thread));

View File

@ -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();

View File

@ -1496,6 +1496,8 @@ public:
static RenderingDevice *get_singleton();
void make_current();
RenderingDevice();
~RenderingDevice();

View File

@ -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() {