Skip to content

Commit

Permalink
Added more profiler points for tracy.
Browse files Browse the repository at this point in the history
  • Loading branch information
jitspoe committed Nov 26, 2024
1 parent 9b04659 commit 4404bfe
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
6 changes: 5 additions & 1 deletion scene/animation/animation_mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ void AnimationMixer::_init_root_motion_cache() {
}

bool AnimationMixer::_update_caches() {
ZoneScopedN("AnimationMixer::_update_caches");
setup_pass++;

root_motion_cache.loc = Vector3(0, 0, 0);
Expand Down Expand Up @@ -978,7 +979,7 @@ Variant AnimationMixer::_post_process_key_value(const Ref<Animation> &p_anim, in
}

void AnimationMixer::_blend_init() {
ZoneScopedN("AnimationPlayer::_blend_init");
ZoneScopedN("AnimationMixer::_blend_init");
// Check all tracks, see if they need modification.
root_motion_position = Vector3(0, 0, 0);
root_motion_rotation = Quaternion(0, 0, 0, 1);
Expand All @@ -994,6 +995,8 @@ void AnimationMixer::_blend_init() {
}

// Init all value/transform/blend/bezier tracks that track_cache has.
{
ZoneScopedN("AnimationMixer::for_loop_track_cache");
for (const KeyValue<Animation::TypeHash, TrackCache *> &K : track_cache) {
TrackCache *track = K.value;

Expand Down Expand Up @@ -1033,6 +1036,7 @@ void AnimationMixer::_blend_init() {
} break;
}
}
}
}

bool AnimationMixer::_blend_pre_process(double p_delta, int p_track_count, const HashMap<NodePath, int> &p_track_map) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "render_forward_clustered.h"
#include "core/config/project_settings.h"
#include "core/object/worker_thread_pool.h"
#include "modules/godot_tracy/profiler.h"
#include "servers/rendering/renderer_rd/framebuffer_cache_rd.h"
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
#include "servers/rendering/renderer_rd/storage_rd/light_storage.h"
Expand Down Expand Up @@ -1407,6 +1408,7 @@ void RenderForwardClustered::_pre_opaque_render(RenderDataRD *p_render_data, boo
}
}

ZoneScopedN("Render OmniLight Shadows");
RENDER_TIMESTAMP("Render OmniLight Shadows");
// Cube shadows are rendered in their own way.
for (const int &index : p_render_data->cube_shadows) {
Expand Down
5 changes: 4 additions & 1 deletion servers/rendering/renderer_scene_cull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3207,7 +3207,7 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c
if (p_using_shadows) { //setup shadow maps

// Directional Shadows

RENDER_TIMESTAMP("Render Directional Shadows");
for (uint32_t i = 0; i < cull.shadow_count; i++) {
for (uint32_t j = 0; j < cull.shadows[i].cascade_count; j++) {
const Cull::Shadow::Cascade &c = cull.shadows[i].cascades[j];
Expand All @@ -3223,7 +3223,9 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c
}
}


// Positional Shadows
RENDER_TIMESTAMP("> Render Positional Shadows");
for (uint32_t i = 0; i < (uint32_t)scene_cull_result.lights.size(); i++) {
Instance *ins = scene_cull_result.lights[i];

Expand Down Expand Up @@ -3349,6 +3351,7 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c
}
}
}
RENDER_TIMESTAMP("< Render Positional Shadows");
}

//render SDFGI
Expand Down
20 changes: 15 additions & 5 deletions servers/rendering/renderer_viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Vector<RendererViewport::Viewport *> RendererViewport::_sort_active_viewports()
}

