Point density: Workaround for possible race condition
authorSergey Sharybin <sergey.vfx@gmail.com>
Sat, 18 Jul 2015 20:57:02 +0000 (22:57 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sat, 18 Jul 2015 20:57:02 +0000 (22:57 +0200)
There was possible race condition in the point density sampling caused
by access to the same data in particle system from sampling thread and
sampling initialization.

Could have happened when two different point density textures were using
same particle system

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

index d2ec5d80c9164778abb3b5857a2a4ae396cf27c2..165a1bbb687d58b7f697343ad3a860e33b47f865 100644 (file)
@@ -687,8 +687,6 @@ void RE_sample_point_density(Scene *scene, PointDensity *pd,
 
        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) {
                        for (x = 0; x < resolution; ++x) {
@@ -711,4 +709,5 @@ void RE_sample_point_density(Scene *scene, PointDensity *pd,
                }
        }
        free_pointdensity(pd);
+       BLI_mutex_unlock(&sample_mutex);
 }