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
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-10-26 11:06:19 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-11-09 13:44:43 +0300
commitdca32f2b4f290bcf8c110c21d2cdecc04d390934 (patch)
tree903724013134314afa083259b5f9a69de292774a /source/blender/blenlib/BLI_buffer.h
parent6f1237b2ebda5c55414851d5c227fb819c3bc75b (diff)
Fluid Particles: fix threading crash with viscoelastic springs.
As correctly pointed out by a comment in the code, adding new springs wasn't thread safe, and caused crashes. Fix by buffering new springs in intermediate thread-local arrays, which are flushed on the main thread. This is valid because the new springs are not used until the next sim step. Differential Revision: https://developer.blender.org/D6133
Diffstat (limited to 'source/blender/blenlib/BLI_buffer.h')
-rw-r--r--source/blender/blenlib/BLI_buffer.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_buffer.h b/source/blender/blenlib/BLI_buffer.h
index 6fe1e9bb693..22d21262712 100644
--- a/source/blender/blenlib/BLI_buffer.h
+++ b/source/blender/blenlib/BLI_buffer.h
@@ -83,4 +83,14 @@ void _bli_buffer_free(BLI_Buffer *buffer);
} \
(void)0
+/* A buffer embedded in a struct. Using memcpy is allowed until first resize. */
+#define BLI_buffer_field_init(name_, type_) \
+ { \
+ memset(name_, 0, sizeof(*name_)); \
+ *(size_t *)&((name_)->elem_size) = sizeof(type_); \
+ } \
+ (void)0
+
+#define BLI_buffer_field_free(name_) _bli_buffer_free(name_)
+
#endif /* __BLI_BUFFER_H__ */