void RendererViewport::_configure_3d_render_buffers(Viewport *p_viewport) {
ZoneScopedN("RendererViewport::_configure_3d_render_buffers");
if (p_viewport->render_buffers.is_valid()) {
if (p_viewport->size.width == 0 || p_viewport->size.height == 0) {
p_viewport->render_buffers.unref();
Expand Down Expand Up @@ -223,6 +224,7 @@ void RendererViewport::_configure_3d_render_buffers(Viewport *p_viewport) {

void RendererViewport::_draw_3d(Viewport *p_viewport) {
#ifndef _3D_DISABLED
ZoneScopedN("RendererViewport::_draw_3d");
RENDER_TIMESTAMP("> Render 3D Scene");

Ref<XRInterface> xr_interface;
Expand Down Expand Up @@ -317,6 +319,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
}

if (can_draw_2d) {
ZoneScopedN("RendererViewport::can_draw_2d");
RBMap<Viewport::CanvasKey, Viewport::CanvasData *> canvas_map;

Rect2 clip_rect(0, 0, p_viewport->size.x, p_viewport->size.y);
Expand Down Expand Up @@ -647,11 +650,13 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
}

if (RSG::texture_storage->render_target_is_clear_requested(p_viewport->render_target)) {
ZoneScopedN("RendererViewport::render_target_do_clear_request");
//was never cleared in the end, force clear it
RSG::texture_storage->render_target_do_clear_request(p_viewport->render_target);
}

if (RSG::texture_storage->render_target_get_msaa_needs_resolve(p_viewport->render_target)) {
ZoneScopedN("RendererViewport::render_target_do_msaa_resolve");
WARN_PRINT_ONCE("2D MSAA is enabled while there is no 2D content. Disable 2D MSAA for better performance.");
RSG::texture_storage->render_target_do_msaa_resolve(p_viewport->render_target);
}
Expand All @@ -666,7 +671,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
void RendererViewport::draw_viewports(bool p_swap_buffers) {
ZoneScopedN("RendererViewport::draw_viewports");
timestamp_vp_map.clear();
RENDER_TIMESTAMP("> Render Viewports");

TracyCZoneN(tracy_predraw, "pre-draw", true);
#ifndef _3D_DISABLED
// get our xr interface in case we need it
Ref<XRInterface> xr_interface;
Expand All @@ -688,10 +695,11 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) {
sorted_active_viewports = _sort_active_viewports();
sorted_active_viewports_dirty = false;
}
TracyCZoneEnd(tracy_predraw);

TracyCZoneN(tracy_draw_viewports, "draw viewports", true);
HashMap<DisplayServer::WindowID, Vector<BlitToScreen>> blit_to_screen_list;
//draw viewports
RENDER_TIMESTAMP("> Render Viewports");

//determine what is visible
draw_viewports_pass++;
Expand Down Expand Up @@ -762,6 +770,7 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) {
continue; //should not draw
}

ZoneScopedN("Render Viewport");
RENDER_TIMESTAMP("> Render Viewport " + itos(i));

RSG::texture_storage->render_target_set_as_unused(vp->render_target);
Expand Down Expand Up @@ -840,8 +849,6 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) {
vp->update_mode = RS::VIEWPORT_UPDATE_DISABLED;
}

RENDER_TIMESTAMP("< Render Viewport " + itos(i));

// 3D render info.
objects_drawn += vp->render_info.info[RS::VIEWPORT_RENDER_INFO_TYPE_VISIBLE][RS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] + vp->render_info.info[RS::VIEWPORT_RENDER_INFO_TYPE_SHADOW][RS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME];
vertices_drawn += vp->render_info.info[RS::VIEWPORT_RENDER_INFO_TYPE_VISIBLE][RS::VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME] + vp->render_info.info[RS::VIEWPORT_RENDER_INFO_TYPE_SHADOW][RS::VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME];
Expand All @@ -850,20 +857,23 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) {
objects_drawn += vp->render_info.info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME];
vertices_drawn += vp->render_info.info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME];
draw_calls_used += vp->render_info.info[RS::VIEWPORT_RENDER_INFO_TYPE_CANVAS][RS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME];

RENDER_TIMESTAMP("< Render Viewport " + itos(i));
}
RSG::scene->set_debug_draw_mode(RS::VIEWPORT_DEBUG_DRAW_DISABLED);

total_objects_drawn = objects_drawn;
total_vertices_drawn = vertices_drawn;
total_draw_calls_used = draw_calls_used;

RENDER_TIMESTAMP("< Render Viewports");

if (p_swap_buffers && !blit_to_screen_list.is_empty()) {
for (const KeyValue<int, Vector<BlitToScreen>> &E : blit_to_screen_list) {
RSG::rasterizer->blit_render_targets_to_screen(E.key, E.value.ptr(), E.value.size());
}
}

TracyCZoneEnd(tracy_draw_viewports);
RENDER_TIMESTAMP("< Render Viewports");
}

RID RendererViewport::viewport_allocate() {
Expand Down

0 comments on commit 4404bfe

Please sign in to comment.