Skip to content

Commit 3c50159

Browse files
committed
tracy
1 parent 8b5cdfb commit 3c50159

File tree

5 files changed

+58
-28
lines changed

5 files changed

+58
-28
lines changed

core/object/worker_thread_pool.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2929
/**************************************************************************/
3030

31+
32+
#include "modules/godot_tracy/profiler.h"
33+
34+
3135
#include "worker_thread_pool.h"
3236

3337
#include "core/object/script_language.h"
@@ -50,6 +54,8 @@ thread_local uintptr_t WorkerThreadPool::unlockable_mutexes[MAX_UNLOCKABLE_MUTEX
5054
#endif
5155

5256
void WorkerThreadPool::_process_task(Task *p_task) {
57+
ZoneScopedN(p_task->description.utf8().get_data());
58+
5359
#ifdef THREADS_ENABLED
5460
int pool_thread_index = thread_ids[Thread::get_caller_id()];
5561
ThreadData &curr_thread = threads[pool_thread_index];

main/main.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -4007,7 +4007,6 @@ static uint64_t navigation_process_max = 0;
40074007
// will terminate the program. In case of failure, the OS exit code needs
40084008
// to be set explicitly here (defaults to EXIT_SUCCESS).
40094009
bool Main::iteration() {
4010-
ZoneScoped;
40114010
iterating++;
40124011

40134012
const uint64_t ticks = OS::get_singleton()->get_ticks_usec();
@@ -4140,7 +4139,7 @@ bool Main::iteration() {
41404139
uint64_t process_begin = OS::get_singleton()->get_ticks_usec();
41414140

41424141
{
4143-
ZoneScopedN("Main process");
4142+
ZoneScopedN("MainLoop process");
41444143
if (OS::get_singleton()->get_main_loop()->process(process_step * time_scale)) {
41454144
exit = true;
41464145
}

modules/multiplayer/scene_multiplayer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#ifdef DEBUG_ENABLED
3737
#include "core/os/os.h"
38+
#include "modules/godot_tracy/tracy/public/tracy/Tracy.hpp"
3839
#endif
3940

4041
#include <stdint.h>
@@ -67,6 +68,7 @@ void SceneMultiplayer::_update_status() {
6768
}
6869

6970
Error SceneMultiplayer::poll() {
71+
ZoneScopedN("Multiplayer Poll");
7072
_update_status();
7173
if (last_connection_status == MultiplayerPeer::CONNECTION_DISCONNECTED) {
7274
return OK;

scene/main/node.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ void Node::_notification(int p_notification) {
102102
} break;
103103
}
104104

105+
// also include the path
106+
if (is_inside_tree()) {
107+
identifier += " at " + get_path();
108+
}
109+
105110
// Set the Tracy zone name
106111
CharString c = identifier.utf8();
107112
ZoneName(c.get_data(), c.length());

scene/main/scene_tree.cpp

+44-26
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "scene/resources/3d/world_3d.h"
6363
#include "servers/physics_server_3d.h"
6464
#endif // _3D_DISABLED
65+
#include "modules/godot_tracy/tracy/public/tracy/Tracy.hpp"
6566
#include "window.h"
6667
#include <stdio.h>
6768
#include <stdlib.h>
@@ -486,7 +487,10 @@ bool SceneTree::physics_process(double p_time) {
486487

487488
call_group(SNAME("_picking_viewports"), SNAME("_process_picking"));
488489

489-
_process(true);
490+
{
491+
ZoneScopedN("SceneTree::_process (Physics)");
492+
_process(true);
493+
}
490494

491495
_flush_ugc();
492496
MessageQueue::get_singleton()->flush(); //small little hack
@@ -511,19 +515,26 @@ bool SceneTree::process(double p_time) {
511515
process_time = p_time;
512516

513517
if (multiplayer_poll) {
518+
ZoneScopedN("SceneTree::process::multiplayer_poll");
514519
multiplayer->poll();
515520
for (KeyValue<NodePath, Ref<MultiplayerAPI>> &E : custom_multiplayers) {
516521
E.value->poll();
517522
}
518523
}
519524

520-
emit_signal(SNAME("process_frame"));
525+
{
526+
ZoneScopedN("SceneTree::signal::process_frame");
527+
emit_signal(SNAME("process_frame"));
528+
}
521529

522530
MessageQueue::get_singleton()->flush(); //small little hack
523531

524532
flush_transform_notifications();
525533

526-
_process(false);
534+
{
535+
ZoneScopedN("SceneTree::_process");
536+
_process(false);
537+
}
527538

528539
_flush_ugc();
529540
MessageQueue::get_singleton()->flush(); //small little hack
@@ -919,11 +930,13 @@ void SceneTree::_process_group(ProcessGroup *p_group, bool p_physics) {
919930

920931
if (p_physics) {
921932
if (p_group->physics_node_order_dirty) {
933+
ZoneScopedN("SceneTree::_process_group Physics Node Sort");
922934
nodes.sort_custom<Node::ComparatorWithPhysicsPriority>();
923935
p_group->physics_node_order_dirty = false;
924936
}
925937
} else {
926938
if (p_group->node_order_dirty) {
939+
ZoneScopedN("SceneTree::_process_group Node Sort");
927940
nodes.sort_custom<Node::ComparatorWithPriority>();
928941
p_group->node_order_dirty = false;
929942
}
@@ -935,31 +948,34 @@ void SceneTree::_process_group(ProcessGroup *p_group, bool p_physics) {
935948
uint32_t node_count = nodes_copy.size();
936949
Node **nodes_ptr = (Node **)nodes_copy.ptr(); // Force cast, pointer will not change.
937950

938-
for (uint32_t i = 0; i < node_count; i++) {
939-
Node *n = nodes_ptr[i];
940-
if (nodes_removed_on_group_call.has(n)) {
941-
// Node may have been removed during process, skip it.
942-
// Keep in mind removals can only happen on the main thread.
943-
continue;
944-
}
945-
946-
if (!n->can_process() || !n->is_inside_tree()) {
947-
continue;
948-
}
949-
950-
if (p_physics) {
951-
if (n->is_physics_processing_internal()) {
952-
n->notification(Node::NOTIFICATION_INTERNAL_PHYSICS_PROCESS);
953-
}
954-
if (n->is_physics_processing()) {
955-
n->notification(Node::NOTIFICATION_PHYSICS_PROCESS);
951+
{
952+
ZoneScopedN("SceneTree::_process_group Process");
953+
for (uint32_t i = 0; i < node_count; i++) {
954+
Node *n = nodes_ptr[i];
955+
if (nodes_removed_on_group_call.has(n)) {
956+
// Node may have been removed during process, skip it.
957+
// Keep in mind removals can only happen on the main thread.
958+
continue;
956959
}
957-
} else {
958-
if (n->is_processing_internal()) {
959-
n->notification(Node::NOTIFICATION_INTERNAL_PROCESS);
960+
961+
if (!n->can_process() || !n->is_inside_tree()) {
962+
continue;
960963
}
961-
if (n->is_processing()) {
962-
n->notification(Node::NOTIFICATION_PROCESS);
964+
965+
if (p_physics) {
966+
if (n->is_physics_processing_internal()) {
967+
n->notification(Node::NOTIFICATION_INTERNAL_PHYSICS_PROCESS);
968+
}
969+
if (n->is_physics_processing()) {
970+
n->notification(Node::NOTIFICATION_PHYSICS_PROCESS);
971+
}
972+
} else {
973+
if (n->is_processing_internal()) {
974+
n->notification(Node::NOTIFICATION_INTERNAL_PROCESS);
975+
}
976+
if (n->is_processing()) {
977+
n->notification(Node::NOTIFICATION_PROCESS);
978+
}
963979
}
964980
}
965981
}
@@ -968,6 +984,7 @@ void SceneTree::_process_group(ProcessGroup *p_group, bool p_physics) {
968984
}
969985

970986
void SceneTree::_process_groups_thread(uint32_t p_index, bool p_physics) {
987+
ZoneScopedN("SceneTree::_process_groups_thread");
971988
Node::current_process_thread_group = local_process_group_cache[p_index]->owner;
972989
_process_group(local_process_group_cache[p_index], p_physics);
973990
Node::current_process_thread_group = nullptr;
@@ -1036,6 +1053,7 @@ void SceneTree::_process(bool p_physics) {
10361053
if (using_threads) {
10371054
local_process_group_cache.push_back(process_groups[j]);
10381055
} else {
1056+
ZoneScopedN("SceneTree::_process_group");
10391057
_process_group(process_groups[j], p_physics);
10401058
}
10411059
}

0 commit comments

Comments
 (0)