From edd1164575feefda103c73119a98cbd994e53141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Thu, 1 Oct 2020 23:16:01 +0200 Subject: Cycles: add time statistics to scene update Gathers information for time spent in the various managers or object (Film, Camera, etc.) being updated in Scene::device_update. The stats include the total time spent in the device_update methods as well as time spent in subroutines (e.g. bvh build, displacement, etc.). This does not qualify as a full blown profiler, but is useful to identify potential bottleneck areas. The stats can be enabled and printed by passing `--cycles-print-stats` on the command line to Cycles, or `-- --cycles-print-stats` to Blender. Reviewed By: brecht Maniphest Tasks: T79174 Differential Revision: https://developer.blender.org/D8596 --- intern/cycles/render/scene.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'intern/cycles/render/scene.cpp') diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp index 8f863b5d15f..e98b2c76e88 100644 --- a/intern/cycles/render/scene.cpp +++ b/intern/cycles/render/scene.cpp @@ -95,7 +95,8 @@ Scene::Scene(const SceneParams ¶ms_, Device *device) default_empty(NULL), device(device), dscene(device), - params(params_) + params(params_), + update_stats(NULL) { memset((void *)&dscene.data, 0, sizeof(dscene.data)); @@ -188,6 +189,7 @@ void Scene::free_memory(bool final) delete particle_system_manager; delete image_manager; delete bake_manager; + delete update_stats; } } @@ -198,6 +200,20 @@ void Scene::device_update(Device *device_, Progress &progress) bool print_stats = need_data_update(); + if (update_stats) { + update_stats->clear(); + } + + scoped_callback_timer timer([this, print_stats](double time) { + if (update_stats) { + update_stats->scene.times.add_entry({"device_update", time}); + + if (print_stats) { + printf("Update statistics:\n%s\n", update_stats->full_report().c_str()); + } + } + }); + /* The order of updates is important, because there's dependencies between * the different managers, using data computed by previous managers. * @@ -269,7 +285,7 @@ void Scene::device_update(Device *device_, Progress &progress) return; progress.set_status("Updating Lookup Tables"); - lookup_tables->device_update(device, &dscene); + lookup_tables->device_update(device, &dscene, this); if (progress.get_cancel() || device->have_error()) return; @@ -293,7 +309,7 @@ void Scene::device_update(Device *device_, Progress &progress) return; progress.set_status("Updating Lookup Tables"); - lookup_tables->device_update(device, &dscene); + lookup_tables->device_update(device, &dscene, this); if (progress.get_cancel() || device->have_error()) return; @@ -404,6 +420,13 @@ void Scene::collect_statistics(RenderStats *stats) image_manager->collect_statistics(stats); } +void Scene::enable_update_stats() +{ + if (!update_stats) { + update_stats = new SceneUpdateStats(); + } +} + DeviceRequestedFeatures Scene::get_requested_device_features() { DeviceRequestedFeatures requested_features; -- cgit v1.2.3