Commit Graph

237 Commits

Author SHA1 Message Date
Brecht Van Lommel
3b47f335c6 BLI: remove TaskParallelRangePool
This is not currently used and will take some work to support with TBB, so
remove it until we have a new implementation based on TBB.

Fixes T76005, parallel range pool tests failing.

Ref D7475
2020-04-23 15:39:34 +02:00
Brecht Van Lommel
8f51f60948 Fix T76005: BLI_task test failing after recent changes
This was an error in changes made to this test to accomodate the new reduce
callback.
2020-04-23 14:04:29 +02:00
Jacques Lucke
614621747e BLI: optimize VectorSet implementation
Instead of building on top of `BLI::Vector`, just use a raw array
and handle the growing in `BLI::VectorSet`.

After this change, the existing `EdgeSet` can be reimplemented using
`BLI::VectorSet` without performance regressions.
2020-04-23 12:02:06 +02:00
Ray Molenkamp
6c9bebd827 Tests: Fix build error in BKE_armature test
Test does not link due to missing symbols, needs
buildinfoobj to link against when WITH_BUILDINFO is on
2020-04-22 07:47:32 -06:00
93e193399d Tests: added unit test for mat3_vec_to_roll() function
This was used to investigate T73840. Since the armature math is far from
simple, I thought it would be a good idea to start writing some unit
tests for it.

No functional changes in Blender itself.
2020-04-21 17:58:27 +02:00
Jacques Lucke
29e9506a7f BLI: simplify naming of listbase wrapper 2020-04-21 17:38:19 +02:00
Jacques Lucke
3059353b38 BLI: Use .hh extension for C++ headers in blenlib 2020-04-21 17:31:56 +02:00
Jeroen Bakker
2d6ad88466 CleanUp: Renamed BLI_task_pool_userdata to BLI_task_pool_user_data
In preparation for {D7475}
2020-04-21 15:37:36 +02:00
Jeroen Bakker
d923fb784f Task: Separate Finalize into Reduce And Free
In preparation of TBB we need to split the finalize function into reduce
and free. Reduce is used to combine results and free for freeing any
allocated memory.

The reduce function is called to join user data chunk into another, to reduce the
result to the original userdata_chunk memory. These functions should have no side
effects so that they can be run on any thread.
The free functions should free data created during execution (TaskParallelRangeFunc).

Original patch by Brecht van Lommel
{rB61f49db843cf5095203112226ae386f301be1e1a}.

Reviewed By: Brecht van Lommel, Bastien Montagne

Differential Revision: https://developer.blender.org/D7394
2020-04-17 16:06:54 +02:00
78f56d5582 TaskScheduler: Minor Preparations for TBB
Tasks: move priority from task to task pool {rBf7c18df4f599fe39ffc914e645e504fcdbee8636}
Tasks: split task.c into task_pool.cc and task_iterator.c {rB4ada1d267749931ca934a74b14a82479bcaa92e0}

Differential Revision: https://developer.blender.org/D7385
2020-04-09 19:18:14 +02:00
17da3b5d82 USD: ensure test does not depend on BLI_assert()
The test failure in T75491 only showed up in debug builds because
`BLI_assert()` is a no-op in release builds. This is now replaced by a
proper GTests call to `ADD_FAILURE()`, ensuring that the test fails
regardless of build mode.
2020-04-09 12:14:51 +02:00
Campbell Barton
d14e768069 Cleanup: BLI_path.h function renaming
Use BLI_path_ prefix, more consistent names:

  BLI_parent_dir              -> BLI_path_parent_dir
  BLI_parent_dir_until_exists -> BLI_path_parent_dir_until_exists
  BLI_ensure_filename         -> BLI_path_filename_ensure
  BLI_first_slash             -> BLI_path_slash_find
  BLI_last_slash              -> BLI_path_slash_rfind
  BLI_add_slash               -> BLI_path_slash_ensure
  BLI_del_slash               -> BLI_path_slash_rstrip
  BLI_path_native_slash       -> BLI_path_slash_native

Rename 'cleanup' to 'normalize', similar to Python's `os.path.normpath`.

  BLI_cleanup_path  -> BLI_path_normalize
  BLI_cleanup_dir   -> BLI_path_normalize_dir
  BLI_cleanup_unc   -> BLI_path_normalize_unc
  BLI_cleanup_unc16 -> BLI_path_normalize_unc16

Clarify naming for extracting, creating numbered paths:

  BLI_stringenc -> BLI_path_sequence_encode
  BLI_stringdec -> BLI_path_sequence_decode

