[Bf-blender-cvs] [d8a01b7970d] cycles-x: Cycles X: Convert pass fields to socket declarations

Sergey Sharybin noreply at git.blender.org
Mon Sep 13 16:51:26 CEST 2021


Commit: d8a01b7970dca774961d94ea86306e5b2deb7873
Author: Sergey Sharybin
Date:   Wed Sep 8 09:48:47 2021 +0200
Branches: cycles-x
https://developer.blender.org/rBd8a01b7970dca774961d94ea86306e5b2deb7873

Cycles X: Convert pass fields to socket declarations

No functional changes, just finalizes conversion of Pass to a proper
scene node.

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

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

M	intern/cycles/blender/blender_session.cpp
M	intern/cycles/blender/blender_sync.cpp
M	intern/cycles/integrator/pass_accessor.cpp
M	intern/cycles/render/buffers.cpp
M	intern/cycles/render/film.cpp
M	intern/cycles/render/pass.cpp
M	intern/cycles/render/pass.h
M	intern/cycles/render/session.cpp
M	intern/cycles/render/tile.cpp

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

diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index b26d3ad53af..1cfb7d062eb 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -634,9 +634,9 @@ void BlenderSession::bake(BL::Depsgraph &b_depsgraph_,
   /* Add render pass that we want to bake, and name it Combined so that it is
    * used as that on the Blender side. */
   Pass *pass = scene->create_node<Pass>();
-  pass->name = "Combined";
-  pass->type = bake_type_to_pass(bake_type, bake_filter);
-  pass->include_albedo = (bake_filter & BL::BakeSettings::pass_filter_COLOR);
+  pass->set_name(ustring("Combined"));
+  pass->set_type(bake_type_to_pass(bake_type, bake_filter));
+  pass->set_include_albedo((bake_filter & BL::BakeSettings::pass_filter_COLOR));
 
   session->read_render_tile_cb = [&]() { read_render_tile(); };
   session->write_render_tile_cb = [&]() { write_render_tile(); };
@@ -820,7 +820,7 @@ void BlenderSession::draw(BL::SpaceImageEditor &space_image)
       return;
     }
 
