[Bf-blender-cvs] [85252f3cbab] temp-viewport-compositor-compiler: Viewport Compositor: Delay mapping input processors
Omar Emara
noreply at git.blender.org
Tue Mar 29 21:24:45 CEST 2022
Commit: 85252f3cbab9c12f06de0e7430815ef1dc2eb9ab
Author: Omar Emara
Date: Tue Mar 29 21:21:06 2022 +0200
Branches: temp-viewport-compositor-compiler
https://developer.blender.org/rB85252f3cbab9c12f06de0e7430815ef1dc2eb9ab
Viewport Compositor: Delay mapping input processors
Delay mapping the result of the of the last input processor to the
operation input until after adding all input processors.
===================================================================
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 3727de90db7..3d107a7f24d 100644
--- a/source/blender/nodes/NOD_compositor_execute.hh
+++ b/source/blender/nodes/NOD_compositor_execute.hh
@@ -447,10 +447,14 @@ class Operation {
* overridden by node operations to compute results for unlinked sockets. */
virtual void pre_execute();
- /* Add all the necessary input processors for each input, then evaluate them. This is called
- * before executing the operation to prepare its inputs but after the pre_execute method was
- * called. The class defines a default implementation, but derived class can override the method
- * to have a different implementation, extend the implementation, or remove it. */
+ /* First, all the necessary input processors for each input. Then update the result mapped to
+ * 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. Finally,
+ * evaluate all input processors in order. This is called before executing the operation to
+ * prepare its inputs but after the pre_execute method was called. The class defines a default
+ * implementation, but derived class can override the method to have a different
+ * implementation, extend the implementation, or remove it. */
virtual void evaluate_input_processors();
/* This method should allocate the operation results, execute the operation, and compute the
@@ -496,14 +500,11 @@ class Operation {
/* Add the given input processor operation to the list of input processors for the input
* 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. */
+ * processors exists. The result of the last input processor will not be mapped to the operation
+ * input in this method, this will be done later, see evaluate_input_processors for more
+ * information. */
void add_input_processor(StringRef identifier, ProcessorOperation *processor);
- /* Allocate all input processors in order. This is called before allocating the operation but
- * after the pre_allocate method was called. */
- void allocate_input_processors();
-
/* Release the results that are mapped to the inputs of the operation. This is called after the
* evaluation of the operation to declare that the results are no longer needed by this
* operation. */
diff --git a/source/blender/nodes/intern/node_compositor_execute.cc b/source/blender/nodes/intern/node_compositor_execute.cc
index bf4537097a0..a6e459f3af3 100644
--- a/source/blender/nodes/intern/node_compositor_execute.cc
+++ b/source/blender/nodes/intern/node_compositor_execute.cc
@@ -421,13 +421,25 @@ void Operation::pre_execute()
void Operation::evaluate_input_processors()
{
- /* First add all needed processors for each input. */
+ /* First, add all needed processors for each input. */
for (const StringRef &identifier : inputs_to_results_map_.keys()) {
add_implicit_conversion_input_processor_if_needed(identifier);
add_realize_on_domain_input_processor_if_needed(identifier);
}
- /* Then evaluate the input processors in order. */
+ /* Then, switch the result mapped for each input of the operation 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());
+ }
+
+ /* Finally, evaluate the input processors in order. */
for (const Vector<ProcessorOperation *> &processors : input_processors_.values()) {
for (ProcessorOperation *processor : processors) {
processor->evaluate();
@@ -530,11 +542,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, add it to the processors vector, and switch the result
- * mapped to the input to the result of the last processor. */
+ /* Map the input result of the processor and add it to the processors vector. No need to map the
+ * result of the processor to the operation input as this will be done later in
+ * evaluate_input_processors. */
processor->map_input_to_result(&result);
processors.append(processor);
- switch_result_mapped_to_input(identifier, &processor->get_result());
}
void Operation::release_inputs()
More information about the Bf-blender-cvs
mailing list