1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Visual GPU profiler and related profiling support in Vulkan.

This commit is contained in:
Juan Linietsky
2019-09-20 17:58:06 -03:00
parent dc32083681
commit 123ee5995c
23 changed files with 1418 additions and 17 deletions

View File

@@ -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();