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
AgeCommit message (Collapse)Author
2021-12-09Cleanup: move public doc-strings into headers for 'functions'Campbell Barton
Ref T92709
2021-12-06Geometry Nodes: reduce code duplication with new GeometyrFieldInputJacques Lucke
Most of our field inputs are currently specific to geometry. This patch introduces a new `GeometryFieldInput` that reduces the overhead of adding new geometry field input. Differential Revision: https://developer.blender.org/D13489
2021-11-26Geometry Nodes: deduplicate virtual array implementationsJacques Lucke
For some underlying data (e.g. spans) we had two virtual array implementations. One for the mutable and one for the immutable case. Now that most code does not deal with the virtual array implementations directly anymore (since rBrBd4c868da9f97a), we can get away with sharing one implementation for both cases. This means that we have to do a `const_cast` in a few places, but this is an implementation detail that does not leak into "user code" (only when explicitly casting a `VArrayImpl` to a `VMutableArrayImpl`, which should happen nowhere).
2021-11-26Fix: error in previous commitJacques Lucke
Forgot to actually slice the span in rB6b5e1cfacab4c4605ec2d7bfef360389afe849be.
2021-11-26Geometry Nodes: refactor multi-threading in field evaluationJacques Lucke
Previously, there was a fixed grain size for all multi-functions. That was not sufficient because some functions could benefit a lot from smaller grain sizes. This refactors adds a new `MultiFunction::call_auto` method which has the same effect as just calling `MultiFunction::call` but additionally figures out how to execute the specific multi-function efficiently. It determines a good grain size and decides whether the mask indices should be shifted or not. Most multi-function evaluations benefit from this, but medium sized work loads (1000 - 50000 elements) benefit from it the most. Especially when expensive multi-functions (e.g. noise) is involved. This is because for smaller work loads, threading is rarely used and for larger work loads threading worked fine before already. With this patch, multi-functions can specify execution hints, that allow the caller to execute it most efficiently. These execution hints still have to be added to more functions. Some performance measurements of a field evaluation involving noise and math nodes, ordered by the number of elements being evaluated: ``` 1,000,000: 133 ms -> 120 ms 100,000: 30 ms -> 18 ms 10,000: 20 ms -> 2.7 ms 1,000: 4 ms -> 0.5 ms 100: 0.5 ms -> 0.4 ms ```
2021-11-26Geometry Nodes: better devirtualization for sliced virtual arraysJacques Lucke
Under some circumstances that can lead to more than a 2x performance increase, because math nodes can better optimize for the case when the slice is a single value or span.
2021-11-26Geometry Nodes: avoid allocation when construct varray for single valueJacques Lucke
Previously, `GVArray::ForSingle` would always allocate a copy of the passed in value. Now it only does so when the value is too large or not trivial.
2021-11-25BLI: remove special cases for is_span and is_single methodsJacques Lucke
Those were not implemented consistently and don't really help in practice.
2021-11-24BLI: add slice method to index mask and generic spanJacques Lucke
2021-11-23Geometry Nodes: reduce overhead when processing single valuesJacques Lucke
Currently the geometry nodes evaluator always stores a field for every type that supports it, even if it is just a single value. This results in a lot of overhead when there are many sockets that just contain a single value, which is often the case. This introduces a new `ValueOrField<T>` type that is used by the geometry nodes evaluator. Now a field will only be created when it is actually necessary. See D13307 for more details. In extrem cases this can speed up the evaluation 2-3x (those cases are probably never hit in practice though, but it's good to get rid of unnecessary overhead nevertheless). Differential Revision: https://developer.blender.org/D13307
2021-11-22Cleanup: make naming more consistentJacques Lucke
2021-11-21Functions: remove test for dynamic nameJacques Lucke
This was broken in rB6ee2abde82ef121cd6e927995053ac33afdbb438.
2021-11-21Functions: fix compile error in testsJacques Lucke
2021-11-21Functions: use static string for parameter namesJacques Lucke
The idea behind this change is the same as in rB6ee2abde82ef121cd6e927995053ac33afdbb438. A `MultiFunction::debug_parameter_name` method could be added separately when necessary.
2021-11-21Functions: use static names for multi-functionsJacques Lucke
Previously, the function names were stored in `std::string` and were often created dynamically (especially when the function just output a constant). This resulted in a lot of overhead. Now the function name is just a `const char *` that should be statically allocated. This is good enough for the majority of cases. If a multi-function needs a more dynamic name, it can override the `MultiFunction::debug_name` method. In my test file with >400,000 simple math nodes, the execution time improves from 3s to 1s.
2021-11-17Cleanup: remove dummy multi functionJacques Lucke
2021-11-17Fix error with makefiles compilationGermano Cavalcante
Use 'template' keyword to treat 'is' as a dependent template name
2021-11-16Geometry Nodes: refactor virtual array systemJacques Lucke
Goals of this refactor: * Simplify creating virtual arrays. * Simplify passing virtual arrays around. * Simplify converting between typed and generic virtual arrays. * Reduce memory allocations. As a quick reminder, a virtual arrays is a data structure that behaves like an array (i.e. it can be accessed using an index). However, it may not actually be stored as array internally. The two most important implementations of virtual arrays are those that correspond to an actual plain array and those that have the same value for every index. However, many more implementations exist for various reasons (interfacing with legacy attributes, unified iterator over all points in multiple splines, ...). With this refactor the core types (`VArray`, `GVArray`, `VMutableArray` and `GVMutableArray`) can be used like "normal values". They typically live on the stack. Before, they were usually inside a `std::unique_ptr`. This makes passing them around much easier. Creation of new virtual arrays is also much simpler now due to some constructors. Memory allocations are reduced by making use of small object optimization inside the core types. Previously, `VArray` was a class with virtual methods that had to be overridden to change the behavior of a the virtual array. Now,`VArray` has a fixed size and has no virtual methods. Instead it contains a `VArrayImpl` that is similar to the old `VArray`. `VArrayImpl` should rarely ever be used directly, unless a new virtual array implementation is added. To support the small object optimization for many `VArrayImpl` classes, a new `blender::Any` type is added. It is similar to `std::any` with two additional features. It has an adjustable inline buffer size and alignment. The inline buffer size of `std::any` can't be relied on and is usually too small for our use case here. Furthermore, `blender::Any` can store additional user-defined type information without increasing the stack size. Differential Revision: https://developer.blender.org/D12986
2021-11-08CMake: add missing headers to CMake listsCampbell Barton
2021-10-26Geometry Nodes: remove reference to anonymous attributes in tooltipsJacques Lucke
This changes socket inspection for fields according to T91881. Differential Revision: https://developer.blender.org/D13006
2021-10-24Fix T92327: use default value when field is passed into data socketJacques Lucke
Previously, the computed value passed into the data socket could depend on the actual field a bit. However, given that the link is marked as invalid in the ui, the user should not depend on this behavior. Using a default value is consistent with other cases when there are invalid links.
2021-10-20Geometry Nodes: Make Random ID a builtin attribute, remove socketsHans Goudey
In order to address feedback that the "Stable ID" was not easy enough to use, remove the "Stable ID" output from the distribution node and the input from the instance on points node. Instead, the nodes write or read a builtin named attribute called `id`. In the future we may add more attributes like `edge_id` and `face_id`. The downside is that more behavior is invisible, which is les expected now that most attributes are passed around with node links. This behavior will have to be explained in the manual. The random value node's "ID" input that had an implicit index input is converted to a special implicit input that uses the `id` attribute if possible, but otherwise defaults to the index. There is no way to tell in the UI which it uses, except by knowing that rule and checking in the spreadsheet for the id attribute. Because it isn't always possible to create stable randomness, this attribute does not always exist, and it will be possible to remove it when we have the attribute remove node back, to improve performance. Differential Revision: https://developer.blender.org/D12903
2021-10-20Cleanup: sort cmake file listsCampbell Barton
2021-10-19Geometry Nodes: De-duplicate index input nodes during evaluationHans Goudey
We do this in other nodes to reduce overhead of using the same node more than once. I don't think it will make a difference with index nodes currently, but at least it's consistent.
2021-10-18Geometry Nodes: decouple multi-function lifetimes from modifierJacques Lucke
Previously, some multi-functions were allocated in a resource scope. This was fine as long as the multi-functions were only needed during the current evaluation of the node tree. However, now cases arise that require the multi-functions to be alive after the modifier is finished. For example, we want to evaluate fields created with geometry nodes outside of geometry nodes. To make this work, `std::shared_ptr` has to be used in a few more places. Realistically, this shouldn't have a noticable impact on performance. If this does become a bottleneck in the future, we can think about ways to make this work without using `shared_ptr` for multi-functions that are only used once.
2021-10-14Functions: Generic array data structureHans Goudey
Sometimes it's useful to pass around a set of values with a generic type. The virtual array data structures allow this, but they don't have logical ownership. My initial use case for this is as a return type for the functions that interpolate curve attributes to evaluated points, but a need for this data structure has come up in a few other places as well. It also reduced the need for templates. Differential Revision: https://developer.blender.org/D11103
2021-10-05Cleanup: use doxygen sectionsCampbell Barton
2021-10-03Cleanup: move methods out of field classesJacques Lucke
This makes it easier to scan through the classes and simplifies testing the compile time impact of having these methods in the header.
2021-09-29Cleanup: sort cmake file listsCampbell Barton
2021-09-27Functions: fail early when multi-function throws an exceptionJacques Lucke
Multi-functions are not allowed to throw exceptions that are not caught in the same multi-function. Previously, it was difficult to backtrack a crash to a previously thrown exception.
2021-09-27Cleanup: simplify field evaluationJacques Lucke
2021-09-27Fix T91732: crash in Set Position node on empty meshJacques Lucke
2021-09-24Fix: field evaluation crash when the domain size is zeroJacques Lucke
2021-09-24Geometry Nodes: make index field more reusableJacques Lucke
Some inputs will be the index field implicitly, so we want this class to be available outside of `node_geo_input_index.cc`.
2021-09-22Geometry Nodes: fix evaluating field to spanJacques Lucke
2021-09-21Functions: make asserts more correctJacques Lucke
It is valid to e.g. copy construct an integer in the same place, because it is a trivial type. It does not work for types like std::string. This fixes a crash reported in D12584 where it would copy a buffer into itself. We should probably also avoid doing this copy alltogether but that can be done separately.
2021-09-21Functions: Fix incorrect assert for unused outputHans Goudey
Since the variable for an output parameter can be null, it is incorrect to use it later on in a reference.
2021-09-20Geometry Nodes: support Noise Texture nodeJacques Lucke
This makes the Noise Texture node available in geometry nodes. It should behave the same as in shader node, with the exception that it does not have an implicit position input yet. That will be added separately. Differential Revision: https://developer.blender.org/D12467
2021-09-15Geometry Nodes: multi threaded field evaluationJacques Lucke
This adds a new `ParallelMultiFunction` which wraps another multi-function and evaluates it with multiple threads. The speeds up field evaluation quite a bit (the effect is most noticeable when the number of evaluations and the field is large). There are still other single-threaded performance bottlenecks in field evaluation that will need to be solved separately. Most notably here is the process of copying the computed data into the position attribute in the Set Position node. Differential Revision: https://developer.blender.org/D12457
2021-09-14Cleanup: simplify resource scope methodsJacques Lucke
Previously, a debug name had to be passed to all methods that added a resource to the `ResourceScope`. The idea was that this would make it easier to find certain bugs. In reality I never found this to be useful, and it was mostly annoying. The thing is, something that is in a resource scope never leaks (unless the resource scope is not destructed of course). Removing the name parameter makes the structure easier to use.
2021-09-14Functions: support optional outputs in multi-functionJacques Lucke
Sometimes not all outputs of a multi-function are required by the caller. In those cases it would be a waste of compute resources to calculate the unused values anyway. Now, the caller of a multi-function can specify when a specific output is not used. The called function can check if an output is unused and may ignore it. Multi-functions can still computed unused outputs as before if they don't want to check if a specific output is unused. The multi-function procedure system has been updated to support ignored outputs in call instructions. An ignored output just has no variable assigned to it. The field system has been updated to generate a multi-function procedure where unused outputs are ignored.
2021-09-13Fix: fix equality operator for fieldsJacques Lucke
Instead of comparing the referenced field node by pointer, compare the nodes directly instead. This is important because different field nodes might be the same semantically.
2021-09-12Cleanup: spellingCampbell Barton
2021-09-11Geometry Nodes: add field support for socket inspectionJacques Lucke
Since fields were committed to master, socket inspection did not work correctly for all socket types anymore. Now the same functionality as before is back. Furthermore, fields that depend on some input will now show the inputs in the socket inspection. I added support for evaluating constant fields more immediately. This has the benefit that the same constant field is not evaluated more than once. It also helps with making the field independent of the multi-functions that it uses. We might still want to change the ownership handling for the multi-functions of nodes a bit, but that can be done separately. Differential Revision: https://developer.blender.org/D12444
2021-09-11Cleanup: use nullptrJacques Lucke
2021-09-11Functions: store cursors to previous instructionsJacques Lucke
Now an instruction knows the cursors where it is inserted instead of just the instruction that references it. This has two benefits: * An instruction knows when it is the entry instruction. * The cursor can contain more information, e.g. if it is linked to the true or false branch of a branch instruction. This also simplifies updating the procedure in future optimization passes.
2021-09-09Fix compiler warnings about virtual functions but non-virtual destructorBrecht Van Lommel
2021-09-09Geometry Nodes: fields and anonymous attributesJacques Lucke
This implements the initial core framework for fields and anonymous attributes (also see T91274). The new functionality is hidden behind the "Geometry Nodes Fields" feature flag. When enabled in the user preferences, the following new nodes become available: `Position`, `Index`, `Normal`, `Set Position` and `Attribute Capture`. Socket inspection has not been updated to work with fields yet. Besides these changes at the user level, this patch contains the ground work for: * building and evaluating fields at run-time (`FN_fields.hh`) and * creating and accessing anonymous attributes on geometry (`BKE_anonymous_attribute.h`). For evaluating fields we use a new so called multi-function procedure (`FN_multi_function_procedure.hh`). It allows composing multi-functions in arbitrary ways and supports efficient evaluation as is required by fields. See `FN_multi_function_procedure.hh` for more details on how this evaluation mechanism can be used. A new `AttributeIDRef` has been added which allows handling named and anonymous attributes in the same way in many places. Hans and I worked on this patch together. Differential Revision: https://developer.blender.org/D12414
2021-08-20Functions: remove multi-function networkJacques Lucke
The multi-function network system was able to compose multiple multi-functions into a new one and to evaluate that efficiently. This functionality was heavily used by the particle nodes prototype a year ago. However, since then we only used multi-functions without the need to compose them in geometry nodes. The upcoming "fields" in geometry nodes will need a way to compose multi-functions again. Unfortunately, the code removed in this commit was not ideal for this different kind of function composition. I've been working on an alternative that will be added separately when it becomes needed. I've had to update all the function nodes, because their interface depended on the multi-function network data structure a bit. The actual multi-function implementations are still the same though.
2021-08-20Functions: add utility methods to parameter builderJacques Lucke