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-04-01 16:55:08 +0300
committerJacques Lucke <jacques@blender.org>2021-04-01 16:55:23 +0300
commitb5c2c3aba886f521a0cade5b8450683c20843d3a (patch)
tree46878da186ccb49b2bcc3e1de816476aea5cf750
parentf674976edd884d7a9a409042708f2b1169fd4e98 (diff)
BLI: rename resource collector to resource scope
Differential Revision: https://developer.blender.org/D10857
-rw-r--r--source/blender/blenlib/BLI_resource_scope.hh (renamed from source/blender/blenlib/BLI_resource_collector.hh)40
-rw-r--r--source/blender/blenlib/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_spreadsheet/space_spreadsheet.cc10
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc20
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.hh4
-rw-r--r--source/blender/functions/FN_multi_function_network_optimization.hh4
-rw-r--r--source/blender/functions/FN_multi_function_params.hh18
-rw-r--r--source/blender/functions/intern/multi_function_network_evaluation.cc109
-rw-r--r--source/blender/functions/intern/multi_function_network_optimization.cc27
-rw-r--r--source/blender/modifiers/intern/MOD_nodes.cc6
-rw-r--r--source/blender/nodes/NOD_node_tree_multi_function.hh17
-rw-r--r--source/blender/nodes/intern/node_tree_multi_function.cc21
-rw-r--r--source/blender/nodes/intern/type_callbacks.cc3
13 files changed, 142 insertions, 139 deletions
diff --git a/source/blender/blenlib/BLI_resource_collector.hh b/source/blender/blenlib/BLI_resource_scope.hh
index 70804ceb1f1..f606dc0c0a1 100644
--- a/source/blender/blenlib/BLI_resource_collector.hh
+++ b/source/blender/blenlib/BLI_resource_scope.hh
@@ -19,12 +19,24 @@
/** \file
* \ingroup bli
*
- * A ResourceCollector holds an arbitrary set of resources, that will be destructed and/or freed
- * when the ResourceCollector is destructed. This is useful when some object has to take ownership
- * of other objects, but it does not know the type of those other objects.
+ * A `ResourceScope` takes ownership of arbitrary data/resources. Those resources will be
+ * destructed and/or freed when the `ResourceScope` is destructed. Destruction happens in reverse
+ * order. That allows resources do depend on other resources that have been added before.
*
- * Resources owned by the ResourceCollector will be freed in reverse order. That allows resources
- * that are added later to depend on resources that have been added before.
+ * A `ResourceScope` can also be thought of as a dynamic/runtime version of normal scopes in C++
+ * that are surrounded by braces.
+ *
+ * The main purpose of a `ResourceScope` is to allow functions to inject data into the scope of the
+ * caller. Traditionally, that can only be done by returning a value that owns everything it needs.
+ * This is fine until one has to deal with optional ownership. There are many ways to have a type
+ * optionally own something else, all of which are fairly annoying. A `ResourceScope` can be used
+ * to avoid having to deal with optional ownership. If some value would be owned, it can just be
+ * added to the resource scope, otherwise not.
+ *
+ * When a function takes a `ResourceScope` as parameter, it usually means that its return value
+ * will live at least as long as the passed in resources scope. However, it might also live longer.
+ * That can happen when the function returns a reference to statically allocated data or
+ * dynamically allocated data depending on some condition.
*/
#include "BLI_linear_allocator.hh"
@@ -33,7 +45,7 @@
namespace blender {
-class ResourceCollector : NonCopyable, NonMovable {
+class ResourceScope : NonCopyable, NonMovable {
private:
struct ResourceData {
void *data;
@@ -45,9 +57,9 @@ class ResourceCollector : NonCopyable, NonMovable {
Vector<ResourceData> m_resources;
public:
- ResourceCollector() = default;
+ ResourceScope() = default;
- ~ResourceCollector()
+ ~ResourceScope()
{
/* Free in reversed order. */
for (int64_t i = m_resources.size(); i--;) {
@@ -57,7 +69,7 @@ class ResourceCollector : NonCopyable, NonMovable {
}
/**
- * Pass ownership of the resource to the ResourceCollector. It will be destructed and freed when
+ * Pass ownership of the resource to the ResourceScope. It will be destructed and freed when
* the collector is destructed.
*/
template<typename T> void add(std::unique_ptr<T> resource, const char *name)
@@ -73,7 +85,7 @@ class ResourceCollector : NonCopyable, NonMovable {
}
/**
- * Pass ownership of the resource to the ResourceCollector. It will be destructed when the
+ * Pass ownership of the resource to the ResourceScope. It will be destructed when the
* collector is destructed.
*/
template<typename T> void add(destruct_ptr<T> resource, const char *name)
@@ -95,7 +107,7 @@ class ResourceCollector : NonCopyable, NonMovable {
}
/**
- * Pass ownership of some resource to the ResourceCollector. The given free function will be
+ * Pass ownership of some resource to the ResourceScope. The given free function will be
* called when the collector is destructed.
*/
void add(void *userdata, void (*free)(void *), const char *name)
@@ -108,7 +120,7 @@ class ResourceCollector : NonCopyable, NonMovable {
}
/**
- * Construct an object with the same value in the ResourceCollector and return a reference to the
+ * Construct an object with the same value in the ResourceScope and return a reference to the
* new value.
*/
template<typename T> T &add_value(T &&value, const char *name)
@@ -126,7 +138,7 @@ class ResourceCollector : NonCopyable, NonMovable {
}
/**
- * Utility method to construct an instance of type T that will be owned by the ResourceCollector.
+ * Utility method to construct an instance of type T that will be owned by the ResourceScope.
*/
template<typename T, typename... Args> T &construct(const char *name, Args &&... args)
{
@@ -137,7 +149,7 @@ class ResourceCollector : NonCopyable, NonMovable {
}
/**
- * Print the names of all the resources that are owned by this ResourceCollector. This can be
+ * Print the names of all the resources that are owned by this ResourceScope. This can be
* useful for debugging.
*/
void print(StringRef name) const
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index d7a27cc4531..e66049c9bd6 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -258,7 +258,7 @@ set(SRC
BLI_rand.h
BLI_rand.hh
BLI_rect.h
- BLI_resource_collector.hh
+ BLI_resource_scope.hh
BLI_scanfill.h
BLI_session_uuid.h
BLI_set.hh
diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
index 0f7709b464e..403e6cd6206 100644
--- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
+++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
@@ -17,7 +17,7 @@
#include <cstring>
#include "BLI_listbase.h"
-#include "BLI_resource_collector.hh"
+#include "BLI_resource_scope.hh"
#include "BKE_screen.h"
@@ -138,7 +138,7 @@ class FallbackSpreadsheetDrawer : public SpreadsheetDrawer {
static void gather_spreadsheet_columns(const bContext *C,
SpreadsheetColumnLayout &column_layout,
- blender::ResourceCollector &resources)
+ blender::ResourceScope &scope)
{
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
ID *used_id = get_used_id(C);
@@ -158,16 +158,16 @@ static void gather_spreadsheet_columns(const bContext *C,
return;
}
- return spreadsheet_columns_from_geometry(C, object_eval, column_layout, resources);
+ return spreadsheet_columns_from_geometry(C, object_eval, column_layout, scope);
}
static void spreadsheet_main_region_draw(const bContext *C, ARegion *region)
{
SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
- blender::ResourceCollector resources;
+ blender::ResourceScope scope;
SpreadsheetColumnLayout column_layout;
- gather_spreadsheet_columns(C, column_layout, resources);
+ gather_spreadsheet_columns(C, column_layout, scope);
sspreadsheet->runtime->visible_rows = column_layout.row_indices.size();
sspreadsheet->runtime->tot_columns = column_layout.columns.size();
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc
index 910bc0a34ec..7eea6c48676 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc
@@ -41,13 +41,13 @@ using blender::bke::ReadAttributePtr;
static void add_columns_for_instances(const InstancesComponent &instances_component,
SpreadsheetColumnLayout &column_layout,
- ResourceCollector &resources)
+ ResourceScope &scope)
{
Span<InstancedData> instance_data = instances_component.instanced_data();
Span<float4x4> transforms = instances_component.transforms();
Vector<std::unique_ptr<SpreadsheetColumn>> &columns =
- resources.construct<Vector<std::unique_ptr<SpreadsheetColumn>>>("columns");
+ scope.construct<Vector<std::unique_ptr<SpreadsheetColumn>>>("columns");
columns.append(spreadsheet_column_from_function(
"Name", [instance_data](int index, CellValue &r_cell_value) {
@@ -330,13 +330,13 @@ static Span<int64_t> filter_mesh_elements_by_selection(const bContext *C,
Object *object_eval,
const MeshComponent *component,
const AttributeDomain domain,
- ResourceCollector &resources)
+ ResourceScope &scope)
{
SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
const bool show_only_selected = sspreadsheet->filter_flag & SPREADSHEET_FILTER_SELECTED_ONLY;
if (object_eval->mode == OB_MODE_EDIT && show_only_selected) {
Object *object_orig = DEG_get_original_object(object_eval);
- Vector<int64_t> &visible_rows = resources.construct<Vector<int64_t>>("visible rows");
+ Vector<int64_t> &visible_rows = scope.construct<Vector<int64_t>>("visible rows");
const Mesh *mesh_eval = component->get_for_read();
Mesh *mesh_orig = (Mesh *)object_orig->data;
BMesh *bm = mesh_orig->edit_mesh->bm;
@@ -389,14 +389,14 @@ static GeometryComponentType get_display_component_type(const bContext *C, Objec
void spreadsheet_columns_from_geometry(const bContext *C,
Object *object_eval,
SpreadsheetColumnLayout &column_layout,
- ResourceCollector &resources)
+ ResourceScope &scope)
{
SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
const AttributeDomain domain = (AttributeDomain)sspreadsheet->attribute_domain;
const GeometryComponentType component_type = get_display_component_type(C, object_eval);
/* Create a resource collector that owns stuff that needs to live until drawing is done. */
- GeometrySet &geometry_set = resources.add_value(
+ GeometrySet &geometry_set = scope.add_value(
get_display_geometry_set(sspreadsheet, object_eval, component_type), "geometry set");
const GeometryComponent *component = geometry_set.get_component_for_read(component_type);
@@ -405,7 +405,7 @@ void spreadsheet_columns_from_geometry(const bContext *C,
}
if (component_type == GEO_COMPONENT_TYPE_INSTANCES) {
add_columns_for_instances(
- *static_cast<const InstancesComponent *>(component), column_layout, resources);
+ *static_cast<const InstancesComponent *>(component), column_layout, scope);
return;
}
@@ -416,12 +416,12 @@ void spreadsheet_columns_from_geometry(const bContext *C,
Vector<std::string> attribute_names = get_sorted_attribute_names_to_display(*component, domain);
Vector<std::unique_ptr<SpreadsheetColumn>> &columns =
- resources.construct<Vector<std::unique_ptr<SpreadsheetColumn>>>("columns");
+ scope.construct<Vector<std::unique_ptr<SpreadsheetColumn>>>("columns");
for (StringRefNull attribute_name : attribute_names) {
ReadAttributePtr attribute_ptr = component->attribute_try_get_for_read(attribute_name);
ReadAttribute &attribute = *attribute_ptr;
- resources.add(std::move(attribute_ptr), "attribute");
+ scope.add(std::move(attribute_ptr), "attribute");
add_columns_for_attribute(&attribute, attribute_name, columns);
}
@@ -433,7 +433,7 @@ void spreadsheet_columns_from_geometry(const bContext *C,
Span<int64_t> visible_rows;
if (component_type == GEO_COMPONENT_TYPE_MESH) {
visible_rows = filter_mesh_elements_by_selection(
- C, object_eval, static_cast<const MeshComponent *>(component), domain, resources);
+ C, object_eval, static_cast<const MeshComponent *>(component), domain, scope);
}
else {
visible_rows = IndexRange(component->attribute_domain_size(domain)).as_span();
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.hh b/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.hh
index cef731517b9..ff45b8517d1 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.hh
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.hh
@@ -18,7 +18,7 @@
#include "BKE_geometry_set.hh"
-#include "BLI_resource_collector.hh"
+#include "BLI_resource_scope.hh"
#include "spreadsheet_column_layout.hh"
@@ -29,6 +29,6 @@ namespace blender::ed::spreadsheet {
void spreadsheet_columns_from_geometry(const bContext *C,
Object *object_eval,
SpreadsheetColumnLayout &column_layout,
- ResourceCollector &resources);
+ ResourceScope &scope);
} // namespace blender::ed::spreadsheet
diff --git a/source/blender/functions/FN_multi_function_network_optimization.hh b/source/blender/functions/FN_multi_function_network_optimization.hh
index 6d0165643ce..96664fa368e 100644
--- a/source/blender/functions/FN_multi_function_network_optimization.hh
+++ b/source/blender/functions/FN_multi_function_network_optimization.hh
@@ -18,12 +18,12 @@
#include "FN_multi_function_network.hh"
-#include "BLI_resource_collector.hh"
+#include "BLI_resource_scope.hh"
namespace blender::fn::mf_network_optimization {
void dead_node_removal(MFNetwork &network);
-void constant_folding(MFNetwork &network, ResourceCollector &resources);
+void constant_folding(MFNetwork &network, ResourceScope &scope);
void common_subnetwork_elimination(MFNetwork &network);
} // namespace blender::fn::mf_network_optimization
diff --git a/source/blender/functions/FN_multi_function_params.hh b/source/blender/functions/FN_multi_function_params.hh
index 2d3a8dd650e..72ebc0d9b94 100644
--- a/source/blender/functions/FN_multi_function_params.hh
+++ b/source/blender/functions/FN_multi_function_params.hh
@@ -25,7 +25,7 @@
* the function. `MFParams` is then used inside the called function to access the parameters.
*/
-#include "BLI_resource_collector.hh"
+#include "BLI_resource_scope.hh"
#include "FN_generic_vector_array.hh"
#include "FN_generic_virtual_vector_array.hh"
@@ -35,7 +35,7 @@ namespace blender::fn {
class MFParamsBuilder {
private:
- ResourceCollector resources_;
+ ResourceScope scope_;
const MFSignature *signature_;
int64_t min_array_size_;
Vector<const GVArray *> virtual_arrays_;
@@ -55,13 +55,13 @@ class MFParamsBuilder {
template<typename T> void add_readonly_single_input(const T *value, StringRef expected_name = "")
{
- this->add_readonly_single_input(resources_.construct<GVArrayForSingleValueRef>(
+ this->add_readonly_single_input(scope_.construct<GVArrayForSingleValueRef>(
__func__, CPPType::get<T>(), min_array_size_, value),
expected_name);
}
void add_readonly_single_input(const GSpan span, StringRef expected_name = "")
{
- this->add_readonly_single_input(resources_.construct<GVArrayForGSpan>(__func__, span),
+ this->add_readonly_single_input(scope_.construct<GVArrayForGSpan>(__func__, span),
expected_name);
}
void add_readonly_single_input(const GVArray &ref, StringRef expected_name = "")
@@ -74,7 +74,7 @@ class MFParamsBuilder {
void add_readonly_vector_input(const GVectorArray &vector_array, StringRef expected_name = "")
{
this->add_readonly_vector_input(
- resources_.construct<GVVectorArrayForGVectorArray>(__func__, vector_array), expected_name);
+ scope_.construct<GVVectorArrayForGVectorArray>(__func__, vector_array), expected_name);
}
void add_readonly_vector_input(const GVVectorArray &ref, StringRef expected_name = "")
{
@@ -136,9 +136,9 @@ class MFParamsBuilder {
return *vector_arrays_[data_index];
}
- ResourceCollector &resources()
+ ResourceScope &resource_scope()
{
- return resources_;
+ return scope_;
}
private:
@@ -177,7 +177,7 @@ class MFParams {
template<typename T> const VArray<T> &readonly_single_input(int param_index, StringRef name = "")
{
const GVArray &array = this->readonly_single_input(param_index, name);
- return builder_->resources_.construct<VArrayForGVArray<T>>(__func__, array);
+ return builder_->scope_.construct<VArrayForGVArray<T>>(__func__, array);
}
const GVArray &readonly_single_input(int param_index, StringRef name = "")
{
@@ -202,7 +202,7 @@ class MFParams {
const VVectorArray<T> &readonly_vector_input(int param_index, StringRef name = "")
{
const GVVectorArray &vector_array = this->readonly_vector_input(param_index, name);
- return builder_->resources_.construct<VVectorArrayForGVVectorArray<T>>(__func__, vector_array);
+ return builder_->scope_.construct<VVectorArrayForGVVectorArray<T>>(__func__, vector_array);
}
const GVVectorArray &readonly_vector_input(int param_index, StringRef name = "")
{
diff --git a/source/blender/functions/intern/multi_function_network_evaluation.cc b/source/blender/functions/intern/multi_function_network_evaluation.cc
index daa0a42963a..86ac4f6a179 100644
--- a/source/blender/functions/intern/multi_function_network_evaluation.cc
+++ b/source/blender/functions/intern/multi_function_network_evaluation.cc
@@ -37,7 +37,7 @@
#include "FN_multi_function_network_evaluation.hh"
-#include "BLI_resource_collector.hh"
+#include "BLI_resource_scope.hh"
#include "BLI_stack.hh"
namespace blender::fn {
@@ -70,13 +70,10 @@ class MFNetworkEvaluationStorage {
void add_vector_output_from_caller(const MFOutputSocket &socket, GVectorArray &vector_array);
/* Get input buffers for function node evaluations. */
- const GVArray &get_single_input__full(const MFInputSocket &socket, ResourceCollector &resources);
- const GVArray &get_single_input__single(const MFInputSocket &socket,
- ResourceCollector &resources);
- const GVVectorArray &get_vector_input__full(const MFInputSocket &socket,
- ResourceCollector &resources);
- const GVVectorArray &get_vector_input__single(const MFInputSocket &socket,
- ResourceCollector &resources);
+ const GVArray &get_single_input__full(const MFInputSocket &socket, ResourceScope &scope);
+ const GVArray &get_single_input__single(const MFInputSocket &socket, ResourceScope &scope);
+ const GVVectorArray &get_vector_input__full(const MFInputSocket &socket, ResourceScope &scope);
+ const GVVectorArray &get_vector_input__single(const MFInputSocket &socket, ResourceScope &scope);
/* Get output buffers for function node evaluations. */
GMutableSpan get_single_output__full(const MFOutputSocket &socket);
@@ -87,16 +84,16 @@ class MFNetworkEvaluationStorage {
/* Get mutable buffers for function node evaluations. */
GMutableSpan get_mutable_single__full(const MFInputSocket &input,
const MFOutputSocket &output,
- ResourceCollector &resources);
+ ResourceScope &scope);
GMutableSpan get_mutable_single__single(const MFInputSocket &input,
const MFOutputSocket &output,
- ResourceCollector &resources);
+ ResourceScope &scope);
GVectorArray &get_mutable_vector__full(const MFInputSocket &input,
const MFOutputSocket &output,
- ResourceCollector &resources);
+ ResourceScope &scope);
GVectorArray &get_mutable_vector__single(const MFInputSocket &input,
const MFOutputSocket &output,
- ResourceCollector &resources);
+ ResourceScope &scope);
/* Mark a node as being done with evaluation. This might free temporary buffers that are no
* longer needed. */
@@ -277,20 +274,20 @@ BLI_NOINLINE void MFNetworkEvaluator::evaluate_function(MFContext &global_contex
/* The function output would be the same for all elements. Therefore, it is enough to call the
* function only on a single element. This can avoid many duplicate computations. */
MFParamsBuilder params{function, 1};
- ResourceCollector &resources = params.resources();
+ ResourceScope &scope = params.resource_scope();
for (int param_index : function.param_indices()) {
MFParamType param_type = function.param_type(param_index);
switch (param_type.category()) {
case MFParamType::SingleInput: {
const MFInputSocket &socket = function_node.input_for_param(param_index);
- const GVArray &values = storage.get_single_input__single(socket, resources);
+ const GVArray &values = storage.get_single_input__single(socket, scope);
params.add_readonly_single_input(values);
break;
}
case MFParamType::VectorInput: {
const MFInputSocket &socket = function_node.input_for_param(param_index);
- const GVVectorArray &values = storage.get_vector_input__single(socket, resources);
+ const GVVectorArray &values = storage.get_vector_input__single(socket, scope);
params.add_readonly_vector_input(values);
break;
}
@@ -309,14 +306,14 @@ BLI_NOINLINE void MFNetworkEvaluator::evaluate_function(MFContext &global_contex
case MFParamType::SingleMutable: {
const MFInputSocket &input = function_node.input_for_param(param_index);
const MFOutputSocket &output = function_node.output_for_param(param_index);
- GMutableSpan values = storage.get_mutable_single__single(input, output, resources);
+ GMutableSpan values = storage.get_mutable_single__single(input, output, scope);
params.add_single_mutable(values);
break;
}
case MFParamType::VectorMutable: {
const MFInputSocket &input = function_node.input_for_param(param_index);
const MFOutputSocket &output = function_node.output_for_param(param_index);
- GVectorArray &values = storage.get_mutable_vector__single(input, output, resources);
+ GVectorArray &values = storage.get_mutable_vector__single(input, output, scope);
params.add_vector_mutable(values);
break;
}
@@ -327,20 +324,20 @@ BLI_NOINLINE void MFNetworkEvaluator::evaluate_function(MFContext &global_contex
}
else {
MFParamsBuilder params{function, storage.mask().min_array_size()};
- ResourceCollector &resources = params.resources();
+ ResourceScope &scope = params.resource_scope();
for (int param_index : function.param_indices()) {
MFParamType param_type = function.param_type(param_index);
switch (param_type.category()) {
case MFParamType::SingleInput: {
const MFInputSocket &socket = function_node.input_for_param(param_index);
- const GVArray &values = storage.get_single_input__full(socket, resources);
+ const GVArray &values = storage.get_single_input__full(socket, scope);
params.add_readonly_single_input(values);
break;
}
case MFParamType::VectorInput: {
const MFInputSocket &socket = function_node.input_for_param(param_index);
- const GVVectorArray &values = storage.get_vector_input__full(socket, resources);
+ const GVVectorArray &values = storage.get_vector_input__full(socket, scope);
params.add_readonly_vector_input(values);
break;
}
@@ -359,14 +356,14 @@ BLI_NOINLINE void MFNetworkEvaluator::evaluate_function(MFContext &global_contex
case MFParamType::SingleMutable: {
const MFInputSocket &input = function_node.input_for_param(param_index);
const MFOutputSocket &output = function_node.output_for_param(param_index);
- GMutableSpan values = storage.get_mutable_single__full(input, output, resources);
+ GMutableSpan values = storage.get_mutable_single__full(input, output, scope);
params.add_single_mutable(values);
break;
}
case MFParamType::VectorMutable: {
const MFInputSocket &input = function_node.input_for_param(param_index);
const MFOutputSocket &output = function_node.output_for_param(param_index);
- GVectorArray &values = storage.get_mutable_vector__full(input, output, resources);
+ GVectorArray &values = storage.get_mutable_vector__full(input, output, scope);
params.add_vector_mutable(values);
break;
}
@@ -400,19 +397,19 @@ bool MFNetworkEvaluator::can_do_single_value_evaluation(const MFFunctionNode &fu
BLI_NOINLINE void MFNetworkEvaluator::initialize_remaining_outputs(
MFParams params, Storage &storage, Span<const MFInputSocket *> remaining_outputs) const
{
- ResourceCollector resources;
+ ResourceScope scope;
for (const MFInputSocket *socket : remaining_outputs) {
int param_index = inputs_.size() + outputs_.first_index_of(socket);
switch (socket->data_type().category()) {
case MFDataType::Single: {
- const GVArray &values = storage.get_single_input__full(*socket, resources);
+ const GVArray &values = storage.get_single_input__full(*socket, scope);
GMutableSpan output_values = params.uninitialized_single_output(param_index);
values.materialize_to_uninitialized(storage.mask(), output_values.data());
break;
}
case MFDataType::Vector: {
- const GVVectorArray &values = storage.get_vector_input__full(*socket, resources);
+ const GVVectorArray &values = storage.get_vector_input__full(*socket, scope);
GVectorArray &output_values = params.vector_output(param_index);
output_values.extend(storage.mask(), values);
break;
@@ -796,7 +793,7 @@ GVectorArray &MFNetworkEvaluationStorage::get_vector_output__single(const MFOutp
GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__full(const MFInputSocket &input,
const MFOutputSocket &output,
- ResourceCollector &resources)
+ ResourceScope &scope)
{
const MFOutputSocket &from = *input.origin();
const MFOutputSocket &to = output;
@@ -810,7 +807,7 @@ GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__full(const MFInputS
if (to_any_value != nullptr) {
BLI_assert(to_any_value->type == ValueType::OutputSingle);
GMutableSpan span = static_cast<OutputSingleValue *>(to_any_value)->span;
- const GVArray &virtual_array = this->get_single_input__full(input, resources);
+ const GVArray &virtual_array = this->get_single_input__full(input, scope);
virtual_array.materialize_to_uninitialized(mask_, span.data());
return span;
}
@@ -825,7 +822,7 @@ GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__full(const MFInputS
}
}
- const GVArray &virtual_array = this->get_single_input__full(input, resources);
+ const GVArray &virtual_array = this->get_single_input__full(input, scope);
void *new_buffer = MEM_mallocN_aligned(min_array_size_ * type.size(), type.alignment(), AT);
GMutableSpan new_array_ref(type, new_buffer, min_array_size_);
virtual_array.materialize_to_uninitialized(mask_, new_array_ref.data());
@@ -838,7 +835,7 @@ GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__full(const MFInputS
GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__single(const MFInputSocket &input,
const MFOutputSocket &output,
- ResourceCollector &resources)
+ ResourceScope &scope)
{
const MFOutputSocket &from = *input.origin();
const MFOutputSocket &to = output;
@@ -853,7 +850,7 @@ GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__single(const MFInpu
BLI_assert(to_any_value->type == ValueType::OutputSingle);
GMutableSpan span = static_cast<OutputSingleValue *>(to_any_value)->span;
BLI_assert(span.size() == 1);
- const GVArray &virtual_array = this->get_single_input__single(input, resources);
+ const GVArray &virtual_array = this->get_single_input__single(input, scope);
virtual_array.get_single_to_uninitialized(span[0]);
return span;
}
@@ -869,7 +866,7 @@ GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__single(const MFInpu
}
}
- const GVArray &virtual_array = this->get_single_input__single(input, resources);
+ const GVArray &virtual_array = this->get_single_input__single(input, scope);
void *new_buffer = allocator_.allocate(type.size(), type.alignment());
virtual_array.get_single_to_uninitialized(new_buffer);
@@ -883,7 +880,7 @@ GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__single(const MFInpu
GVectorArray &MFNetworkEvaluationStorage::get_mutable_vector__full(const MFInputSocket &input,
const MFOutputSocket &output,
- ResourceCollector &resources)
+ ResourceScope &scope)
{
const MFOutputSocket &from = *input.origin();
const MFOutputSocket &to = output;
@@ -897,7 +894,7 @@ GVectorArray &MFNetworkEvaluationStorage::get_mutable_vector__full(const MFInput
if (to_any_value != nullptr) {
BLI_assert(to_any_value->type == ValueType::OutputVector);
GVectorArray &vector_array = *static_cast<OutputVectorValue *>(to_any_value)->vector_array;
- const GVVectorArray &virtual_vector_array = this->get_vector_input__full(input, resources);
+ const GVVectorArray &virtual_vector_array = this->get_vector_input__full(input, scope);
vector_array.extend(mask_, virtual_vector_array);
return vector_array;
}
@@ -912,7 +909,7 @@ GVectorArray &MFNetworkEvaluationStorage::get_mutable_vector__full(const MFInput
}
}
- const GVVectorArray &virtual_vector_array = this->get_vector_input__full(input, resources);
+ const GVVectorArray &virtual_vector_array = this->get_vector_input__full(input, scope);
GVectorArray *new_vector_array = new GVectorArray(base_type, min_array_size_);
new_vector_array->extend(mask_, virtual_vector_array);
@@ -926,7 +923,7 @@ GVectorArray &MFNetworkEvaluationStorage::get_mutable_vector__full(const MFInput
GVectorArray &MFNetworkEvaluationStorage::get_mutable_vector__single(const MFInputSocket &input,
const MFOutputSocket &output,
- ResourceCollector &resources)
+ ResourceScope &scope)
{
const MFOutputSocket &from = *input.origin();
const MFOutputSocket &to = output;
@@ -941,7 +938,7 @@ GVectorArray &MFNetworkEvaluationStorage::get_mutable_vector__single(const MFInp
BLI_assert(to_any_value->type == ValueType::OutputVector);
GVectorArray &vector_array = *static_cast<OutputVectorValue *>(to_any_value)->vector_array;
BLI_assert(vector_array.size() == 1);
- const GVVectorArray &virtual_vector_array = this->get_vector_input__single(input, resources);
+ const GVVectorArray &virtual_vector_array = this->get_vector_input__single(input, scope);
vector_array.extend({0}, virtual_vector_array);
return vector_array;
}
@@ -956,7 +953,7 @@ GVectorArray &MFNetworkEvaluationStorage::get_mutable_vector__single(const MFInp
}
}
- const GVVectorArray &virtual_vector_array = this->get_vector_input__single(input, resources);
+ const GVVectorArray &virtual_vector_array = this->get_vector_input__single(input, scope);
GVectorArray *new_vector_array = new GVectorArray(base_type, 1);
new_vector_array->extend({0}, virtual_vector_array);
@@ -968,7 +965,7 @@ GVectorArray &MFNetworkEvaluationStorage::get_mutable_vector__single(const MFInp
}
const GVArray &MFNetworkEvaluationStorage::get_single_input__full(const MFInputSocket &socket,
- ResourceCollector &resources)
+ ResourceScope &scope)
{
const MFOutputSocket &origin = *socket.origin();
Value *any_value = value_per_output_id_[origin.id()];
@@ -977,11 +974,11 @@ const GVArray &MFNetworkEvaluationStorage::get_single_input__full(const MFInputS
if (any_value->type == ValueType::OwnSingle) {
OwnSingleValue *value = static_cast<OwnSingleValue *>(any_value);
if (value->is_single_allocated) {
- return resources.construct<GVArrayForSingleValueRef>(
+ return scope.construct<GVArrayForSingleValueRef>(
__func__, value->span.type(), min_array_size_, value->span.data());
}
- return resources.construct<GVArrayForGSpan>(__func__, value->span);
+ return scope.construct<GVArrayForGSpan>(__func__, value->span);
}
if (any_value->type == ValueType::InputSingle) {
InputSingleValue *value = static_cast<InputSingleValue *>(any_value);
@@ -990,15 +987,15 @@ const GVArray &MFNetworkEvaluationStorage::get_single_input__full(const MFInputS
if (any_value->type == ValueType::OutputSingle) {
OutputSingleValue *value = static_cast<OutputSingleValue *>(any_value);
BLI_assert(value->is_computed);
- return resources.construct<GVArrayForGSpan>(__func__, value->span);
+ return scope.construct<GVArrayForGSpan>(__func__, value->span);
}
BLI_assert(false);
- return resources.construct<GVArrayForEmpty>(__func__, CPPType::get<float>());
+ return scope.construct<GVArrayForEmpty>(__func__, CPPType::get<float>());
}
const GVArray &MFNetworkEvaluationStorage::get_single_input__single(const MFInputSocket &socket,
- ResourceCollector &resources)
+ ResourceScope &scope)
{
const MFOutputSocket &origin = *socket.origin();
Value *any_value = value_per_output_id_[origin.id()];
@@ -1007,7 +1004,7 @@ const GVArray &MFNetworkEvaluationStorage::get_single_input__single(const MFInpu
if (any_value->type == ValueType::OwnSingle) {
OwnSingleValue *value = static_cast<OwnSingleValue *>(any_value);
BLI_assert(value->span.size() == 1);
- return resources.construct<GVArrayForGSpan>(__func__, value->span);
+ return scope.construct<GVArrayForGSpan>(__func__, value->span);
}
if (any_value->type == ValueType::InputSingle) {
InputSingleValue *value = static_cast<InputSingleValue *>(any_value);
@@ -1018,15 +1015,15 @@ const GVArray &MFNetworkEvaluationStorage::get_single_input__single(const MFInpu
OutputSingleValue *value = static_cast<OutputSingleValue *>(any_value);
BLI_assert(value->is_computed);
BLI_assert(value->span.size() == 1);
- return resources.construct<GVArrayForGSpan>(__func__, value->span);
+ return scope.construct<GVArrayForGSpan>(__func__, value->span);
}
BLI_assert(false);
- return resources.construct<GVArrayForEmpty>(__func__, CPPType::get<float>());
+ return scope.construct<GVArrayForEmpty>(__func__, CPPType::get<float>());
}
const GVVectorArray &MFNetworkEvaluationStorage::get_vector_input__full(
- const MFInputSocket &socket, ResourceCollector &resources)
+ const MFInputSocket &socket, ResourceScope &scope)
{
const MFOutputSocket &origin = *socket.origin();
Value *any_value = value_per_output_id_[origin.id()];
@@ -1036,10 +1033,10 @@ const GVVectorArray &MFNetworkEvaluationStorage::get_vector_input__full(
OwnVectorValue *value = static_cast<OwnVectorValue *>(any_value);
if (value->vector_array->size() == 1) {
GSpan span = (*value->vector_array)[0];
- return resources.construct<GVVectorArrayForSingleGSpan>(__func__, span, min_array_size_);
+ return scope.construct<GVVectorArrayForSingleGSpan>(__func__, span, min_array_size_);
}
- return resources.construct<GVVectorArrayForGVectorArray>(__func__, *value->vector_array);
+ return scope.construct<GVVectorArrayForGVectorArray>(__func__, *value->vector_array);
}
if (any_value->type == ValueType::InputVector) {
InputVectorValue *value = static_cast<InputVectorValue *>(any_value);
@@ -1047,16 +1044,15 @@ const GVVectorArray &MFNetworkEvaluationStorage::get_vector_input__full(
}
if (any_value->type == ValueType::OutputVector) {
OutputVectorValue *value = static_cast<OutputVectorValue *>(any_value);
- return resources.construct<GVVectorArrayForGVectorArray>(__func__, *value->vector_array);
+ return scope.construct<GVVectorArrayForGVectorArray>(__func__, *value->vector_array);
}
BLI_assert(false);
- return resources.construct<GVVectorArrayForSingleGSpan>(
- __func__, GSpan(CPPType::get<float>()), 0);
+ return scope.construct<GVVectorArrayForSingleGSpan>(__func__, GSpan(CPPType::get<float>()), 0);
}
const GVVectorArray &MFNetworkEvaluationStorage::get_vector_input__single(
- const MFInputSocket &socket, ResourceCollector &resources)
+ const MFInputSocket &socket, ResourceScope &scope)
{
const MFOutputSocket &origin = *socket.origin();
Value *any_value = value_per_output_id_[origin.id()];
@@ -1065,7 +1061,7 @@ const GVVectorArray &MFNetworkEvaluationStorage::get_vector_input__single(
if (any_value->type == ValueType::OwnVector) {
OwnVectorValue *value = static_cast<OwnVectorValue *>(any_value);
BLI_assert(value->vector_array->size() == 1);
- return resources.construct<GVVectorArrayForGVectorArray>(__func__, *value->vector_array);
+ return scope.construct<GVVectorArrayForGVectorArray>(__func__, *value->vector_array);
}
if (any_value->type == ValueType::InputVector) {
InputVectorValue *value = static_cast<InputVectorValue *>(any_value);
@@ -1075,12 +1071,11 @@ const GVVectorArray &MFNetworkEvaluationStorage::get_vector_input__single(
if (any_value->type == ValueType::OutputVector) {
OutputVectorValue *value = static_cast<OutputVectorValue *>(any_value);
BLI_assert(value->vector_array->size() == 1);
- return resources.construct<GVVectorArrayForGVectorArray>(__func__, *value->vector_array);
+ return scope.construct<GVVectorArrayForGVectorArray>(__func__, *value->vector_array);
}
BLI_assert(false);
- return resources.construct<GVVectorArrayForSingleGSpan>(
- __func__, GSpan(CPPType::get<float>()), 0);
+ return scope.construct<GVVectorArrayForSingleGSpan>(__func__, GSpan(CPPType::get<float>()), 0);
}
/** \} */
diff --git a/source/blender/functions/intern/multi_function_network_optimization.cc b/source/blender/functions/intern/multi_function_network_optimization.cc
index 6c418dee2c1..4b6b3e81393 100644
--- a/source/blender/functions/intern/multi_function_network_optimization.cc
+++ b/source/blender/functions/intern/multi_function_network_optimization.cc
@@ -219,7 +219,7 @@ static Vector<MFInputSocket *> find_constant_inputs_to_fold(
static void prepare_params_for_constant_folding(const MultiFunction &network_fn,
MFParamsBuilder &params,
- ResourceCollector &resources)
+ ResourceScope &scope)
{
for (int param_index : network_fn.param_indices()) {
MFParamType param_type = network_fn.param_type(param_index);
@@ -229,8 +229,7 @@ static void prepare_params_for_constant_folding(const MultiFunction &network_fn,
case MFDataType::Single: {
/* Allocates memory for a single constant folded value. */
const CPPType &cpp_type = data_type.single_type();
- void *buffer = resources.linear_allocator().allocate(cpp_type.size(),
- cpp_type.alignment());
+ void *buffer = scope.linear_allocator().allocate(cpp_type.size(), cpp_type.alignment());
GMutableSpan array{cpp_type, buffer, 1};
params.add_uninitialized_single_output(array);
break;
@@ -238,7 +237,7 @@ static void prepare_params_for_constant_folding(const MultiFunction &network_fn,
case MFDataType::Vector: {
/* Allocates memory for a constant folded vector. */
const CPPType &cpp_type = data_type.vector_base_type();
- GVectorArray &vector_array = resources.construct<GVectorArray>(AT, cpp_type, 1);
+ GVectorArray &vector_array = scope.construct<GVectorArray>(AT, cpp_type, 1);
params.add_vector_output(vector_array);
break;
}
@@ -248,7 +247,7 @@ static void prepare_params_for_constant_folding(const MultiFunction &network_fn,
static Array<MFOutputSocket *> add_constant_folded_sockets(const MultiFunction &network_fn,
MFParamsBuilder &params,
- ResourceCollector &resources,
+ ResourceScope &scope,
MFNetwork &network)
{
Array<MFOutputSocket *> folded_sockets{network_fn.param_indices().size(), nullptr};
@@ -264,15 +263,15 @@ static Array<MFOutputSocket *> add_constant_folded_sockets(const MultiFunction &
const CPPType &cpp_type = data_type.single_type();
GMutableSpan array = params.computed_array(param_index);
void *buffer = array.data();
- resources.add(buffer, array.type().destruct_cb(), AT);
+ scope.add(buffer, array.type().destruct_cb(), AT);
- constant_fn = &resources.construct<CustomMF_GenericConstant>(AT, cpp_type, buffer);
+ constant_fn = &scope.construct<CustomMF_GenericConstant>(AT, cpp_type, buffer);
break;
}
case MFDataType::Vector: {
GVectorArray &vector_array = params.computed_vector_array(param_index);
GSpan array = vector_array[0];
- constant_fn = &resources.construct<CustomMF_GenericConstantArray>(AT, array);
+ constant_fn = &scope.construct<CustomMF_GenericConstantArray>(AT, array);
break;
}
}
@@ -284,17 +283,15 @@ static Array<MFOutputSocket *> add_constant_folded_sockets(const MultiFunction &
}
static Array<MFOutputSocket *> compute_constant_sockets_and_add_folded_nodes(
- MFNetwork &network,
- Span<const MFInputSocket *> sockets_to_compute,
- ResourceCollector &resources)
+ MFNetwork &network, Span<const MFInputSocket *> sockets_to_compute, ResourceScope &scope)
{
MFNetworkEvaluator network_fn{{}, sockets_to_compute};
MFContextBuilder context;
MFParamsBuilder params{network_fn, 1};
- prepare_params_for_constant_folding(network_fn, params, resources);
+ prepare_params_for_constant_folding(network_fn, params, scope);
network_fn.call({0}, params, context);
- return add_constant_folded_sockets(network_fn, params, resources, network);
+ return add_constant_folded_sockets(network_fn, params, scope, network);
}
class MyClass {
@@ -304,7 +301,7 @@ class MyClass {
/**
* Find function nodes that always output the same value and replace those with constant nodes.
*/
-void constant_folding(MFNetwork &network, ResourceCollector &resources)
+void constant_folding(MFNetwork &network, ResourceScope &scope)
{
Vector<MFDummyNode *> temporary_nodes;
Vector<MFInputSocket *> inputs_to_fold = find_constant_inputs_to_fold(network, temporary_nodes);
@@ -313,7 +310,7 @@ void constant_folding(MFNetwork &network, ResourceCollector &resources)
}
Array<MFOutputSocket *> folded_sockets = compute_constant_sockets_and_add_folded_nodes(
- network, inputs_to_fold, resources);
+ network, inputs_to_fold, scope);
for (int i : inputs_to_fold.index_range()) {
MFOutputSocket &original_socket = *inputs_to_fold[i]->origin();
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 267c4be5571..843797e0f72 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -1100,9 +1100,9 @@ static GeometrySet compute_geometry(const DerivedNodeTree &tree,
NodesModifierData *nmd,
const ModifierEvalContext *ctx)
{
- blender::ResourceCollector resources;
- blender::LinearAllocator<> &allocator = resources.linear_allocator();
- blender::nodes::MultiFunctionByNode mf_by_node = get_multi_function_per_node(tree, resources);
+ blender::ResourceScope scope;
+ blender::LinearAllocator<> &allocator = scope.linear_allocator();
+ blender::nodes::MultiFunctionByNode mf_by_node = get_multi_function_per_node(tree, scope);
PersistentDataHandleMap handle_map;
fill_data_handle_map(nmd->settings, tree, handle_map);
diff --git a/source/blender/nodes/NOD_node_tree_multi_function.hh b/source/blender/nodes/NOD_node_tree_multi_function.hh
index df31ee18369..de1f5a0dc70 100644
--- a/source/blender/nodes/NOD_node_tree_multi_function.hh
+++ b/source/blender/nodes/NOD_node_tree_multi_function.hh
@@ -29,7 +29,7 @@
#include "NOD_type_callbacks.hh"
#include "BLI_multi_value_map.hh"
-#include "BLI_resource_collector.hh"
+#include "BLI_resource_scope.hh"
namespace blender::nodes {
@@ -190,7 +190,7 @@ class MFNetworkTreeMap {
* This data is necessary throughout the generation of a MFNetwork from a node tree.
*/
struct CommonMFNetworkBuilderData {
- ResourceCollector &resources;
+ ResourceScope &scope;
fn::MFNetwork &network;
MFNetworkTreeMap &network_map;
const DerivedNodeTree &tree;
@@ -225,9 +225,9 @@ class MFNetworkBuilderBase {
* Returns a resource collector that will only be destructed after the multi-function network is
* destructed.
*/
- ResourceCollector &resources()
+ ResourceScope &resource_scope()
{
- return common_.resources;
+ return common_.scope;
}
/**
@@ -236,9 +236,9 @@ class MFNetworkBuilderBase {
template<typename T, typename... Args> T &construct_fn(Args &&... args)
{
BLI_STATIC_ASSERT((std::is_base_of_v<fn::MultiFunction, T>), "");
- void *buffer = common_.resources.linear_allocator().allocate(sizeof(T), alignof(T));
+ void *buffer = common_.scope.linear_allocator().allocate(sizeof(T), alignof(T));
T *fn = new (buffer) T(std::forward<Args>(args)...);
- common_.resources.add(destruct_ptr<T>(fn), fn->name().c_str());
+ common_.scope.add(destruct_ptr<T>(fn), fn->name().c_str());
return *fn;
}
};
@@ -382,11 +382,10 @@ class NodeMFNetworkBuilder : public MFNetworkBuilderBase {
MFNetworkTreeMap insert_node_tree_into_mf_network(fn::MFNetwork &network,
const DerivedNodeTree &tree,
- ResourceCollector &resources);
+ ResourceScope &scope);
using MultiFunctionByNode = Map<DNode, const fn::MultiFunction *>;
-MultiFunctionByNode get_multi_function_per_node(const DerivedNodeTree &tree,
- ResourceCollector &resources);
+MultiFunctionByNode get_multi_function_per_node(const DerivedNodeTree &tree, ResourceScope &scope);
class DataTypeConversions {
private:
diff --git a/source/blender/nodes/intern/node_tree_multi_function.cc b/source/blender/nodes/intern/node_tree_multi_function.cc
index c77a6b42f97..1fb86661dff 100644
--- a/source/blender/nodes/intern/node_tree_multi_function.cc
+++ b/source/blender/nodes/intern/node_tree_multi_function.cc
@@ -250,11 +250,11 @@ static fn::MFOutputSocket &insert_default_value_for_type(CommonMFNetworkBuilderD
{
const fn::MultiFunction *default_fn;
if (type.is_single()) {
- default_fn = &common.resources.construct<fn::CustomMF_GenericConstant>(
+ default_fn = &common.scope.construct<fn::CustomMF_GenericConstant>(
AT, type.single_type(), type.single_type().default_value());
}
else {
- default_fn = &common.resources.construct<fn::CustomMF_GenericConstantArray>(
+ default_fn = &common.scope.construct<fn::CustomMF_GenericConstantArray>(
AT, fn::GSpan(type.vector_base_type()));
}
@@ -349,11 +349,11 @@ static void insert_links_and_unlinked_inputs(CommonMFNetworkBuilderData &common)
*/
MFNetworkTreeMap insert_node_tree_into_mf_network(fn::MFNetwork &network,
const DerivedNodeTree &tree,
- ResourceCollector &resources)
+ ResourceScope &scope)
{
MFNetworkTreeMap network_map{tree, network};
- CommonMFNetworkBuilderData common{resources, network, network_map, tree};
+ CommonMFNetworkBuilderData common{scope, network, network_map, tree};
insert_nodes(common);
insert_links_and_unlinked_inputs(common);
@@ -427,7 +427,7 @@ static const fn::MultiFunction &create_function_for_node_that_expands_into_multi
const DNode &dnode,
fn::MFNetwork &network,
MFNetworkTreeMap &network_map,
- ResourceCollector &resources)
+ ResourceScope &scope)
{
Vector<const fn::MFOutputSocket *> dummy_fn_inputs;
for (const InputSocketRef *dsocket : dnode->inputs()) {
@@ -452,7 +452,7 @@ static const fn::MultiFunction &create_function_for_node_that_expands_into_multi
}
}
- fn::MFNetworkEvaluator &fn_evaluator = resources.construct<fn::MFNetworkEvaluator>(
+ fn::MFNetworkEvaluator &fn_evaluator = scope.construct<fn::MFNetworkEvaluator>(
__func__, std::move(dummy_fn_inputs), std::move(dummy_fn_outputs));
return fn_evaluator;
}
@@ -461,16 +461,15 @@ static const fn::MultiFunction &create_function_for_node_that_expands_into_multi
* Returns a single multi-function for every node that supports it. This makes it easier to reuse
* the multi-function implementation of nodes in different contexts.
*/
-MultiFunctionByNode get_multi_function_per_node(const DerivedNodeTree &tree,
- ResourceCollector &resources)
+MultiFunctionByNode get_multi_function_per_node(const DerivedNodeTree &tree, ResourceScope &scope)
{
/* Build a network that nodes can insert themselves into. However, the individual nodes are not
* connected. */
- fn::MFNetwork &network = resources.construct<fn::MFNetwork>(__func__);
+ fn::MFNetwork &network = scope.construct<fn::MFNetwork>(__func__);
MFNetworkTreeMap network_map{tree, network};
MultiFunctionByNode functions_by_node;
- CommonMFNetworkBuilderData common{resources, network, network_map, tree};
+ CommonMFNetworkBuilderData common{scope, network, network_map, tree};
tree.foreach_node([&](DNode dnode) {
const bNodeType *node_type = dnode->typeinfo();
@@ -499,7 +498,7 @@ MultiFunctionByNode get_multi_function_per_node(const DerivedNodeTree &tree,
/* If a node expanded into multiple functions, a new function has to be created that
* combines those. */
const fn::MultiFunction &fn = create_function_for_node_that_expands_into_multiple(
- dnode, network, network_map, resources);
+ dnode, network, network_map, scope);
functions_by_node.add_new(dnode, &fn);
break;
}
diff --git a/source/blender/nodes/intern/type_callbacks.cc b/source/blender/nodes/intern/type_callbacks.cc
index 26eeaebc6d4..5160432aea5 100644
--- a/source/blender/nodes/intern/type_callbacks.cc
+++ b/source/blender/nodes/intern/type_callbacks.cc
@@ -64,7 +64,8 @@ void socket_expand_in_mf_network(SocketMFNetworkBuilder &builder)
}
else if (socket.typeinfo->get_cpp_value != nullptr) {
const CPPType &type = *socket_cpp_type_get(*socket.typeinfo);
- void *buffer = builder.resources().linear_allocator().allocate(type.size(), type.alignment());
+ void *buffer = builder.resource_scope().linear_allocator().allocate(type.size(),
+ type.alignment());
socket.typeinfo->get_cpp_value(socket, buffer);
builder.set_constant_value(type, buffer);
}