summaryrefslogtreecommitdiff
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
parent169159c8aac5807725594145bf029c0ff7ac8ef1 (diff)
Add API to get frame setup time on CPU
Needed for benchmarks
-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
-rw-r--r--servers/rendering_server.cpp3
-rw-r--r--servers/rendering_server.h2
5 files changed, 22 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);
}
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index 4dcb7aa79c..73e382a5ba 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -1817,6 +1817,9 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_render_loop_enabled"), &RenderingServer::is_render_loop_enabled);
ClassDB::bind_method(D_METHOD("set_render_loop_enabled", "enabled"), &RenderingServer::set_render_loop_enabled);
+
+ ClassDB::bind_method(D_METHOD("get_frame_setup_time_cpu"), &RenderingServer::get_frame_setup_time_cpu);
+
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_loop_enabled"), "set_render_loop_enabled", "is_render_loop_enabled");
BIND_CONSTANT(NO_INDEX_ARRAY);
diff --git a/servers/rendering_server.h b/servers/rendering_server.h
index 4dc4f332fa..f403264a96 100644
--- a/servers/rendering_server.h
+++ b/servers/rendering_server.h
@@ -1409,6 +1409,8 @@ public:
virtual Vector<FrameProfileArea> get_frame_profile() = 0;
virtual uint64_t get_frame_profile_frame() = 0;
+ virtual float get_frame_setup_time_cpu() const = 0;
+
/* TESTING */
virtual RID get_test_cube() = 0;