[Bf-blender-cvs] [de04736] cycles_point_density: Cycles point density: Avoid race condition when using same object as texture source

Sergey Sharybin noreply at git.blender.org
Mon Apr 6 19:22:39 CEST 2015


Commit: de0473644bf1f1e4730d68a3f37aedaf6b4b9028
Author: Sergey Sharybin
Date:   Mon Apr 6 22:18:55 2015 +0500
Branches: cycles_point_density
https://developer.blender.org/rBde0473644bf1f1e4730d68a3f37aedaf6b4b9028

Cycles point density: Avoid race condition when using same object as texture source

If the same object is used by two point density textures in Particle source mode
it was really easy to catch a crash in derived render creation.

For now solved with mutex lock around cache_pointdensity_ex() which is not ideal
but seems to be better compromise comparing to other alternatives.

===================================================================

M	source/blender/render/intern/source/pointdensity.c

===================================================================

diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index 5cd8a73..14b9c8b 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -67,6 +67,7 @@
 extern struct Render R;
 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
 
+static ThreadMutex sample_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static int point_data_used(PointDensity *pd)
 {
@@ -720,7 +721,10 @@ void RE_sample_point_density(Scene *scene, PointDensity *pd,
 
 	/* Same matricies/resolution as dupli_render_particle_set(). */
 	unit_m4(mat);
+
+	BLI_mutex_lock(&sample_mutex);
 	cache_pointdensity_ex(scene, pd, mat, mat, 1, 1);
+	BLI_mutex_unlock(&sample_mutex);
 
 	for (z = 0; z < resolution; ++z) {
 		for (y = 0; y < resolution; ++y) {




More information about the Bf-blender-cvs mailing list