diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-01-22 17:01:26 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-01-22 18:08:25 +0300 |
commit | bbe6d44928235cd4a5cfbeaf1a1de78ed861bb92 (patch) | |
tree | c3a8653dfdf38029caebfd9978ea4644535bae3d /intern/cycles/render/shader.h | |
parent | 131a758b6f88a2be816e9351d216bcfb9c965c4b (diff) |
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
Diffstat (limited to 'intern/cycles/render/shader.h')
-rw-r--r-- | intern/cycles/render/shader.h | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h index de19048d8e1..4375ef9e978 100644 --- a/intern/cycles/render/shader.h +++ b/intern/cycles/render/shader.h @@ -100,7 +100,9 @@ class Shader : public Node { float prev_volume_step_rate; /* synchronization */ - bool need_update_geometry; + bool need_update_uvs; + bool need_update_attribute; + bool need_update_displacement; /* If the shader has only volume components, the surface is assumed to * be transparent. @@ -152,6 +154,8 @@ class Shader : public Node { void set_graph(ShaderGraph *graph); void tag_update(Scene *scene); void tag_used(Scene *scene); + + bool need_update_geometry() const; }; /* Shader Manager virtual base class @@ -161,7 +165,16 @@ class Shader : public Node { class ShaderManager { public: - bool need_update; + enum : uint32_t { + SHADER_ADDED = (1 << 0), + SHADER_MODIFIED = (1 << 2), + INTEGRATOR_MODIFIED = (1 << 3), + + /* tag everything in the manager for an update */ + UPDATE_ALL = ~0u, + + UPDATE_NONE = 0u, + }; static ShaderManager *create(int shadingsystem); virtual ~ShaderManager(); @@ -204,9 +217,15 @@ class ShaderManager { string get_cryptomatte_materials(Scene *scene); + void tag_update(Scene *scene, uint32_t flag); + + bool need_update() const; + protected: ShaderManager(); + uint32_t update_flags; + typedef unordered_map<ustring, uint, ustringHash> AttributeIDMap; AttributeIDMap unique_attribute_id; |