Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-05-20 12:34:47 +0300
committerJacques Lucke <jacques@blender.org>2021-05-20 12:35:13 +0300
commitb084b57fbf6d2b6c2a1adb2192f5d82581cede5c (patch)
tree14c11a07c6d0dbb58f6eb71804d28b741125b8d4 /source/blender/nodes/NOD_geometry_exec.hh
parent44e7192745f0b53e29d20bb88d4df0945a808758 (diff)
Geometry Nodes: new geometry nodes evaluator
The old geometry nodes evaluator was quite basic and missed many features. It was useful to get the geometry nodes project started. However, nowadays we run into its limitations from time to time. The new evaluator is more complex, but comes with new capabilities. The two most important capabilities are that it can now execute nodes in parallel and it supports lazy evaluation. The performance improvement by multi-threading depends a lot on the specific node tree. In our demo files, the speedup is measurable but not huge. This is mainly because they are bottlenecked by one or two nodes that have to be executed one after the other (often the Boolean or Attribute Proximity nodes) or because the bottleneck is multi-threaded already (often openvdb nodes). Lazy evaluation of inputs is only supported by the Switch node for now. Previously, geometry nodes would always compute both inputs and then just discard the one that is not used. Now, only the input that is required is computed. For some more details read D11191, T87620 and the in-code documentation. Differential Revision: https://developer.blender.org/D11191
Diffstat (limited to 'source/blender/nodes/NOD_geometry_exec.hh')
-rw-r--r--source/blender/nodes/NOD_geometry_exec.hh55
1 files changed, 53 insertions, 2 deletions
diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh
index f341cb28dce..52d7e097f0d 100644
--- a/source/blender/nodes/NOD_geometry_exec.hh
+++ b/source/blender/nodes/NOD_geometry_exec.hh
@@ -96,7 +96,18 @@ class GeoNodeExecParamsProvider {
* Prepare a memory buffer for an output value of the node. The returned memory has to be
* initialized by the caller. The identifier and type are expected to be correct.
*/
- virtual GMutablePointer alloc_output_value(StringRef identifier, const CPPType &type) = 0;
+ virtual GMutablePointer alloc_output_value(const CPPType &type) = 0;
+
+ /**
+ * The value has been allocated with #alloc_output_value.
+ */
+ virtual void set_output(StringRef identifier, GMutablePointer value) = 0;
+
+ /* A description for these methods is provided in GeoNodeExecParams. */
+ virtual void set_input_unused(StringRef identifier) = 0;
+ virtual bool output_is_required(StringRef identifier) const = 0;
+ virtual bool lazy_require_input(StringRef identifier) = 0;
+ virtual bool lazy_output_is_required(StringRef identifier) const = 0;
};
class GeoNodeExecParams {
@@ -174,8 +185,48 @@ class GeoNodeExecParams {
#ifdef DEBUG
this->check_output_access(identifier, type);
#endif
- GMutablePointer gvalue = provider_->alloc_output_value(identifier, type);
+ GMutablePointer gvalue = provider_->alloc_output_value(type);
new (gvalue.get()) StoredT(std::forward<T>(value));
+ provider_->set_output(identifier, gvalue);
+ }
+
+ /**
+ * Tell the evaluator that a specific input won't be used anymore.
+ */
+ void set_input_unused(StringRef identifier)
+ {
+ provider_->set_input_unused(identifier);
+ }
+
+ /**
+ * Returns true when the output has to be computed.
+ * Nodes that support lazyness could use the #lazy_output_is_required variant to possibly avoid
+ * some computations.
+ */
+ bool output_is_required(StringRef identifier) const
+ {
+ return provider_->output_is_required(identifier);
+ }
+
+ /**
+ * Tell the evaluator that a specific input is required.
+ * This returns true when the input will only be available in the next execution.
+ * False is returned if the input is available already.
+ * This can only be used when the node supports lazyness.
+ */
+ bool lazy_require_input(StringRef identifier)
+ {
+ return provider_->lazy_require_input(identifier);
+ }
+
+ /**
+ * Asks the evaluator if a specific output is required right now. If this returns false, the
+ * value might still need to be computed later.
+ * This can only be used when the node supports lazyness.
+ */
+ bool lazy_output_is_required(StringRef identifier)
+ {
+ return provider_->lazy_output_is_required(identifier);
}
/**