Commit Graph

40594 Commits

Author SHA1 Message Date
Sergey Sharybin
9f7961b6b1 Optimization and threading fix for shapekeys weights calculation
This commit fixes two different issues, which were caused by
how weights are being calculated for relative shapekeys.

Weights for key block used to saved in KeyBlock DNA structure,
which lead to situations when different objects could start
writing to the same weights array if they're sharing the same
key datablock.

Solved this in a way so weights are never stored in KeyBlock
and being passed to shapekeys routines as an array of pointers.
This way weights are still computed run-time (meaning they're
calculated before shapekey evaluation and freed afterwards).

This required some changes to GameEngine as well, to make it
never cache weights in the key blocks.

Another aspect of this commit makes it so weight for a given
vertex group is only computed once. So if multiple key blocks
are using the same influence vertex group, they'll share the
same exact weights array. This gave around 1.7x speedup in
test chinchilla file which is close enough to if we've been
caching weights permanently in DNA (test machine is dual-code
4 threads laptop, speedup measured in depsgraph_mt branch,
trunk might be not so much high speedup).

Some further speed is optimization possible, but it could be
done later as well.

Thanks Brecht for idea of how the things might be solved in
really clear way.

--
svn merge -r58786:58787  ^/branches/soc-2013-depsgraph_mt
2013-08-19 10:36:39 +00:00
Sergey Sharybin
bec9bcc14c Added check for address being freed by mempool free
When blender is built in debug mode, BLI_mempool_free will
ensure address passed to the function actually belongs to
this pool.

--
svn merge -r58710:58711 ^/branches/soc-2013-depsgraph_mt
2013-08-19 10:18:25 +00:00
Sergey Sharybin
552d068565 Utility benchmarking macros
This new macros could be used to benchmark overall
execution time of some chunk of code, running in cycle.

The usage is:

  void foo(void) {
    TIMEIT_BLOCK_INIT(overall_bar);

    for (...) {
      ...

      TIMEIT_BLOCK_BEGIN(over_bar);
      bar();
      TIMEIT_BLOCK_END(oberall_bar);

      ...
    }

    TIMEIT_BLOCK_STATS(overall_bar)
  }


  This would print total time which was spent on
  running function bar().

--
svn merge -r58281:58283 ^/branches/soc-2013-depsgraph_mt
2013-08-19 10:16:23 +00:00
Sergey Sharybin
36ffc7accd Made armatures evaluation safe for threading
Apparently, some routines in armature deformation code
were using static arrays. This is probably just an
optimization thing, but it's very bad for threading.

Now made it so bbone matrices array is allocating in
callee function stack. This required exposing
MAX_BBONE_SUBDIV to an external API, This is not so
much crappy from code side, and it shall be the same
fast as before.

--
svn merge -r58278:58279 ^/branches/soc-2013-depsgraph_mt
2013-08-19 10:14:22 +00:00
Sergey Sharybin
c46cbc602e Make lattice deform safe for threading
Lattice deformation used to store some runtime data
inside of lattice datablock itself. It's something
which is REALLY bad. Ideally DNA shouldn't contain
and runtime data.

For now solved it in a way that initialization of
lattice deform will create a structure which contains
lattice object for which deformation is calculating
and that runtime data which used to be stored in
lattice datablock itself.

It works really fine for mesh deform modifier, but
there's still runtime data stored in particle system
DNA, It didn't look something easy to be solved, so
leaving this as-is for now.

--
svn merge -r58277:58278 -r58795:58796 ^/branches/soc-2013-depsgraph_mt
2013-08-19 10:11:48 +00:00
Sergey Sharybin
b9ae749480 Make GPU buffers allocation/freeing safe for threading
Code in GPU_buffers_free was already trying to be safe
for threading, by skipping OGL calls there, but in fact
it was still buggy.

Namely, freeing was doing buffers shift in a cycle, and
if two threads will call this function shifting will go
crazy.

Now made it so GPU_buffers_alloc and GPU_buffers_free
are using mutex lock, so they're completely safe for
threading. Same goes to gpu_buffer_setup function.

It required minor functions reshuffle, so there're no
locks happening from locked thread, but it's all very
straightforward change

--
svn merge -r58276:58277 ^/branches/soc-2013-depsgraph_mt
2013-08-19 10:06:05 +00:00
Sergey Sharybin
59dfb05c72 Make fonts safe(r) for threading
Getting vfont data wasn't safe for threading, because it
was modifying font data which is in bmain and could be
shared by multiple objects.

For now made it so getting vfont uses critical section,
meaning vfont->data is initializing from inside a locked
mutex.

