Commit Graph

55451 Commits

Author SHA1 Message Date
Bastien Montagne
3c1f3c02c6 Fix for Fix (c): broken atomic lock in own bmesh code.
That was a nasty one, Debug build would never have any issue (even tried
with 64 threads!), but Release build would deadlock nearly immediately,
even with only 2 threads!

What happened here (I think) is that gcc optimizer would generate a
specific path endlessly looping when initial value of virtual_lock was
FLT_MAX, by-passing re-assignment from v_no[0] and the atomic cas
completely. Which would have been correct, should v_no[0] not have been
shared (and modified) by multiple threads. ;)

Idea of that (broken) for loop was to avoid completely calling the
atomic cas as long as v_no[0] was locked by some other thread, but...
Guess the avoided/missing memory barrier was the root of the issue here.

Lesson of the evening: Remember kids, do not trust your compiler to
understand all possible threading-related side effects, and be explicit
rather than elegant when using atomic ops!

Side-effect lesson: do check both release and debug builds when messing
with said atomic ops...
2017-11-25 23:14:54 +01:00
Bastien Montagne
dd6c918b2c Fix broken atomic_cas lock in own recent commit in bmesh.
Using atomic cas correctly is really hairy... ;)

In this case, the returned value from cas needs to validate *two*
conditions, it must not be FLT_MAX (which is our 'locked' value and
would mean another thread has already locked it), but it also must be
equal to previously stored value...

This means we need two steps per loop here, hence using a 'for' loop
instead of a 'while' one now.

Note that collisions are (as expected) very rare, less than 1 for 10k
typically, so did not catch the issue initially (also because I was
mostly working with release build to check on performances...).
2017-11-25 20:28:12 +01:00
Sergey Sharybin
1caa267ee6 Depsgraph: Cleanup, indentation 2017-11-24 15:45:41 +01:00
Sergey Sharybin
5f7981243e Depsgraph: Allow finding operations after construction is done 2017-11-24 15:38:20 +01:00
Sergey Sharybin
a8b97b2e41 Depsgraph: Deduplicate operation node finding logic 2017-11-24 15:35:42 +01:00
Sergey Sharybin
d232363290 Depsgraph: Use proper return type for find_node method 2017-11-24 15:34:53 +01:00
Sergey Sharybin
d80c1e1e11 Depsgraph: Use get_ prefix for function which expect operation to exists 2017-11-24 15:32:29 +01:00
Sergey Sharybin
d8f33fc818 Depsgraph: Make has_ prefixed function to return boolean 2017-11-24 15:26:54 +01:00
Sergey Sharybin
93e8a045df Depsgraph: Introduce explicit method which finds operation or returns NULL 2017-11-24 15:24:33 +01:00
Sergey Sharybin
68654c0be5 Depsgraph: Make more clear what find_operation() is doing for component 2017-11-24 15:21:50 +01:00
Bastien Montagne
8db63c6a1c Cleanup leftover timing debug prints from own recent commits.
Sorry about that...
2017-11-24 10:43:29 +01:00
Campbell Barton
c62e3a05b0 Cleanup: -Wnonnull-compare GCC warning 2017-11-24 14:29:17 +11:00
Bastien Montagne
b63442e0b6 Minor cleanup for own recent commits. 2017-11-23 22:43:11 +01:00
Bastien Montagne
43ddf0e9a7 Getting rid of OMP: first usage of new parallel BMesh items iteration instead.
`BM_mesh_normals_update` was converted from OMP to new parallel iterator code,
basic test with heavily subdivided cube (24.5k faces) gives:
    - old OMP code: average 10ms per run.
    - new BLI_task code: average 6ms per run.

So new code seems to be easily 40% quicker, in addition to getting rid of OMP. ;)

Reviewers: sergey, campbellbarton

Differential Revision: https://developer.blender.org/D2930
2017-11-23 21:21:32 +01:00
Bastien Montagne
bc3f0cfd14 BMesh: add limited support for parallelization over some basic iterators.
This merely uses new memloop/task looper over vertex/edge/face mempools.