Part of T74506 proposal.
2020-04-07 12:10:36 +10:00
Dalai Felinto
2d1cce8331 Cleanup: make format after SortedIncludes change 2020-03-19 09:33:58 +01:00
Sergey Sharybin
5a664c6e98 Fix another implicit cast of boot to int
Use proper comparison to nullptr.

It is important to use nullptr since NULL is actually an integer,
which leads to another type of warnings.
2020-03-16 12:15:16 +01:00
Sergey Sharybin
7df435325b Fix implicit cast from bool to int in path tests 2020-03-16 10:53:46 +01:00
Howard Trickey
cebff2ff30 Fix a syntax error in test spec for BLI_delaunay_2d_test.
Test specs are read from strings, and there was a comma instead
of a decimal point, and then an extra decimal point in the Quad0 test.
This test has been flaky on Windows buildbot. Perhaps this is why.
2020-03-15 17:14:04 -04:00
eb522af4fe Cleanup: move Alembic, AVI, Collada, and USD to source/blender/io
This moves the `alembic`, `avi`, `collada`, and `usd` modules into a common
`io` directory.

This also cleans up some `#include "../../{somedir}/{somefile}.h"` by
adding `../../io/{somedir}` to `CMakeLists.txt` and then just using
`#include "{somefile}.h"`.

No functional changes.
2020-03-06 16:19:45 +01:00
Bastien Montagne
c328049535 Initial step for IDTypeInfo refactor 'cleanup' project.
Introduce new IDTypeInfo structure.

Each ID type will have its own, with some minimal basic common info,
and ID management callbacks.

This patch only does it for Object type, for demo/testing purpose.
Moving all existing IDs is a goal of next "cleanup Friday".

Note that BKE_idcode features should then be merged back into BKE_idtype -
but this will have to be done later, once all ID types have been properly
converted to the new system.

Another later TODO might be to try and add callbacks for file read/write,
and lib_query ID usages looper.

This is part of T73719.

Thanks to @brecht for initial idea, and reviewing the patch.

Differential Revision: https://developer.blender.org/D6966
2020-03-05 10:58:58 +01:00
Campbell Barton
a5c984a57d Cleanup: cmake indentation 2020-03-04 11:02:35 +11:00
Tiago Chaves
14c9f64def BLI_math: add clamp_v# and clamp_v#_v#v# utility functions 2020-03-04 10:25:44 +11:00
Howard Trickey
ed29ff944a Fix delaunay triangulation, bad indices for output faces.
If there were merged vertices, sometimes the output faces
had wrong vertex indices. Added a test for this, and fixed.
2020-03-03 08:41:26 -05:00
Ish Bosamiya
5afa4b1dc8 Fix T65568: sewing and self collision issue
As explained in T65568 by @LucaRood, the self collision system should exclude triangles that are connected by sewing springs.

Differential Revision: https://developer.blender.org/D6911
2020-03-02 11:02:26 -03:00
Howard Trickey
f2557d137a Fix problem with Delaunay triangulalation re output mapping.
The array giving original vertex indices should not contain
entries for newly created vertices. Added a test to check this.
2020-03-01 12:25:44 -05:00
Howard Trickey
cb8b424c6b Made BLI_delaunay_2d_cdt_calc better at tiny feature elimination.
The 'random' unit tests and some examples from the new boolean code
triggered asserts and crashes. This fixes those.
There is a new flag in the input that optionally disables a pass
over input to snap segment edges to other segments.
2020-02-29 13:26:27 -05:00
Campbell Barton
1135c2cd17 Cleanup: CMake formatting 2020-02-15 10:40:41 +11:00
Jacques Lucke
68cc982dcb BLI: improve various C++ data structures
The changes come from the `functions` branch, where I'm using
these structures a lot.

This also includes a new `BLI::Optional<T>` type, which is similar
to `std::Optional<T>` which can be used when Blender starts using
C++17.
2020-02-10 14:09:01 +01:00
Howard Trickey
7038a3a774 Disable some longer running tests from previous commit. 2020-01-28 09:52:45 -05:00
Howard Trickey
2867c35d4e Fix T73271, Delaunay Triangulation not robust enough.
A big rework of the code now uses exact predicates for orientation
and incircle. Also switched the main algorithm to use a faster
divide and conquer algorithm, which is possible with the exact
predicates.
2020-01-28 09:45:46 -05:00
1107af1abb Fix OBJECT_GUARDED_FREE compiler error when type is in namespace 2020-01-27 12:22:01 +01:00
Campbell Barton
cdebc8a9f6 Cleanup: include missing CMake headers 2020-01-25 20:15:35 +11:00
Alexander Gavrilov
79d9874028 Merge branch 'blender-v2.82-release' 2020-01-24 20:48:38 +03:00
Alexander Gavrilov
fc1f5bded4 Depsgraph: fix false positive time dependencies for simple drivers.
The dependency graph has to know whether a driver must be re-evaluated
every frame due to a dependency on the current frame number. For python
drivers it was using a heuristic based on searching for certain sub-
strings in the expression, notably including '('.

