[Bf-blender-cvs] [36a573c09df] cycles-x: Cycles X: Don't cache Pass info as a field

Sergey Sharybin noreply at git.blender.org
Thu Sep 9 12:35:03 CEST 2021


Commit: 36a573c09df80522b7906b94d97101fa1511944f
Author: Sergey Sharybin
Date:   Wed Sep 8 18:24:10 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB36a573c09df80522b7906b94d97101fa1511944f

Cycles X: Don't cache Pass info as a field

Avoiding such caching makes the Pass to fit generic nodes much
better: no need to worry about maintaining the information in
sync with the socket values.

The PassInfo construction is cheap, so the change should not
cause any time penalties.

No functional changes, just making Pass more re-usable outside
of Scene/Film for an upcoming development.

Differential Revision: https://developer.blender.org/D12431

===================================================================

M	intern/cycles/render/film.cpp
M	intern/cycles/render/pass.cpp
M	intern/cycles/render/pass.h

===================================================================

diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index 53854668783..014e9172c15 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -637,11 +637,9 @@ void Film::finalize_passes(Scene *scene, const bool use_denoise)
   vector<Pass *> new_passes;
 
   for (Pass *pass : scene->passes) {
-    pass->info_ = Pass::get_info(pass->type, pass->include_albedo);
-
     /* Disable denoising on passes if denoising is disabled, or if the
      * pass does not support it. */
-    pass->mode = (use_denoise && pass->info_.support_denoise) ? pass->mode : PassMode::NOISY;
+    pass->mode = (use_denoise && pass->get_info().support_denoise) ? pass->mode : PassMode::NOISY;
 
     /* Merge duplicate passes. */
     bool duplicate_found = false;
diff --git a/intern/cycles/render/pass.cpp b/intern/cycles/render/pass.cpp
index 799cd6c5cec..8e3f82a9f95 100644
--- a/intern/cycles/render/pass.cpp
+++ b/intern/cycles/render/pass.cpp
@@ -144,14 +144,14 @@ Pass::Pass() : Node(get_node_type()), is_auto_(false)
 {
 }
 
-const PassInfo &Pass::get_info() const
+PassInfo Pass::get_info() const
 {
-  return info_;
+  return get_info(type, include_albedo);
 }
 
 bool Pass::is_written() const
 {
-  return info_.is_written;
+  return get_info().is_written;
 }
 
 PassInfo Pass::get_info(const PassType type, const bool include_albedo)
diff --git a/intern/cycles/render/pass.h b/intern/cycles/render/pass.h
index b2846942e5d..18348990045 100644
--- a/intern/cycles/render/pass.h
+++ b/intern/cycles/render/pass.h
@@ -69,7 +69,7 @@ class Pass : public Node {
 
   Pass();
 
-  const PassInfo &get_info() const;
+  PassInfo get_info() const;
 
   /* The pass is written by the render pipeline (kernel or denoiser). If the pass is written it
    * will have pixels allocated in a RenderBuffer. Passes which are not written do not have their
@@ -77,8 +77,6 @@ class Pass : public Node {
   bool is_written() const;
 
  protected:
-  PassInfo info_;
-
   /* The has been created automatically as a requirement to various rendering functionality (such
    * as adaptive sampling). */
   bool is_auto_;



More information about the Bf-blender-cvs mailing list