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:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-05-18 11:53:48 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-05-18 14:40:52 +0300
commit61f9f508a4473e1d2bb353396717b4e1a085e646 (patch)
tree223ed7cac6193b55d923ec7e2ede44ebd026f0d0 /source/blender
parent8540907d6067eee8645f7f079c7fc103bd068573 (diff)
Make object material drivers evaluation thread safe
Previously it was very easy to run into situation when two objects are sharing the same materials with drivers which will cause threading access issues. This actually only needed for the old depsgraph, but since it's still the one we're using by default we'd better solve this issue.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/object_update.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 46d68e7ccab..d9373b9595a 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -37,6 +37,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_math.h"
+#include "BLI_threads.h"
#include "BKE_global.h"
#include "BKE_armature.h"
@@ -65,6 +66,8 @@
# define DEBUG_PRINT if (G.debug & G_DEBUG_DEPSGRAPH) printf
#endif
+static ThreadMutex material_lock = BLI_MUTEX_INITIALIZER;
+
void BKE_object_eval_local_transform(EvaluationContext *UNUSED(eval_ctx),
Scene *UNUSED(scene),
Object *ob)
@@ -239,12 +242,16 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
*/
if (ob->totcol) {
int a;
- for (a = 1; a <= ob->totcol; a++) {
- Material *ma = give_current_material(ob, a);
- if (ma) {
- /* recursively update drivers for this material */
- material_drivers_update(scene, ma, ctime);
+ if (ob->totcol != 0) {
+ BLI_mutex_lock(&material_lock);
+ for (a = 1; a <= ob->totcol; a++) {
+ Material *ma = give_current_material(ob, a);
+ if (ma) {
+ /* recursively update drivers for this material */
+ material_drivers_update(scene, ma, ctime);
+ }
}
+ BLI_mutex_unlock(&material_lock);
}
}
else if (ob->type == OB_LAMP)