summaryrefslogtreecommitdiff
path: root/servers/visual/visual_server_raster.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2019-09-20 17:58:06 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-11 12:01:26 +0100
commit123ee5995c989d7c2f0bb320fe94ef1702a48c13 (patch)
tree97855b3218f56dcaaeb5e737bf1a919f28ac36db /servers/visual/visual_server_raster.cpp
parentdc32083681a770e9d7e332c5beed30b52c793752 (diff)
Visual GPU profiler and related profiling support in Vulkan.
Diffstat (limited to 'servers/visual/visual_server_raster.cpp')
-rw-r--r--servers/visual/visual_server_raster.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 2f25b8b015..513393c9c9 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -103,12 +103,14 @@ void VisualServerRaster::draw(bool p_swap_buffers, double frame_step) {
VSG::rasterizer->begin_frame(frame_step);
+ VSG::storage->capture_timestamps_begin();
+
VSG::scene_render->update(); //update scenes stuff before updating instances
VSG::scene->update_dirty_instances(); //update scene stuff
- VSG::viewport->draw_viewports();
VSG::scene->render_probes();
+ VSG::viewport->draw_viewports();
VSG::canvas_render->update();
_draw_margins();
@@ -130,6 +132,25 @@ void VisualServerRaster::draw(bool p_swap_buffers, double frame_step) {
frame_drawn_callbacks.pop_front();
}
VS::get_singleton()->emit_signal("frame_post_draw");
+
+ if (VSG::storage->get_captured_timestamps_count()) {
+ Vector<FrameProfileArea> new_profile;
+ new_profile.resize(VSG::storage->get_captured_timestamps_count());
+
+ uint64_t base_cpu = VSG::storage->get_captured_timestamp_cpu_time(0);
+ uint64_t base_gpu = VSG::storage->get_captured_timestamp_gpu_time(0);
+ for (int i = 0; i < VSG::storage->get_captured_timestamps_count(); i++) {
+ uint64_t time_cpu = VSG::storage->get_captured_timestamp_cpu_time(i) - base_cpu;
+ uint64_t time_gpu = VSG::storage->get_captured_timestamp_gpu_time(i) - base_gpu;
+ new_profile.write[i].gpu_msec = float(time_gpu / 1000) / 1000.0;
+ new_profile.write[i].cpu_msec = float(time_cpu) / 1000.0;
+ new_profile.write[i].name = VSG::storage->get_captured_timestamp_name(i);
+ }
+
+ frame_profile = new_profile;
+ }
+
+ frame_profile_frame = VSG::storage->get_captured_timestamps_frame();
}
void VisualServerRaster::sync() {
}
@@ -167,6 +188,18 @@ String VisualServerRaster::get_video_adapter_vendor() const {
return VSG::storage->get_video_adapter_vendor();
}
+void VisualServerRaster::set_frame_profiling_enabled(bool p_enable) {
+ VSG::storage->capturing_timestamps = p_enable;
+}
+
+uint64_t VisualServerRaster::get_frame_profile_frame() {
+ return frame_profile_frame;
+}
+
+Vector<VisualServer::FrameProfileArea> VisualServerRaster::get_frame_profile() {
+ return frame_profile;
+}
+
/* TESTING */
void VisualServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
@@ -217,6 +250,8 @@ VisualServerRaster::VisualServerRaster() {
VSG::canvas_render = VSG::rasterizer->get_canvas();
VSG::scene_render = VSG::rasterizer->get_scene();
+ frame_profile_frame = 0;
+
for (int i = 0; i < 4; i++) {
black_margin[i] = 0;
black_image[i] = RID();