Quite obviously, only BM_VERTS/EDGES/FACES_OF_MESH iterators are
supported.
2017-11-23 21:19:54 +01:00
Bastien Montagne
efb86b712d Add a new parallel looper for MemPool items to BLI_task.
It merely uses the new thread-safe iterators system of mempool, quite
straight forward.

Note that to avoid possible confusion with two void pointers as
parameters of the callback, a dummy opaque struct pointer is used
instead for the second parameter (pointer generated by iteration over
mempool), callback functions must explicitely convert it to expected
real type.

Also added a basic gtest for this new feature.
2017-11-23 21:14:43 +01:00
Bastien Montagne
b84e6dfee4 Add ability to use more than one mempool iterator simultaneously.
This will allow threaded tasks to 'consume' all mempool items in
parallel tasks, each one working on a whole chunk at once (to reduce
concurrency managing overhead).
2017-11-23 21:12:00 +01:00
Bastien Montagne
d423e66d34 Add non-gcc variant of static assert macro.
Adapted from http://www.pixelbeat.org/programming/gcc/static_assert.html.

Note that this macro just discards error message, so error when building
is much less nice than with gcc's _Static_assert... But error log will
point to right place in code, so should still be OK.
2017-11-23 20:25:55 +01:00
Brecht Van Lommel
5e13097dc3 Fix T53145: bevel tool fails when used a second time.
Pixel size was not initial early enough. For first time this was not a problem
because the bevel amount starts at 0 then, and after the mouse moves the pixel
size is initialized. For the second time the bevel amount starts at a non-zero
value, and it failed then.
2017-11-23 20:17:31 +01:00
Brecht Van Lommel
56da112ae0 Fix T53360: crash with GLSL bump mapping and missing group output node. 2017-11-23 18:12:32 +01:00
Brecht Van Lommel
f218e6d4da Fix T53276: encoding output quality UI clarification. 2017-11-23 17:55:25 +01:00
Brecht Van Lommel
dd04f54e84 Fix inaccuracy when storing material ID pass in half float multilayer EXR.
These and other non-RGB passes should always be stored as full float, the
precision loss is too unpredictable.

Related to T53381, but that one is about file output nodes where we don't
know the type of data being saved currently.
2017-11-23 17:14:04 +01:00
Brecht Van Lommel
e50ed90e4d Fix T53348: Cycles difference between gradient texture on CPU and GPU. 2017-11-23 17:14:04 +01:00
Bastien Montagne
580b34e52b atomic_ops: add char versions of uint8_t atomic primitives. 2017-11-23 16:24:34 +01:00
Bastien Montagne
497e2b3dfa Cleanup: use signed atomic ops when needed. 2017-11-23 16:24:34 +01:00
Sergey Sharybin
75a87abdc9 Depsgraph: Cleanup, deduplicate code around component registration 2017-11-23 15:23:19 +01:00
Sergey Sharybin
f2842ac65e Depsgraph: Cleanup, split build_object() a bit 2017-11-23 12:01:31 +01:00
Sergey Sharybin
f3fa5c1258 Depsgraph: Cleanup, always call full object 2017-11-23 11:39:28 +01:00
Campbell Barton
434ed96dd2 Revert "BLI_utildefines: Support SWAP macro with two args"
This reverts commit d749320e3b.

It's possible the container struct is larger,
we could do sizeof checks that falls back to memmove
but rather avoid complicating things.
2017-11-23 15:21:50 +11:00
Campbell Barton
3bec70ca60 Use custom SWAP macro for swapping userdef data
Avoids complicating the common case
2017-11-23 15:18:22 +11:00
Campbell Barton
326efb4319 Fix T53274: Saving template prefs overwrites default prefs 2017-11-23 03:12:00 +11:00
Campbell Barton
d749320e3b BLI_utildefines: Support SWAP macro with two args 2017-11-23 03:11:48 +11:00
Campbell Barton
69b5165902 WM: minor correction to user-pref writing
When saving templates had wrong return value.
2017-11-22 17:11:03 +11:00
Bastien Montagne
5f4058ddbc Removing OMP: get rid of usages in /bmesh/ area.
Just removing it, such cases are not bottlenecks and not worth the
complication of doing real threading with own BLI_task.