-    scene->film->set_display_pass(pass->type);
+    scene->film->set_display_pass(pass->get_type());
 
     draw_state_.last_pass_index = pass_index;
   }
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index 373e4237e3d..d6fc7ee1723 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -566,9 +566,9 @@ static Pass *pass_add(Scene *scene,
 {
   Pass *pass = scene->create_node<Pass>();
 
-  pass->type = type;
-  pass->name = name;
-  pass->mode = mode;
+  pass->set_type(type);
+  pass->set_name(ustring(name));
+  pass->set_mode(mode);
 
   return pass;
 }
diff --git a/intern/cycles/integrator/pass_accessor.cpp b/intern/cycles/integrator/pass_accessor.cpp
index 5054991dbe6..d1e0f3c1031 100644
--- a/intern/cycles/integrator/pass_accessor.cpp
+++ b/intern/cycles/integrator/pass_accessor.cpp
@@ -36,9 +36,9 @@ PassAccessor::PassAccessInfo::PassAccessInfo(const Pass &pass,
                                              const Film &film,
                                              const Background &background,
                                              const vector<Pass *> &passes)
-    : type(pass.type),
-      mode(pass.mode),
-      include_albedo(pass.include_albedo),
+    : type(pass.get_type()),
+      mode(pass.get_mode()),
+      include_albedo(pass.get_include_albedo()),
       offset(Pass::get_offset(passes, &pass)),
       use_approximate_shadow_catcher(film.get_use_approximate_shadow_catcher()),
       use_approximate_shadow_catcher_background(use_approximate_shadow_catcher &&
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index 1619651afaa..9d9f205b11b 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -43,7 +43,7 @@ static int pass_type_mode_to_index(PassType pass_type, PassMode mode)
 
 static int pass_to_index(const Pass *pass)
 {
-  return pass_type_mode_to_index(pass->type, pass->mode);
+  return pass_type_mode_to_index(pass->get_type(), pass->get_mode());
 }
 
 /* Buffer Params */
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index 747b825e687..05b511c9b25 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -147,7 +147,7 @@ Film::~Film()
 void Film::add_default(Scene *scene)
 {
   Pass *pass = scene->create_node<Pass>();
-  pass->type = PASS_COMBINED;
+  pass->set_type(PASS_COMBINED);
 }
 
 void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
@@ -207,11 +207,11 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
   for (size_t i = 0; i < scene->passes.size(); i++) {
     const Pass *pass = scene->passes[i];
 
-    if (pass->type == PASS_NONE || !pass->is_written()) {
+    if (pass->get_type() == PASS_NONE || !pass->is_written()) {
       continue;
     }
 
-    if (pass->mode == PassMode::DENOISED) {
+    if (pass->get_mode() == PassMode::DENOISED) {
       /* Generally we only storing offsets of the noisy passes. The display pass is an exception
        * since it is a read operation and not a write. */
       kfilm->pass_stride += pass->get_info().num_components;
@@ -219,25 +219,25 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
     }
 
     /* Can't do motion pass if no motion vectors are available. */
-    if (pass->type == PASS_MOTION || pass->type == PASS_MOTION_WEIGHT) {
+    if (pass->get_type() == PASS_MOTION || pass->get_type() == PASS_MOTION_WEIGHT) {
       if (scene->need_motion() != Scene::MOTION_PASS) {
         kfilm->pass_stride += pass->get_info().num_components;
         continue;
       }
     }
 
-    int pass_flag = (1 << (pass->type % 32));
-    if (pass->type <= PASS_CATEGORY_LIGHT_END) {
+    const int pass_flag = (1 << (pass->get_type() % 32));
+    if (pass->get_type() <= PASS_CATEGORY_LIGHT_END) {
       kfilm->light_pass_flag |= pass_flag;
     }
-    else if (pass->type <= PASS_CATEGORY_DATA_END) {
+    else if (pass->get_type() <= PASS_CATEGORY_DATA_END) {
       kfilm->pass_flag |= pass_flag;
     }
     else {
-      assert(pass->type <= PASS_CATEGORY_BAKE_END);
+      assert(pass->get_type() <= PASS_CATEGORY_BAKE_END);
     }
 
-    switch (pass->type) {
+    switch (pass->get_type()) {
       case PASS_COMBINED:
         kfilm->pass_combined = kfilm->pass_stride;
         break;
@@ -405,21 +405,21 @@ int Film::get_aov_offset(Scene *scene, string name, bool &is_color)
 {
   int offset_color = 0, offset_value = 0;
   foreach (const Pass *pass, scene->passes) {
-    if (pass->name == name) {
-      if (pass->type == PASS_AOV_VALUE) {
+    if (pass->get_name() == name) {
+      if (pass->get_type() == PASS_AOV_VALUE) {
         is_color = false;
         return offset_value;
       }
-      else if (pass->type == PASS_AOV_COLOR) {
+      else if (pass->get_type() == PASS_AOV_COLOR) {
         is_color = true;
         return offset_color;
       }
     }
 
-    if (pass->type == PASS_AOV_VALUE) {
+    if (pass->get_type() == PASS_AOV_VALUE) {
       offset_value += pass->get_info().num_components;
     }
-    else if (pass->type == PASS_AOV_COLOR) {
+    else if (pass->get_type() == PASS_AOV_COLOR) {
       offset_color += pass->get_info().num_components;
     }
   }
@@ -433,9 +433,9 @@ const Pass *Film::get_actual_display_pass(Scene *scene, const Pass *pass)
     return nullptr;
   }
 
-  if (pass->type == PASS_COMBINED && scene->has_shadow_catcher()) {
+  if (pass->get_type() == PASS_COMBINED && scene->has_shadow_catcher()) {
     const Pass *shadow_catcher_matte_pass = Pass::find(
-        scene->passes, PASS_SHADOW_CATCHER_MATTE, pass->mode);
+        scene->passes, PASS_SHADOW_CATCHER_MATTE, pass->get_mode());
     if (shadow_catcher_matte_pass) {
       pass = shadow_catcher_matte_pass;
     }
@@ -508,7 +508,7 @@ void Film::update_passes(Scene *scene, bool add_sample_count_pass)
 
   const vector<Pass *> passes_immutable = scene->passes;
   for (const Pass *pass : passes_immutable) {
-    const PassInfo info = Pass::get_info(pass->type, pass->include_albedo);
+    const PassInfo &info = pass->get_info();
     /* Add utility passes needed to generate some light passes. */
     if (info.divide_type != PASS_NONE) {
       add_auto_pass(scene, info.divide_type);
@@ -523,7 +523,7 @@ void Film::update_passes(Scene *scene, bool add_sample_count_pass)
     /* NOTE: Enable all denoised passes when storage is requested.
      * This way it is possible to tweak denoiser parameters later on. */
     if (info.support_denoise && use_denoise) {
-      add_auto_pass(scene, pass->type, PassMode::DENOISED);
+      add_auto_pass(scene, pass->get_type(), PassMode::DENOISED);
     }
   }
 
@@ -581,9 +581,9 @@ void Film::add_auto_pass(Scene *scene, PassType type, const char *name)
 void Film::add_auto_pass(Scene *scene, PassType type, PassMode mode, const char *name)
 {
   Pass *pass = new Pass();
-  pass->type = type;
-  pass->mode = mode;
-  pass->name = (name) ? name : "";
+  pass->set_type(type);
+  pass->set_mode(mode);
+  pass->set_name(ustring((name) ? name : ""));
   pass->is_auto_ = true;
 
   pass->set_owner(scene);
@@ -613,7 +613,7 @@ static bool compare_pass_order(const Pass *a, const Pass *b)
   const int num_components_b = b->get_info().num_components;
 
   if (num_components_a == num_components_b) {
-    return (a->type < b->type);
+    return (a->get_type() < b->get_type());
   }
 
   return num_components_a > num_components_b;
@@ -627,24 +627,26 @@ void Film::finalize_passes(Scene *scene, const bool use_denoise)
   for (Pass *pass : scene->passes) {
     /* Disable denoising on passes if denoising is disabled, or if the
      * pass does not support it. */
-    pass->mode = (use_denoise && pass->get_info().support_denoise) ? pass->mode : PassMode::NOISY;
+    pass->set_mode((use_denoise && pass->get_info().support_denoise) ? pass->get_mode() :
+                                                                       PassMode::NOISY);
 
     /* Merge duplicate passes. */
     bool duplicate_found = false;
     for (Pass *new_pass : new_passes) {
       /* If different type or denoising, don't merge. */
-      if (new_pass->type != pass->type || new_pass->mode != pass->mode) {
+      if (new_pass->get_type() != pass->get_type() || new_pass->get_mode() != pass->get_mode()) {
         continue;
       }
 
       /* If both passes have a name and the names are different, don't merge.
        * If either pass has a name, we'll use that name. */
-      if (!pass->name.empty() && !new_pass->name.empty() && pass->name != new_pass->name) {
+      if (!pass->get_name().empty() && !new_pass->get_name().empty() &&
+          pass->get_name() != new_pass->get_name()) {
         continue;
       }
 
-      if (!pass->name.empty() && new_pass->name.empty()) {
-        new_pass->name = pass->name;
+      if (!pass->get_name().empty() && new_pass->get_name().empty()) {
+        new_pass->set_name(pass->get_name());
       }
 
       new_pass->is_auto_ &= pass->is_auto_;
@@ -677,21 +679,24 @@ uint Film::get_kernel_features(const Scene *scene) const
       continue;
     }
 
-   

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list