--
svn merge -r58168:58169 ^/branches/soc-2013-depsgraph_mt
2013-08-19 10:02:18 +00:00
Campbell Barton
6bdff7e2ad fix [#36481] When "Rip Edge" cannot be completed, Blender crashes weirdly 2013-08-19 10:00:17 +00:00
Sergey Sharybin
f030758515 Tag object-data level boundbox as invalid rather than freeing it
Object update used to free object-data level bounding box to trigger
it's re-calculation in the future. Such a freeing performed from
object update isn't thread-safe because mesh could be shared between
multiple objects.

Rather than freeing bounding box, tag it's as invalid, this is safe
from threading point of view and also prevents unnecessary memory
re-allocation.

Object-level bounding box is still reallocating, but think we could
change this easily in the future as well.

--
svn merge -r58154:58156 -r59258:59259 ^/branches/soc-2013-depsgraph_mt
2013-08-19 09:58:28 +00:00
Sergey Sharybin
2dcb1d7002 Remove unused bounding box from MetaBall
--
svn merge -r58150:58151 ^/branches/soc-2013-depsgraph_mt
2013-08-19 09:41:13 +00:00
Sergey Sharybin
7ef3f98de1 Made curves almost thread-safe
Now modifier stack wouldn't modify original curve's nurbs
and will operate on a copy of nurbs.

This makes it possible to process curve object update with
shared curve datablocks from multiple threads. There's no
big overhead for creating a copy of nurbs comparing to old
behavior which was allocating original vertex array and
apply coordinates on curve after all modifier are applied.

The only remained issue with curves is curve's bounding box
and texture space. It's not thread-safe, but it wouldn't
lead to crashes -- it just could lead to either memory
leak or wrong texture coordinates due to difference in
modifiers stacks of objects which shares the same curve.

--
svn merge -r57959:57961 ^/branches/soc-2013-depsgraph_mt
2013-08-19 09:36:40 +00:00
Sergey Sharybin
345fff872b Remove unused argument from utility curve functions
So far it was harmless, but with upcoming changes having this
argument could be confusing from logic point of view

--
svn merge -r57958:57959 ^/branches/soc-2013-depsgraph_mt
2013-08-19 09:29:51 +00:00
Sergey Sharybin
527ddb0a5b Move bevel list and path from Curve to Object datablock
I know this is not so much nice to have this guys hanging
around in a general Object datablock and ideally they better
be wrapped around into a structure like DerivedMesh or
something like this. But this is pure runtime only stuff and
we could re-wrap them around later.

Main purpose of this is making curves more thread safe,
so no separate threads will ever start freeing the same path
or the same bevel list.

It also makes sense because path and bevel shall include
deformation coming from modifiers which are applying on
pre-tesselation point and different objects could have
different set of modifiers. This used to be really confusing
in the past and now data which depends on object is stored
in an object, making things clear for understanding even.

This doesn't make curve code fully thread-safe due to
pre-tesselation modifiers still modifies actual nurbs and
lock is still needed in makeDispListsCurveTypes, but this
change makes usage of paths safe for threading.

Once modifiers will stop modifying actual nurbs, curves
will be fully safe for threading.

Actually, this commit also contains wrapping runtime curve
members into own structure

This allows easier assignment on file loading, keeps curve-
specific runtime data grouped and saves couple of bytes in
Object for non-curve types.

--
svn merge -r57938:57939 ^/branches/soc-2013-depsgraph_mt
svn merge -r57957:57958^/branches/soc-2013-depsgraph_mt
2013-08-19 09:25:24 +00:00
Sergey Sharybin
0312b18319 Get rid of a display list stored in Curve datablock
This display list was only used for texture space calculation,
and even there this display list was only used for bounding
box calculation.

Since we already do have bounding box in a curve datablock
there's no reason to duplicate non-modified display list
just to calculate bounding box later, let's just calculate
bounding box at the first point.

This makes code a little be more thread-safe but curves are
still not safe for threads at all because of bevel list and
path. That would be solved later.

--
svn merge -r57939:57940 ^/branches/soc-2013-depsgraph_mt
2013-08-19 09:13:15 +00:00
Sergey Sharybin
2acf0a1354 Always use ob->bb when drawing the curve types
It used to be a check for ob->bb ? ob->bb : cu->bb but
in fact it doesn't make sense and only makes code more
crappy.

Making displist for mballs and curves/surfaces/fonts
already ensures object has walid bounding box.

--
svn merge -r57938:57939 ^/branches/soc-2013-depsgraph_mt
2013-08-19 09:07:09 +00:00
Sergey Sharybin
beffaa293e Made modifiers_getVirtualModifierList safe for threading
Move static variables to context filling in by this fcuntion
and owned by a callee function. This ensures no conflicts
between threads happens because of static variables used in
this function.

Also moved modifier types and virtual modifiers data to a
function called from creator. This is needed to be sure all
the information is properly initialied to the time when
threads starts to use this data.

--
svn merge -r57899:57900 ^/branches/soc-2013-depsgraph_mt
2013-08-19 09:05:34 +00:00
Sergey Sharybin
a14febc70a Fix issue with EWA filtering in compositor which disabled alpha
It was caused by wrong copy-paste thing, which replaced check
"whether alpha channel is enabled" with "whether alpha channel
is not zero" (which is always zero in accumulator).

Compositor always works with RGBA, so no need to do any special
checks here.

TODO: Maybe MapUV ode shall ignore alpha channel?
2013-08-19 08:30:03 +00:00
Sergey Sharybin
1dc19975c0 Fix warnings reported by cavity checker 2013-08-19 07:32:47 +00:00
Campbell Barton
f008a4c551 edit to object center snapping, exit early if unsupported. 2013-08-19 04:23:54 +00:00
Campbell Barton
43e9913ba3 add support for snapping to empty centers during transform. 2013-08-19 04:22:05 +00:00
Campbell Barton
47c23750e8 style cleanup: indent/whitespace 2013-08-19 01:48:44 +00:00
Campbell Barton
2060bb114a correct uninitialized var, worked by accident. 2013-08-19 00:39:28 +00:00
Antony Riakiotakis
d4fde84bbd Fix #34485 sculpt strength weirdly inverted with some mesh part.
The view vector was not being calculated correctly. Shamelessly rip off
correct transform to object space from projective texture painting code.
2013-08-18 22:44:43 +00:00
Sv. Lockal
49b0dbd3a3 Add comments for outliner's treestore and treehash (no functional changes) 2013-08-18 20:07:49 +00:00
Antony Riakiotakis
6fe983ddf5 Fix #34413 Dyntopo, smooth shading normals not getting uploaded to GPU
and undo buffers.

When we have smooth shading we must not only update the unique vertex
normals.
2013-08-18 19:47:33 +00:00
Campbell Barton
c5e14f62a6 bmesh improvements to face creation.
* fill-holes operator now takes advantage of new edge-net fill, works in many more cases then it did before.

* face-create that uses edge-net now initializes the normals based on surrounding geometry, only running normal calculation if there are no connected faces for a reference.
2013-08-18 15:14:55 +00:00
Campbell Barton
e2dc3313fe correct recent commit 2013-08-18 14:35:53 +00:00
Brecht Van Lommel
d43682d51b Cycles: Subsurface Scattering
New features:

* Bump mapping now works with SSS
* Texture Blur factor for SSS, see the documentation for details:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Shaders#Subsurface_Scattering

Work in progress for feedback:

Initial implementation of the "BSSRDF Importance Sampling" paper, which uses
a different importance sampling method. It gives better quality results in
many ways, with the availability of both Cubic and Gaussian falloff functions,
but also tends to be more noisy when using the progressive integrator and does
not give great results with some geometry. It works quite well for the
non-progressive integrator and is often less noisy there.

This code may still change a lot, so unless you're testing it may be best to
stick to the Compatible falloff function.

Skin test render and file that takes advantage of the gaussian falloff:
http://www.pasteall.org/pic/show.php?id=57661
http://www.pasteall.org/pic/show.php?id=57662
http://www.pasteall.org/blend/23501
2013-08-18 14:15:57 +00:00
Brecht Van Lommel
a2541508ac Fix a few compiler warnings reported by clang. 2013-08-18 14:15:51 +00:00
Campbell Barton
19d3e230e6 improved BM_face_copy_shared to copy from more possible connected loops and add filter function (not used yet). 2013-08-18 11:44:51 +00:00
Campbell Barton
fa3481cf07 correct own error in recent linked stack edits. 2013-08-18 04:06:49 +00:00
Campbell Barton
754b4ab3bc add hash function BLI_ghash_assign, BLI_edgehash_assign
avoids remove,insert and only hashes the key once.
2013-08-18 03:41:39 +00:00
Thomas Dinges
7cce556344 Code cleanup:
* Forgot to remove RNA/DNA in r59043. No need to keep this here, we never used it in Trunk.
2013-08-18 02:35:39 +00:00
Campbell Barton
ee2d95f850 minor api cleanup for ghash/edgehash
- use single inlined lookup function.
- move comments into source.
- pack iterator vars more efficiently.
2013-08-18 01:00:52 +00:00
Campbell Barton
fbb446dff6 add assert for hashes if an existing element is ever inserted into a ghash/edgehash.
the outliner does this intentionally, so add a flag to allow this situation optionally.
2013-08-18 00:36:04 +00:00
Campbell Barton
763bce4d64 bmesh api internal changes
- optimize BM_face_exists_overlap_subset(), dont check faces smaller then the vert array, don't initialize overlap flag unless its needed.
- BM_face_exists_overlap had incorrect check (currently function is unused so no harm done)
2013-08-17 13:32:56 +00:00
Campbell Barton
0b00ba4ee0 remove unused function 2013-08-17 13:08:09 +00:00
Sv. Lockal
95dc1d922b Fix [36486] Outliner doesn't allow to expand Hierarchies of armature if it's present on 2 Scenes
This is done by fixing logic for finding the first unused element in treehash.
The blend file from [36486] also exposes a memleak, but it should be addressed separately.
2013-08-17 11:49:18 +00:00
Campbell Barton
0f07ca6809 remove unused args from edgenet fill (since rewrite, but they weren't used before either) 2013-08-17 09:25:12 +00:00
Campbell Barton
5fafc222f0 style cleanup 2013-08-17 08:21:40 +00:00
Campbell Barton
85b0315b3b avoid double ghash lookups 2013-08-17 08:00:22 +00:00
Campbell Barton
1b11428101 fix for crash in compositor/opencl, the error value of -1001 would read past the error-string array. 2013-08-17 07:09:07 +00:00
Campbell Barton
d7cc2be2b7 add linklist stack macros, use where over allocating an array was previously done. 2013-08-17 05:33:55 +00:00
Campbell Barton
9d4bf6b37b change CHECK_TYPE_INLINE macro not to add the pointer in the macro. 2013-08-17 04:48:34 +00:00
Mitchell Stokes
82c845425f BGE: Adding partial support for LibLoaded lights with GLSL materials.
Any GLSL materials loaded after lights are LibLoaded will now use the lights in
heir shaders. This includes materials loaded from the same scene as the LibLoaded
lights. We could later add a new flag to LibLoad to recompile all existing shaders,
but this commit should offer a lot more flexibility as is.
2013-08-17 04:37:25 +00:00
Mitchell Stokes
51bca0d7dc BGE: Flipping vsync constants so VSYNC_ON is 0.
This will make transitions from older versions of Blender easier since VSYNC_ON
will be the default. This could have been changed in a do_version, but the vsync
code has yet to see an official release, so I figured this would be a bit nicer.
Also, this makes VSYNC_ON the default for new scenes as well.
2013-08-17 02:06:45 +00:00
Campbell Barton
ef8ea14f45 rewrite edgenet fill bmesh operator.
previous code created faces with mixed face-flipping and could get very slow,
test with ~60,000 edges here hung my system for over 2min (didnt wait for it to finish), new code executes in about 1 second.

new code doesn't attempt to flip faces correctly, its quite involved to do so, especially when the new faces are not created adjacent to eachother.
so simpler to calculate normals afterwards.
2013-08-16 14:18:54 +00:00
Sergey Sharybin
36c530dec9 Remove ifdef-ed code, it's still in SVn anyway. 2013-08-16 13:58:39 +00:00
Sergey Sharybin
a59777c33f Tweaks to MapUV and PlaneTrack nodes to make results less doggy
This disables crazy adaptive sampling happening in diagonal direction.

This still gives some doggyness, but it's much less dramatic now,
and behavior is pretty damn the same as EWA filtering when rendering
textures with Blender Internal.
2013-08-16 13:58:34 +00:00
Lukas Toenne
8d1c0b6f0f Fix for #36468, "Buffer Groups" option changes compositing output.
Problem is that the read/write buffer operations only work with actual
image inputs. If a singular value is used as group input no actual
buffer will be created, the write operation does not schedule any chunks
and the ReadBufferOperation subsequently returns zero
(MemoryBuffer::read).

The fix uses the (0,0) resolution to detect single value input of the
WriteBufferOperation. The actual resolution is then clamped to (1,1) to
ensure we have a single pixel to store the value in. A m_single_value
flag is also set, so we can reliably distinguish this from genuine image
resolutions without having to check m_width/m_height later on.

The ReadBufferOperation copies this flag from the associated
WriteBufferOperation and if set will always return the single value from
pixel (0,0).
2013-08-16 13:11:15 +00:00