When the expression is actually evaluated using Python, this can't be
easily improved; however if the Simple Expression evaluator is used,
this check can be done precisely by accessing the parsed data.

Differential Revision: https://developer.blender.org/D6624
2020-01-24 20:48:02 +03:00
Sergey Sharybin
6fff73e3f0 Merge branch 'blender-v2.82-release' 2020-01-23 16:59:50 +01:00
Sergey Sharybin
517870a4a1 CMake: Refactor external dependencies handling
This is a more correct fix to the issue Brecht was fixing in D6600.

While the fix in that patch worked fine for linking it broke ASAN
runtime under some circumstances.
For example, `make full debug developer` would compile, but trying
to start blender will cause assert failure in ASAN (related on check
that ASAN is not running already).

Top-level idea: leave it to CMake to keep track of dependency graph.

The root of the issue comes to the fact that target like "blender" is
configured to use a lot of static libraries coming from Blender sources
and to use external static libraries. There is nothing which ensures
order between blender's and external libraries. Only order of blender
libraries is guaranteed.

It was possible that due to a cycle or other circumstances some of
blender libraries would have been passed to linker after libraries
it uses, causing linker errors.

For example, this order will likely fail:

  libbf_blenfont.a libfreetype6.a libbf_blenfont.a

This change makes it so blender libraries are explicitly provided
their dependencies to an external libraries, which allows CMake to
ensure they are always linked against them.

General rule here: if bf_foo depends on an external library it is
to be provided to LIBS for bf_foo.
For example, if bf_blenkernel depends on opensubdiv then LIBS in
blenkernel's CMakeLists.txt is to include OPENSUBDIB_LIBRARIES.

The change is made based on searching for used include folders
such as OPENSUBDIV_INCLUDE_DIRS and adding corresponding libraries
to LIBS ion that CMakeLists.txt. Transitive dependencies are not
simplified by this approach, but I am not aware of any downside of
this: CMake should be smart enough to simplify them on its side.
And even if not, this shouldn't affect linking time.

Benefit of not relying on transitive dependencies is that build
system is more robust towards future changes. For example, if
bf_intern_opensubiv is no longer depends on OPENSUBDIV_LIBRARIES
and all such code is moved to bf_blenkernel this will not break
linking.

The not-so-trivial part is change to blender_add_lib (and its
version in Cycles). The complexity is caused by libraries being
provided as a single list argument which doesn't allow to use
different release and debug libraries on Windows. The idea is:

- Have every library prefixed as "optimized" or "debug" if
  separation is needed (non-prefixed libraries will be considered
  "generic").

- Loop through libraries passed to function and do simple parsing
  which will look for "optimized" and "debug" words and specify
  following library to corresponding category.

This isn't something particularly great. Alternative would be to
use target_link_libraries() directly, which sounds like more code
but which is more explicit and allows to have more flexibility
and control comparing to wrapper approach.

Tested the following configurations on Linux, macOS and Windows:

- make full debug developer
- make full release developer
- make lite debug developer
- make lite release developer

NOTE: Linux libraries needs to be compiled with D6641 applied,
otherwise, depending on configuration, it's possible to run into
duplicated zlib symbols error.

Differential Revision: https://developer.blender.org/D6642
2020-01-23 16:59:18 +01:00
Jacques Lucke
9c9ea37770 Fix: Use a minimal alignment of 8 in MEM_lockfree_mallocN_aligned
`posix_memalign` requires the `alignment` to be at least `sizeof(void *)`.
Previously, `MEM_mallocN_aligned` would simply return `NULL` if a too small
`alignment` was used. This was an OS specific issue.

The solution is to use a minimal alignment of `8` for all aligned allocations.
The unit tests have been extended to test more possible alignments (some
of which were broken before).

Reviewers: brecht

Differential Revision: https://developer.blender.org/D6660
2020-01-23 14:21:48 +01:00
Sergey Sharybin
7fc7df1bd3 CMake: Fix linking of ffmpeg_test on macOS
Part of the issue was missing library path to png library.
Other part was missing iconv passed to linker.
2020-01-16 15:52:19 +01:00
473bcff5cb Fix linking error with ffmpeg_test on Linux
The exact reason is unclear, but we might as well link just the few libraries
that are actually needed for ffmpeg.
2020-01-15 11:42:20 +01:00
Ray Molenkamp
f8b34d5ca4 test: Add basic codec test for ffmpeg.
This add a basic sanity check that validates
the features we use from ffmpeg are actually
available

