summaryrefslogtreecommitdiff
path: root/servers/rendering
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2020-12-24 00:13:52 -0300
committerreduz <reduzio@gmail.com>2020-12-24 00:13:52 -0300
commit7219f37cb5738190b2b11c27c4e6a9a0ce5ecd30 (patch)
tree1267e7db2c8cae27713e5cdf4b43f75415c341f7 /servers/rendering
parent169159c8aac5807725594145bf029c0ff7ac8ef1 (diff)
Add API to get frame setup time on CPU
Needed for benchmarks
Diffstat (limited to 'servers/rendering')
-rw-r--r--servers/rendering/rendering_server_default.cpp9
-rw-r--r--servers/rendering/rendering_server_default.h4
-rw-r--r--servers/rendering/rendering_server_wrap_mt.h4
3 files changed, 17 insertions, 0 deletions
diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp
index 8c7c25c19b..da6c3ef6f4 100644
--- a/servers/rendering/rendering_server_default.cpp
+++ b/servers/rendering/rendering_server_default.cpp
@@ -101,11 +101,16 @@ void RenderingServerDefault::draw(bool p_swap_buffers, double frame_step) {
TIMESTAMP_BEGIN()
+ uint64_t time_usec = OS::get_singleton()->get_ticks_usec();
+
RSG::scene->update(); //update scenes stuff before updating instances
+ frame_setup_time = double(OS::get_singleton()->get_ticks_usec() - time_usec) / 1000.0;
+
RSG::storage->update_particles(); //need to be done after instances are updated (colliders and particle transforms), and colliders are rendered
RSG::scene->render_probes();
+
RSG::viewport->draw_viewports();
RSG::canvas_render->update();
@@ -159,6 +164,10 @@ void RenderingServerDefault::draw(bool p_swap_buffers, double frame_step) {
frame_profile_frame = RSG::storage->get_captured_timestamps_frame();
}
+float RenderingServerDefault::get_frame_setup_time_cpu() const {
+ return frame_setup_time;
+}
+
void RenderingServerDefault::sync() {
}
diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h
index 11220dcf79..922cf08f3b 100644
--- a/servers/rendering/rendering_server_default.h
+++ b/servers/rendering/rendering_server_default.h
@@ -72,6 +72,8 @@ class RenderingServerDefault : public RenderingServer {
uint64_t frame_profile_frame;
Vector<FrameProfileArea> frame_profile;
+ float frame_setup_time = 0;
+
public:
//if editor is redrawing when it shouldn't, enable this and put a breakpoint in _changes_changed()
//#define DEBUG_CHANGES
@@ -845,6 +847,8 @@ public:
/* TESTING */
+ virtual float get_frame_setup_time_cpu() const;
+
virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true);
virtual void set_default_clear_color(const Color &p_color);
diff --git a/servers/rendering/rendering_server_wrap_mt.h b/servers/rendering/rendering_server_wrap_mt.h
index ec71178dae..1e6c3b8f71 100644
--- a/servers/rendering/rendering_server_wrap_mt.h
+++ b/servers/rendering/rendering_server_wrap_mt.h
@@ -776,6 +776,10 @@ public:
return rendering_server->get_frame_profile();
}
+ virtual float get_frame_setup_time_cpu() const {
+ return rendering_server->get_frame_setup_time_cpu();
+ }
+
virtual void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) {
rendering_server->sdfgi_set_debug_probe_select(p_position, p_dir);
}