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:
Diffstat (limited to 'source/blender/functions/intern/multi_function_network_optimization.cc')
-rw-r--r--source/blender/functions/intern/multi_function_network_optimization.cc46
1 files changed, 23 insertions, 23 deletions
diff --git a/source/blender/functions/intern/multi_function_network_optimization.cc b/source/blender/functions/intern/multi_function_network_optimization.cc
index 849b24a318f..e76b2f51a15 100644
--- a/source/blender/functions/intern/multi_function_network_optimization.cc
+++ b/source/blender/functions/intern/multi_function_network_optimization.cc
@@ -107,7 +107,7 @@ static Vector<MFNode *> find_nodes_based_on_mask(MFNetwork &network,
bool mask_value)
{
Vector<MFNode *> nodes;
- for (uint id : id_mask.index_range()) {
+ for (int id : id_mask.index_range()) {
if (id_mask[id] == mask_value) {
MFNode *node = network.node_or_null_by_id(id);
if (node != nullptr) {
@@ -212,7 +212,7 @@ static void prepare_params_for_constant_folding(const MultiFunction &network_fn,
MFParamsBuilder &params,
ResourceCollector &resources)
{
- for (uint param_index : network_fn.param_indices()) {
+ for (int param_index : network_fn.param_indices()) {
MFParamType param_type = network_fn.param_type(param_index);
MFDataType data_type = param_type.data_type();
@@ -244,7 +244,7 @@ static Array<MFOutputSocket *> add_constant_folded_sockets(const MultiFunction &
{
Array<MFOutputSocket *> folded_sockets{network_fn.param_indices().size(), nullptr};
- for (uint param_index : network_fn.param_indices()) {
+ for (int param_index : network_fn.param_indices()) {
MFParamType param_type = network_fn.param_type(param_index);
MFDataType data_type = param_type.data_type();
@@ -302,7 +302,7 @@ void constant_folding(MFNetwork &network, ResourceCollector &resources)
Array<MFOutputSocket *> folded_sockets = compute_constant_sockets_and_add_folded_nodes(
network, inputs_to_fold, resources);
- for (uint i : inputs_to_fold.index_range()) {
+ for (int i : inputs_to_fold.index_range()) {
MFOutputSocket &original_socket = *inputs_to_fold[i]->origin();
network.relink(original_socket, *folded_sockets[i]);
}
@@ -317,12 +317,12 @@ void constant_folding(MFNetwork &network, ResourceCollector &resources)
*
* \{ */
-static uint32_t compute_node_hash(MFFunctionNode &node, RNG *rng, Span<uint32_t> node_hashes)
+static uint64_t compute_node_hash(MFFunctionNode &node, RNG *rng, Span<uint64_t> node_hashes)
{
- uint32_t combined_inputs_hash = 394659347u;
+ uint64_t combined_inputs_hash = 394659347u;
for (MFInputSocket *input_socket : node.inputs()) {
MFOutputSocket *origin_socket = input_socket->origin();
- uint32_t input_hash;
+ uint64_t input_hash;
if (origin_socket == nullptr) {
input_hash = BLI_rng_get_uint(rng);
}
@@ -333,8 +333,8 @@ static uint32_t compute_node_hash(MFFunctionNode &node, RNG *rng, Span<uint32_t>
combined_inputs_hash = BLI_ghashutil_combine_hash(combined_inputs_hash, input_hash);
}
- uint32_t function_hash = node.function().hash();
- uint32_t node_hash = BLI_ghashutil_combine_hash(combined_inputs_hash, function_hash);
+ uint64_t function_hash = node.function().hash();
+ uint64_t node_hash = BLI_ghashutil_combine_hash(combined_inputs_hash, function_hash);
return node_hash;
}
@@ -342,15 +342,15 @@ static uint32_t compute_node_hash(MFFunctionNode &node, RNG *rng, Span<uint32_t>
* Produces a hash for every node. Two nodes with the same hash should have a high probability of
* outputting the same values.
*/
-static Array<uint32_t> compute_node_hashes(MFNetwork &network)
+static Array<uint64_t> compute_node_hashes(MFNetwork &network)
{
RNG *rng = BLI_rng_new(0);
- Array<uint32_t> node_hashes(network.node_id_amount());
+ Array<uint64_t> node_hashes(network.node_id_amount());
Array<bool> node_is_hashed(network.node_id_amount(), false);
/* No dummy nodes are not assumed to output the same values. */
for (MFDummyNode *node : network.dummy_nodes()) {
- uint32_t node_hash = BLI_rng_get_uint(rng);
+ uint64_t node_hash = BLI_rng_get_uint(rng);
node_hashes[node->id()] = node_hash;
node_is_hashed[node->id()] = true;
}
@@ -381,7 +381,7 @@ static Array<uint32_t> compute_node_hashes(MFNetwork &network)
continue;
}
- uint32_t node_hash = compute_node_hash(node, rng, node_hashes);
+ uint64_t node_hash = compute_node_hash(node, rng, node_hashes);
node_hashes[node.id()] = node_hash;
node_is_hashed[node.id()] = true;
nodes_to_check.pop();
@@ -391,14 +391,14 @@ static Array<uint32_t> compute_node_hashes(MFNetwork &network)
return node_hashes;
}
-static Map<uint32_t, Vector<MFNode *, 1>> group_nodes_by_hash(MFNetwork &network,
- Span<uint32_t> node_hashes)
+static Map<uint64_t, Vector<MFNode *, 1>> group_nodes_by_hash(MFNetwork &network,
+ Span<uint64_t> node_hashes)
{
- Map<uint32_t, Vector<MFNode *, 1>> nodes_by_hash;
- for (uint id : IndexRange(network.node_id_amount())) {
+ Map<uint64_t, Vector<MFNode *, 1>> nodes_by_hash;
+ for (int id : IndexRange(network.node_id_amount())) {
MFNode *node = network.node_or_null_by_id(id);
if (node != nullptr) {
- uint32_t node_hash = node_hashes[id];
+ uint64_t node_hash = node_hashes[id];
nodes_by_hash.lookup_or_add_default(node_hash).append(node);
}
}
@@ -428,7 +428,7 @@ static bool nodes_output_same_values(DisjointSet &cache, const MFNode &a, const
if (!functions_are_equal(a.as_function().function(), b.as_function().function())) {
return false;
}
- for (uint i : a.inputs().index_range()) {
+ for (int i : a.inputs().index_range()) {
const MFOutputSocket *origin_a = a.input(i).origin();
const MFOutputSocket *origin_b = b.input(i).origin();
if (origin_a == nullptr || origin_b == nullptr) {
@@ -444,7 +444,7 @@ static bool nodes_output_same_values(DisjointSet &cache, const MFNode &a, const
}
static void relink_duplicate_nodes(MFNetwork &network,
- Map<uint32_t, Vector<MFNode *, 1>> &nodes_by_hash)
+ Map<uint64_t, Vector<MFNode *, 1>> &nodes_by_hash)
{
DisjointSet same_node_cache{network.node_id_amount()};
@@ -462,7 +462,7 @@ static void relink_duplicate_nodes(MFNetwork &network,
/* This is true with fairly high probability, but hash collisions can happen. So we have to
* check if the node actually output the same values. */
if (nodes_output_same_values(same_node_cache, deduplicated_node, *node)) {
- for (uint i : deduplicated_node.outputs().index_range()) {
+ for (int i : deduplicated_node.outputs().index_range()) {
network.relink(node->output(i), deduplicated_node.output(i));
}
}
@@ -481,8 +481,8 @@ static void relink_duplicate_nodes(MFNetwork &network,
*/
void common_subnetwork_elimination(MFNetwork &network)
{
- Array<uint32_t> node_hashes = compute_node_hashes(network);
- Map<uint32_t, Vector<MFNode *, 1>> nodes_by_hash = group_nodes_by_hash(network, node_hashes);
+ Array<uint64_t> node_hashes = compute_node_hashes(network);
+ Map<uint64_t, Vector<MFNode *, 1>> nodes_by_hash = group_nodes_by_hash(network, node_hashes);
relink_duplicate_nodes(network, nodes_by_hash);
}