From bbe6d44928235cd4a5cfbeaf1a1de78ed861bb92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Fri, 22 Jan 2021 15:01:26 +0100 Subject: Cycles: optimize device updates This optimizes device updates (during user edits or frame changes in the viewport) by avoiding unnecessary computations. To achieve this, we use a combination of the sockets' update flags as well as some new flags passed to the various managers when tagging for an update to tell exactly what the tagging is for (e.g. shader was modified, object was removed, etc.). Besides avoiding recomputations, we also avoid resending to the devices unmodified data arrays, thus reducing bandwidth usage. For OptiX and Embree, BVH packing was also multithreaded. The performance improvements may vary depending on the used device (CPU or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive subdivision or volumes) rendered using OptiX will benefit from this work the most. On average, for a variety of animated scenes, this gives a 3x speedup. Reviewed By: #cycles, brecht Maniphest Tasks: T79174 Differential Revision: https://developer.blender.org/D9555 --- intern/cycles/render/tables.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'intern/cycles/render/tables.cpp') diff --git a/intern/cycles/render/tables.cpp b/intern/cycles/render/tables.cpp index b581537c852..a0813400b1c 100644 --- a/intern/cycles/render/tables.cpp +++ b/intern/cycles/render/tables.cpp @@ -28,7 +28,7 @@ CCL_NAMESPACE_BEGIN LookupTables::LookupTables() { - need_update = true; + need_update_ = true; } LookupTables::~LookupTables() @@ -38,7 +38,7 @@ LookupTables::~LookupTables() void LookupTables::device_update(Device *, DeviceScene *dscene, Scene *scene) { - if (!need_update) + if (!need_update()) return; scoped_callback_timer timer([scene](double time) { @@ -52,7 +52,7 @@ void LookupTables::device_update(Device *, DeviceScene *dscene, Scene *scene) if (lookup_tables.size() > 0) dscene->lookup_table.copy_to_device(); - need_update = false; + need_update_ = false; } void LookupTables::device_free(Device *, DeviceScene *dscene) @@ -60,6 +60,11 @@ void LookupTables::device_free(Device *, DeviceScene *dscene) dscene->lookup_table.free(); } +bool LookupTables::need_update() const +{ + return need_update_; +} + static size_t round_up_to_multiple(size_t size, size_t chunk) { return ((size + chunk - 1) / chunk) * chunk; @@ -69,7 +74,7 @@ size_t LookupTables::add_table(DeviceScene *dscene, vector &data) { assert(data.size() > 0); - need_update = true; + need_update_ = true; Table new_table; new_table.offset = 0; @@ -107,7 +112,7 @@ void LookupTables::remove_table(size_t *offset) return; } - need_update = true; + need_update_ = true; list::iterator table; -- cgit v1.2.3