diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2020-11-23 18:26:54 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2020-11-25 22:31:47 +0300 |
commit | 02a0f6b04a648b62150a310e67628efc1c0773e8 (patch) | |
tree | c28a8cd2636c2b8d6c9aaec444af62f238ba0b04 /source/blender/blenlib/intern | |
parent | 8330e19cb2e7faca9884e34a8f46564250c8c29a (diff) |
Fluid Particles: fix viscoelastic spring threading crash again after D7394.
Since D6133 fluid particle code uses thread local storage to collect
springs created during a time step before adding them to the actual
spring array.
Prior to the switch to TBB there was a single finalize callback which
was called on the main thread, so it could use psys_sph_flush_springs
and insert the new entries into the final buffer. However in D7394 it
was replaced with a reduce callback, which is supposed to be thread
safe and have no side effects. This means that the only thing it can
safely do is copy entries to the other temporary buffer.
In addition, careful checking reveals that the 'classical' solver
doesn't actually add springs, so reduce isn't needed there.
Differential Revision: https://developer.blender.org/D9632
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/buffer.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/buffer.c b/source/blender/blenlib/intern/buffer.c index bac4786a2e9..74e97d89430 100644 --- a/source/blender/blenlib/intern/buffer.c +++ b/source/blender/blenlib/intern/buffer.c @@ -114,6 +114,16 @@ void BLI_buffer_reinit(BLI_Buffer *buffer, const size_t new_count) buffer->count = new_count; } +/* Callers use BLI_buffer_append_array. */ +void _bli_buffer_append_array(BLI_Buffer *buffer, void *new_data, size_t count) +{ + size_t size = buffer->count; + BLI_buffer_resize(buffer, size + count); + + uint8_t *bytes = (uint8_t *)buffer->data; + memcpy(bytes + size * buffer->elem_size, new_data, count * buffer->elem_size); +} + /* callers use BLI_buffer_free */ void _bli_buffer_free(BLI_Buffer *buffer) { |