Commit Graph

30 Commits

Author SHA1 Message Date
Jacques Lucke
fe49e4139c Simulation: cleanup deduplicating attribute input nodes 2020-07-18 10:51:38 +02:00
Jacques Lucke
2679236047 Cleanup: avoid static initialization order issues when accessing CPPTypes
Instead of depending on static initialization order of globals use
static variables within functions. Those are initialized on first use.
This is every so slighly less efficient, but avoids a full class of problems.
2020-07-17 14:15:06 +02:00
Jacques Lucke
2ddb3dc617 Nodes: support default function for partially implemented nodes 2020-07-16 13:38:23 +02:00
Jacques Lucke
0718c6fae0 Cleanup: fix clang tidy warning
The code was actually correct, but clang tidy complaint about
using the Vector after it was moved from.
2020-07-13 10:40:05 +02:00
Jacques Lucke
838b1742fb Functions: minor improvements 2020-07-12 12:38:03 +02:00
Jacques Lucke
06401157a6 Fix: incorrect attribute type in network 2020-07-11 17:59:43 +02:00
Jacques Lucke
c806db6313 Functions: add utility to find dependencies of input sockets 2020-07-10 14:23:13 +02:00
Jacques Lucke
295b3aefb0 Functions: make constant folding work on unfinished networks 2020-07-10 14:23:13 +02:00
Jacques Lucke
8fd65a2252 Functions: use new is-equal and hash function of CPPType 2020-07-10 12:57:28 +02:00
Campbell Barton
3dd460aa7f Cleanup: spelling 2020-07-10 11:49:46 +10:00
Jacques Lucke
31bc76ea4e Cleanup: remove unnecessary calls to as_span
This uses the new implicit conversions and constructors
that have been committed in the previous commit.

I tested these changes on Linux with gcc and on Windows.
2020-07-08 22:30:23 +02:00
Jacques Lucke
439c238bb4 Cleanup: use different internal socket name 2020-07-08 17:05:52 +02:00
Jacques Lucke
d1f4546a59 Functions: implement common subnetwork elimination optimization
This was the last of the three network optimizations I developed in
the functions branch. Common subnetwork elimination and constant
folding together can get rid of most unnecessary nodes.
2020-07-08 15:10:30 +02:00
Jacques Lucke
34d175f372 Functions: initial hash/equals implementation for constant multi-functions 2020-07-08 15:10:30 +02:00
Jacques Lucke
45004d82e0 Functions: add dead node removal and constant folding optimization
Those optimizations work on the multi-function network level.
Not only will they make the network evaluation faster, but they also
simplify the network a lot. That makes it easier to understand the
exported dot graph.
2020-07-08 11:18:43 +02:00
Jacques Lucke
902ee4d13c Functions: cleanup loop that traverses the MFNetwork 2020-07-07 19:46:10 +02:00
Jacques Lucke
22158162ef Functions: add generic functions that output constants 2020-07-07 19:34:35 +02:00
Jacques Lucke
67042aa6a1 Functions: extend multi-function network api 2020-07-07 18:45:34 +02:00
Jacques Lucke
395b294b61 Cleanup: use nested namespaces 2020-07-03 14:25:20 +02:00
Jacques Lucke
5fbf70b0d0 Cleanup: use trailing underscore for non-public data members 2020-07-03 14:20:42 +02:00
Jacques Lucke
c2ebf3edb4 Functions: provide dummy multi function
Sometimes it is convenient to be able to return a reference to some
dummy function.
2020-06-30 18:18:48 +02:00
Jacques Lucke
67da2bd23a Functions: add methods to multi-function network classes
Those are necessary to query and modify the network.
2020-06-30 18:18:48 +02:00
Jacques Lucke
784911a4a0 Cleanup: rename namespace DotExport to dot 2020-06-29 11:53:17 +02:00
Jacques Lucke
ff82049642 Functions: add MutableAttributesRef data structure
This will be used to reference the content of a CustomData structure
in C++ code, that does not need to know who owns the data but only
works with it.
2020-06-27 20:58:35 +02:00
Campbell Barton
fd5c185beb Cleanup: spelling 2020-06-25 23:14:36 +10:00
Jacques Lucke
3a3708cefb Functions: Multi Function Network
A multi-function network is a graph data structure, where nodes are
multi-functions (or dummies) and links represent data flow.
New multi-functions can be derived from such a network. For that
one just has to specify two sets of sockets in the network that
represent the inputs and outputs of the new function.

It is possible to do optimizations like constant folding on this
data structure, but that is not implemented in this patch yet.

In a next step, user generated node trees are converted into a
MFNetwork, so that they can be evaluated efficiently for many particles.

This patch also includes some tests that cover the majority of the code.
However, this seems to be the kind of code that is best tested by some
.blend files. Building graph structures in code is possible, but is
not easy to understand afterwards.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D8049
2020-06-23 10:16:14 +02:00
Jacques Lucke
4365de3870 Functions: Multi Function
This adds the `MultiFunction` type and some smallish utility types that it uses.
A `MultiFunction` encapsulates a function that is optimized for throughput by
always processing many elements at once.

This is an important part of the new particle system, because it allows us to
execute user generated node trees for many particles efficiently.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D8030
2020-06-16 16:35:57 +02:00
Sergey Sharybin
9cc0597556 Functions: Wrap into blender namespace
Similar to previous commit, aims to resolve compilation on
devtoolset-6.
2020-06-12 15:39:16 +02:00
Jacques Lucke
9bb7d6ed68 BLI: put C++ data structures in "blender" namespace instead of "BLI"
We plan to use the "blender" namespace in other modules as well.
2020-06-09 10:27:24 +02:00
Jacques Lucke
0a907657d4 Functions: Run-time type system and index mask
This adds a new `CPPType` that encapsulates information about how to handle
instances of a specific data type. This is necessary for the function evaluation
system, which will be used to evaluate most of the particle node trees.

Furthermore, this adds an `IndexMask` class which offers a surprisingly useful
abstraction over an array containing unsigned integers. It makes two assumptions
about the underlying integer array:
* The integers are in ascending order.
* There are no duplicates.

`IndexMask` will be used to "select" certain particles that will be
processed in a data-oriented way. Sometimes, operations don't have to
be applied to all particles, but only some, those that are in the indexed by
the `IndexMask`. The two limitations imposed by an `IndexMask` allow for
better performance.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D7957
2020-06-08 17:37:43 +02:00