[Bf-blender-cvs] [6e654396323] temp-viewport-compositor-compiler: Viewport Compositor: Map input processors results directly

Omar Emara noreply at git.blender.org
Mon Mar 14 12:01:11 CET 2022


Commit: 6e6543963238a98a01f719b4963e0e38d5aad1e8
Author: Omar Emara
Date:   Mon Mar 14 10:12:21 2022 +0200
Branches: temp-viewport-compositor-compiler
https://developer.blender.org/rB6e6543963238a98a01f719b4963e0e38d5aad1e8

Viewport Compositor: Map input processors results directly

Remove unnecessary logic to delay the mapping of the input processor
result. This can be readded if proven really needed in the future.

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

M	source/blender/nodes/NOD_compositor_execute.hh
M	source/blender/nodes/intern/node_compositor_execute.cc

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

diff --git a/source/blender/nodes/NOD_compositor_execute.hh b/source/blender/nodes/NOD_compositor_execute.hh
index 0d95210a448..cf15d84b3f4 100644
--- a/source/blender/nodes/NOD_compositor_execute.hh
+++ b/source/blender/nodes/NOD_compositor_execute.hh
@@ -403,8 +403,8 @@ class Operation {
   Result &get_input(StringRef identifier) const;
 
   /* Switch the result mapped to the input identified by the given identifier with the given
-   * result. This will involve releasing original result, but it is assumed that the result will be
-   * mapped to something else. */
+   * result. This will involve releasing the original result, but it is assumed that the result
+   * will be mapped to something else. */
   void switch_result_mapped_to_input(StringRef identifier, Result *result);
 
   /* Add the given result to the results_ map identified by the given output identifier. This
@@ -427,14 +427,10 @@ class Operation {
   TexturePool &texture_pool();
 
  private:
-  /* Add all the necessary input processors for each input as needed. Then update the mapped result
-   * for each input to be that of the last processor for that input if any input processors exist
-   * for it. This is done now in a separate step after all processors were added because the
-   * operation might use the original mapped results to determine what processors needs to be
-   * added. This method is called in the operation initialization method after pre_allocate but
-   * before the allocate method, it needs to happen then and not before at operation construction
-   * because the logic for adding input processors can depend on the nature of the input results,
-   * but not on their value. */
+  /* Add all the necessary input processors for each input as needed. This method is called in the
+   * operation initialization method after pre_allocate but before the allocate method, it needs to
+   * happen then and not before at operation construction because the logic for adding input
+   * processors can depend on the nature of the input results, but not on their value. */
   void add_input_processors();
 
   /* Add an implicit conversion input processor for the input identified by the given identifier if
@@ -446,9 +442,10 @@ class Operation {
   void add_realize_on_domain_input_processor_if_needed(StringRef identifier);
 
   /* Add the given input processor operation to the list of input processors for the input
-   * identified by the given identifier. The result of the last input processor will not be mapped
-   * to the input in this method, this is done later, see add_input_processors for more
-   * information. */
+   * identified by the given identifier. This will also involve mapping the input of the processor
+   * to be the result of the last input processor or the result mapped to the input if no previous
+   * processors exists. Finally, the result mapped to the input is switched to be the result of the
+   * newly added processor. */
   void add_input_processor(StringRef identifier, ProcessorOperation *processor);
 
   /* Allocate all input processors in order. This is called before allocating the operation but
diff --git a/source/blender/nodes/intern/node_compositor_execute.cc b/source/blender/nodes/intern/node_compositor_execute.cc
index e387f349ad1..c9a9717c69f 100644
--- a/source/blender/nodes/intern/node_compositor_execute.cc
+++ b/source/blender/nodes/intern/node_compositor_execute.cc
@@ -361,18 +361,6 @@ void Operation::add_input_processors()
     add_implicit_conversion_input_processor_if_needed(identifier);
     add_realize_on_domain_input_processor_if_needed(identifier);
   }
-
-  /* Then update the mapped result for each input to be that of the last processor for that input
-   * if any input processor exist for it. */
-  for (const StringRef &identifier : inputs_to_results_map_.keys()) {
-    Vector<ProcessorOperation *> &processors = input_processors_.lookup_or_add_default(identifier);
-    /* No input processors, nothing to do. */
-    if (processors.is_empty()) {
-      continue;
-    }
-    /* Replace the currently mapped result with the result of the last input processor. */
-    switch_result_mapped_to_input(identifier, &processors.last()->get_result());
-  }
 }
 
 void Operation::add_implicit_conversion_input_processor_if_needed(StringRef identifier)
@@ -434,10 +422,11 @@ void Operation::add_input_processor(StringRef identifier, ProcessorOperation *pr
    * processor or not. */
   Result &result = processors.is_empty() ? get_input(identifier) : processors.last()->get_result();
 
-  /* Set the input result of the processor and add it to the processors vector. The output of the
-   * processor will be mapped later after all processors were added. */
+  /* Set the input result of the processor, add it to the processors vector, and switch the result
+   * mapped to the input to the result of the last processor. */
   processor->map_input_to_result(&result);
   processors.append(processor);
+  switch_result_mapped_to_input(identifier, &processor->get_result());
 }
 
 void Operation::allocate_input_processors()



More information about the Bf-blender-cvs mailing list