131
131
#endif // TOOLS_ENABLED && !GDSCRIPT_NO_LSP
132
132
#endif // MODULE_GDSCRIPT_ENABLED
133
133
134
+ #ifdef MODULE_GODOT_TRACY_ENABLED
135
+ #include " modules/godot_tracy/profiler.h"
136
+ #else
137
+ // Dummy defines to allow compiling without tracy.
138
+ #define ZoneScoped
139
+ #define ZoneScopedN (a )
140
+ #endif // MODULE_GODOT_TRACY_ENABLED
141
+
134
142
/* Static members */
135
143
136
144
// Singletons
@@ -3999,6 +4007,7 @@ static uint64_t navigation_process_max = 0;
3999
4007
// will terminate the program. In case of failure, the OS exit code needs
4000
4008
// to be set explicitly here (defaults to EXIT_SUCCESS).
4001
4009
bool Main::iteration () {
4010
+ ZoneScoped;
4002
4011
iterating++;
4003
4012
4004
4013
const uint64_t ticks = OS::get_singleton ()->get_ticks_usec ();
@@ -4044,6 +4053,8 @@ bool Main::iteration() {
4044
4053
NavigationServer2D::get_singleton ()->sync ();
4045
4054
NavigationServer3D::get_singleton ()->sync ();
4046
4055
4056
+ {
4057
+ ZoneScopedN (" PHYSICS LOOP" );
4047
4058
for (int iters = 0 ; iters < advance.physics_steps ; ++iters) {
4048
4059
if (Input::get_singleton ()->is_agile_input_event_flushing ()) {
4049
4060
Input::get_singleton ()->flush_buffered_events ();
@@ -4055,17 +4066,26 @@ bool Main::iteration() {
4055
4066
uint64_t physics_begin = OS::get_singleton ()->get_ticks_usec ();
4056
4067
4057
4068
#ifndef _3D_DISABLED
4069
+ {
4070
+ ZoneScopedN (" Godot physics 3D - sync" );
4058
4071
PhysicsServer3D::get_singleton ()->sync ();
4059
4072
PhysicsServer3D::get_singleton ()->flush_queries ();
4073
+ }
4060
4074
#endif // _3D_DISABLED
4061
4075
4062
4076
// Prepare the fixed timestep interpolated nodes BEFORE they are updated
4063
4077
// by the physics server, otherwise the current and previous transforms
4064
4078
// may be the same, and no interpolation takes place.
4065
4079
OS::get_singleton ()->get_main_loop ()->iteration_prepare ();
4066
4080
4081
+ {
4082
+ ZoneScopedN (" Godot physics 2D - sync" );
4067
4083
PhysicsServer2D::get_singleton ()->sync ();
4068
4084
PhysicsServer2D::get_singleton ()->flush_queries ();
4085
+ }
4086
+
4087
+ {
4088
+ ZoneScopedN (" physics_process" );
4069
4089
4070
4090
if (OS::get_singleton ()->get_main_loop ()->physics_process (physics_step * time_scale)) {
4071
4091
#ifndef _3D_DISABLED
@@ -4076,23 +4096,33 @@ bool Main::iteration() {
4076
4096
exit = true ;
4077
4097
break ;
4078
4098
}
4099
+ }
4079
4100
4080
4101
uint64_t navigation_begin = OS::get_singleton ()->get_ticks_usec ();
4081
4102
4103
+ {
4104
+ ZoneScopedN (" Navigation process" );
4082
4105
NavigationServer3D::get_singleton ()->process (physics_step * time_scale);
4106
+ }
4083
4107
4084
4108
navigation_process_ticks = MAX (navigation_process_ticks, OS::get_singleton ()->get_ticks_usec () - navigation_begin); // keep the largest one for reference
4085
4109
navigation_process_max = MAX (OS::get_singleton ()->get_ticks_usec () - navigation_begin, navigation_process_max);
4086
4110
4087
4111
message_queue->flush ();
4088
4112
4089
4113
#ifndef _3D_DISABLED
4114
+ {
4115
+ ZoneScopedN (" Godot physics 3D - step" );
4090
4116
PhysicsServer3D::get_singleton ()->end_sync ();
4091
4117
PhysicsServer3D::get_singleton ()->step (physics_step * time_scale);
4118
+ }
4092
4119
#endif // _3D_DISABLED
4093
4120
4121
+ {
4122
+ ZoneScopedN (" Godot physics 2D - step" );
4094
4123
PhysicsServer2D::get_singleton ()->end_sync ();
4095
4124
PhysicsServer2D::get_singleton ()->step (physics_step * time_scale);
4125
+ }
4096
4126
4097
4127
message_queue->flush ();
4098
4128
@@ -4101,18 +4131,24 @@ bool Main::iteration() {
4101
4131
4102
4132
Engine::get_singleton ()->_in_physics = false ;
4103
4133
}
4134
+ }
4104
4135
4105
4136
if (Input::get_singleton ()->is_agile_input_event_flushing ()) {
4106
4137
Input::get_singleton ()->flush_buffered_events ();
4107
4138
}
4108
4139
4109
4140
uint64_t process_begin = OS::get_singleton ()->get_ticks_usec ();
4110
4141
4142
+ {
4143
+ ZoneScopedN (" Main process" );
4111
4144
if (OS::get_singleton ()->get_main_loop ()->process (process_step * time_scale)) {
4112
4145
exit = true ;
4113
4146
}
4147
+ }
4114
4148
message_queue->flush ();
4115
4149
4150
+ {
4151
+ ZoneScopedN (" Main::iteration - Draw" );
4116
4152
RenderingServer::get_singleton ()->sync (); // sync if still drawing from previous frames.
4117
4153
4118
4154
if ((DisplayServer::get_singleton ()->can_any_window_draw () || DisplayServer::get_singleton ()->has_additional_outputs ()) &&
@@ -4128,16 +4164,23 @@ bool Main::iteration() {
4128
4164
force_redraw_requested = false ;
4129
4165
}
4130
4166
}
4167
+ }
4131
4168
4132
4169
process_ticks = OS::get_singleton ()->get_ticks_usec () - process_begin;
4133
4170
process_max = MAX (process_ticks, process_max);
4134
4171
uint64_t frame_time = OS::get_singleton ()->get_ticks_usec () - ticks;
4135
4172
4173
+ {
4174
+ ZoneScopedN (" Languages update" );
4136
4175
for (int i = 0 ; i < ScriptServer::get_language_count (); i++) {
4137
4176
ScriptServer::get_language (i)->frame ();
4138
4177
}
4178
+ }
4139
4179
4180
+ {
4181
+ ZoneScopedN (" Audio update" );
4140
4182
AudioServer::get_singleton ()->update ();
4183
+ }
4141
4184
4142
4185
if (EngineDebugger::is_active ()) {
4143
4186
EngineDebugger::get_singleton ()->iteration (frame_time, process_ticks, physics_process_ticks, physics_step);
@@ -4198,7 +4241,10 @@ bool Main::iteration() {
4198
4241
return exit ;
4199
4242
}
4200
4243
4244
+ {
4245
+ ZoneScopedN (" Frame delay" );
4201
4246
OS::get_singleton ()->add_frame_delay (DisplayServer::get_singleton ()->window_can_draw ());
4247
+ }
4202
4248
4203
4249
#ifdef TOOLS_ENABLED
4204
4250
if (auto_build_solutions) {
0 commit comments