Other (remaining) usages may be relevant, need case-by-case check.
2017-11-21 22:25:22 +01:00
Bastien Montagne
7770c2ef87 Removing OMP: get rid of last bit in /editors/ area.
Just removing it, such cases are not bottlenecks and not worth the
complication of doing real threading with own BLI_task.
2017-11-21 22:25:22 +01:00
Sergey Sharybin
6c372530b4 Cleanup: We do not use camel case in Blender code
At least not for variables.
2017-11-21 17:34:44 +01:00
Sergey Sharybin
6785a2bd66 Fix T53371: Keying Node fails with values above 1
This was expected behavior for over-exposured lamps when the mode was originally
created for Tears of Steel. Turns out, there could be really bad green screen in
real production which will only have green (or rather screen) channel over
exposured.

Tweaked condition now so we use least bright channel to see if the area has
proper exposure or not.

Seems to work fine in tests, but further tweaks are possible.
2017-11-21 17:31:45 +01:00
Campbell Barton
175e8fdc1e Disable adding scene sequence strips into themselves
D2923 by @spockTheGray w/ edits, see T52586 for details
2017-11-21 16:46:27 +11:00
Campbell Barton
a591bd203e Cleanup: redundant ELEM use 2017-11-21 16:15:19 +11:00
Brecht Van Lommel
96415cb52a Code cleanup: fix harmless compiler warning. 2017-11-20 23:32:06 +01:00
Bastien Montagne
f34e03d34d Fix (unreported) Crash: broken RNA accessors to tesselated MCol data.
Regression from rB823bcf1689a3 (VPaint 2017 GSoC, this is not in 2.79 release).

Also cleanup, using fake-array-ification to access struct members is
generally not a great idea, but when we already have a totally confusing
broken struct layout, this is pure evil, as demonstrated here!

Found while investigating T53341.
2017-11-20 10:16:50 +01:00
Campbell Barton
65af15ad88 UV Cube Project: improve default behavior
- initialize the cube-size from the bounding box when it's not set.
- no longer wrap faces to keep in 0-1 bounds,
  other projection methods don't do this and calculating the scale
  prevents the UV's from being too far outside the view.
2017-11-20 19:51:19 +11:00
Campbell Barton
ed3b7a5cd4 Fix T53342: Outliner 'select hierarchy' broken
Was using cursor position from within menu,
clicking on the same position for every selected item (toggling).

Now operate on each selected outliner element, without toggling.
2017-11-20 16:02:37 +11:00
Bastien Montagne
784614655f Fix T53343: Custom Normal Data Transfer Crashes when some vertexes have no faces.
Odd nobody noticed this earlier, was obvious bug in code logic here... :/

To be backported to 2.79a.
2017-11-19 20:43:59 +01:00
Campbell Barton
0a69e3b307 Option not to select with un-hide
D1518 from @mba105 w/ edits
2017-11-20 02:28:07 +11:00
Campbell Barton
92ea281017 Cleanup: remove BKE_utildefines
This was meant to be used for less general macros but was never used.

Rename BKE_BIT_TEST_SET to SET_FLAG_FROM_TEST
2017-11-20 01:47:31 +11:00
Joshua Leung
d2b03d2364 Fix: Undo pushes were missing for Add/Remove Driver Variable buttons, and Remove Driver button 2017-11-20 03:06:13 +13:00
Joshua Leung
2317fa6dcc Cleanup - Style 2017-11-20 02:56:40 +13:00
Joshua Leung
6f578740ef Fix T53300: Bone Extrude via Ctrl + Click is not done from active bone tail 2017-11-20 02:55:17 +13:00
Joshua Leung
e2585c2342 Fix compiler warning
--> render_result.c:832 - formal parameter 6 different from declaration
2017-11-20 02:08:55 +13:00