diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2020-10-02 00:16:01 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2020-10-02 00:21:11 +0300 |
commit | edd1164575feefda103c73119a98cbd994e53141 (patch) | |
tree | ae69e078944ba7f27ffbce6209e4eef6e17fca88 /intern/cycles/render/scene.cpp | |
parent | 342bdbc1769fa31c734d7c38ab67be3428c9d234 (diff) |
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
Diffstat (limited to 'intern/cycles/render/scene.cpp')
-rw-r--r-- | intern/cycles/render/scene.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
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; |