Differential Revision: https://developer.blender.org/D5999

Reviewed By: sybren
2020-01-14 11:31:02 -07:00
6bca11a847 Fix build error in tests on Clang / macOS 2020-01-08 17:21:40 +01:00
Julian Eisel
f52d9a878d Fix T72878: Alphabetical sorting in Outliner sorts shorter names last
E.g. "Cube" would be placed after "Cube.001", which is not what you'd
expect. 2.80 handled this correctly.

Loosely based on D6525 by @radcapricorn, but found a bug in that and
prefered to do some further adjustments.

Also activates test for this case.
2020-01-08 16:08:10 +01:00
Julian Eisel
525b0e0ccb Tests: Natural string comparing (BLI_strcasecmp_natural())
Adds tests covering a good amount of common cases and corner cases for
`BLI_strcasecmp_natural()`.
Could of course always add more tests for more cases, but don't want to
spend too much time on this.
2020-01-08 16:08:10 +01:00
Howard Trickey
a0892bb690 Fix crash in delaunay triangulation due to epsilon issues. 2019-12-21 12:23:02 -05:00
Campbell Barton
7d2d2ffa76 Cleanup: spelling 2019-12-17 16:30:39 +11:00
c4203ef17d USD: disabled unit test that fails on the buildbot
I can't fix this quickly right now, so I'd rather drop the entire test
for now.
2019-12-13 18:59:23 +01:00
e6c40bc9e1 USD: Simplified unit test and made it work on Windows as well 2019-12-13 18:59:23 +01:00
322555faa3 USD: Remove file created in unit test after the test is done
No functional changes in the USD exporter, just some cleanup code added
to the unit test.
2019-12-13 15:08:44 +01:00
ec62413f80 USD: Introducing a simple USD Exporter
This commit introduces the first version of an exporter to Pixar's
Universal Scene Description (USD) format.

Reviewed By: sergey, LazyDodo

Differential Revision: https://developer.blender.org/D6287

- The USD libraries are built by `make deps`, but not yet built by
  install_deps.sh.
- Only experimental support for instancing; by default all duplicated
  objects are made real in the USD file. This is fine for exporting a
  linked-in posed character, not so much for thousands of pebbles etc.
- The way materials and UV coordinates and Normals are exported is going
  to change soon.
- This patch contains LazyDodo's fixes for building on Windows in D5359.

== Meshes ==

USD seems to support neither per-material nor per-face-group
double-sidedness, so we just use the flag from the first non-empty
material slot. If there is no material we default to double-sidedness.

Each UV map is stored on the mesh in a separate primvar. Materials can
refer to these UV maps, but this is not yet exported by Blender. The
primvar name is the same as the UV Map name. This is to allow the
standard name "st" for texture coordinates by naming the UV Map as such,
without having to guess which UV Map is the "standard" one.

Face-varying mesh normals are written to USD. When the mesh has custom
loop normals those are written. Otherwise the poly flag `ME_SMOOTH` is
inspected to determine the normals.

The UV maps and mesh normals take up a significant amount of space, so
exporting them is optional. They're still enabled by default, though.
For comparison: a shot of Spring (03_035_A) is 1.2 GiB when exported
with UVs and normals, and 262 MiB without. We probably have room for
optimisation of written UVs and normals.

The mesh subdivision scheme isn't using the default value 'Catmull
Clark', but uses 'None', indicating we're exporting a polygonal mesh.
This is necessary for USD to understand our normals; otherwise the mesh
is always rendered smooth. In the future we may want to expose this
choice of subdivision scheme to the user, or auto-detect it when we
actually support exporting pre-subdivision meshes.

A possible optimisation could be to inspect whether all polygons are
smooth or flat, and mark the USD mesh as such. This can be added when
needed.

== Animation ==

Mesh and transform animation are now written when passing
`animation=True` to the export operator. There is no inspection of
whether an object is actually animated or not; USD can handle
deduplication of static values for us.

The administration of which timecode to use for the export is left to
the file-format-specific concrete subclasses of
`AbstractHierarchyIterator`; the abstract iterator itself doesn't know
anything about the passage of time. This will allow subclasses for the
frame-based USD format and time-based Alembic format.

== Support for simple preview materials ==

Very simple versions of the materials are now exported, using only the
viewport diffuse RGB, metallic, and roughness.

When there are multiple materials, the mesh faces are stored as geometry
subset and each material is assigned to the appropriate subset. If there
is only one material this is skipped.

The first material if any) is always applied to the mesh itself
(regardless of the existence of geometry subsets), because the Hydra
viewport doesn't support materials on subsets. See
https://github.com/PixarAnimationStudios/USD/issues/542 for more info.

Note that the geometry subsets are not yet time-sampled, so it may break
when an animated mesh changes topology.

Materials are exported as a flat list under a top-level '/_materials'
namespace. This inhibits instancing of the objects using those
materials, so this is subject to change.

== Hair ==

Only the parent strands are exported, and only with a constant colour.
No UV coordinates, no information about the normals.

== Camera ==

Only perspective cameras are supported for now.

== Particles ==

Particles are only written when they are alive, which means that they
are always visible (there is currently no code that deals with marking
them as invisible outside their lifespan).

Particle-system-instanced objects are exported by suffixing the object
name with the particle's persistent ID, giving each particle XForm a
unique name.

== Instancing/referencing ==

This exporter has experimental support for instancing/referencing.

Dupli-object meshes are now written to USD as references to the original
mesh. This is still very limited in correctness, as there are issues
referencing to materials from a referenced mesh.

I am still committing this, as it gives us a place to start when
continuing the quest for proper instancing in USD.

== Lights ==

USD does not directly support spot lights, so those aren't exported yet.
It's possible to add this in the future via the UsdLuxShapingAPI. The
units used for the light intensity are also still a bit of a mystery.

== Fluid vertex velocities ==

Currently only fluid simulations (not meshes in general) have explicit
vertex velocities. This is the most important case for exporting
velocities, though, as the baked mesh changes topology all the time, and
thus computing the velocities at import time in a post-processing step
is hard.

== The Building Process ==

- USD is built as monolithic library, instead of 25 smaller libraries.
  We were linking all of them as 'whole archive' anyway, so this doesn't
  affect the final file size. It does, however, make life easier with
  respect to linking order, and handling upstream changes.
- The JSON files required by USD are installed into datafiles/usd; they
  are required on every platform. Set the `PXR_PATH_DEBUG` to any value
  to have the USD library print the paths it uses to find those files.
- USD is patched so that it finds the aforementioned JSON files in a path
  that we pass to it from Blender.
- USD is patched to have a `PXR_BUILD_USD_TOOLS` CMake option to disable
  building the tools in its `bin` directory. This is sent as a pull
  request at https://github.com/PixarAnimationStudios/USD/pull/1048
2019-12-13 10:27:40 +01:00
Campbell Barton
dfb6af3011 Cleanup: extra semicolon, comma warnings 2019-12-10 12:01:58 +11:00
f445f72eca Tests: Blendfile-loading test class
This new test class minimally sets up Blender so that it can load blend
files and construct a depsgraph without crashing.

Note that it hasn't been tested on very complex blend files, so it may
still crash when the loaded blend file references/requires uninitialised
data structures.

The test will certainly crash with Blend files created with Blender
older than 2.80, as the versioning code requires space types to be
registered. This is normally done by initialising the window manager,
which is not done in this test. The WM requires Python to run, which in
turn requires that Blender finds the release directory in the same
directory that contains the running executable, which is not the case
for GTest tests (they are written to `bin/tests/executablename`.

Reviewed By: sergey, mont29

Differential Revision: https://developer.blender.org/D6246
2019-11-28 17:41:32 +01:00
Bastien Montagne
fcbec6e97e BLI_task: Add pooled threaded index range iterator, Take II.
This code allows to push a set of different operations all based on
iterations over a range of indices, and then process them all at once
over multiple threads.

This commit also adds unit tests for both old un-pooled, and new pooled
task_parallel_range family of functions, as well as some basic
performances tests.

This is mainly interesting for relatively low amount of individual
tasks, as expected.

E.g. performance tests on a 32 threads machine, for a set of 10
different tasks, shows following improvements when using pooled version
instead of ten sequential calls to BLI_task_parallel_range():

| Num Items | Sequential | Pooled  | Speed-up |
| --------- | ---------- | ------- | -------- |
|       10K |     365 us |  138 us |   2.5  x |
|      100K |     877 us |  530 us |   1.66 x |
|     1000K |    5521 us | 4625 us |   1.25 x |

Differential Revision: https://developer.blender.org/D6189

Note: Compared to previous commit yesterday, this reworks atomic handling in
parallel iter code, and fixes a dummy double-free bug.

Now we should only use the two critical values for synchronization from
atomic calls results, which is the proper way to do things.

Reading a value after an atomic operation does not guarantee you will
get the latest value in all cases (especially on Windows release builds
it seems).
2019-11-26 14:30:41 +01:00