diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-03-01 23:46:58 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-03-02 00:05:50 +0400 |
commit | f01d19431d0e2a14a007d5480e805b99dc933169 (patch) | |
tree | 564d2c303ba3ff3413a8bc413ee133869ac1ba2b /source/blender/blenkernel/intern/smoke.c | |
parent | 3eabe064ab5401b9f0267c0a4a31379541084610 (diff) |
Fix T38873: Crashing on undo of ocean modifier.
Issue of this bug is that most part of fftw is not thread safe, only compute-intensive fftw_execute & co are.
Since smoke was affected by this issue as well, a global fftw mutex was added to BLI_threads.
Audaspace also uses fftw in one of its readers (AUD_BandPassReader.cpp),
but this is not an issue currently since this code is disabled in CMake/scons files.
There was another threading issue with smoke, we need to copy dm used by emit_from_derivedmesh(),
as it is modified by this func.
Reviewers: sergey, brecht
Reviewed By: brecht
CC: brecht
Differential Revision: https://developer.blender.org/D374
Diffstat (limited to 'source/blender/blenkernel/intern/smoke.c')
-rw-r--r-- | source/blender/blenkernel/intern/smoke.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 61d9ea99c2f..0ec277aeed6 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -207,7 +207,14 @@ void smoke_reallocate_highres_fluid(SmokeDomainSettings *sds, float dx, int res[ sds->wt = NULL; return; } + + /* smoke_turbulence_init uses non-threadsafe functions from fftw3 lib (like fftw_plan & co). */ + BLI_lock_thread(LOCK_FFTW); + sds->wt = smoke_turbulence_init(res, sds->amplify + 1, sds->noise, BLI_temporary_dir(), use_fire, use_colors); + + BLI_unlock_thread(LOCK_FFTW); + sds->res_wt[0] = res[0] * (sds->amplify + 1); sds->res_wt[1] = res[1] * (sds->amplify + 1); sds->res_wt[2] = res[2] * (sds->amplify + 1); @@ -1550,7 +1557,7 @@ static void emit_from_derivedmesh(Object *flow_ob, SmokeDomainSettings *sds, Smo { if (!sfs->dm) return; { - DerivedMesh *dm = sfs->dm; + DerivedMesh *dm; int defgrp_index = sfs->vgroup_density - 1; MDeformVert *dvert = NULL; MVert *mvert = NULL; @@ -1566,6 +1573,11 @@ static void emit_from_derivedmesh(Object *flow_ob, SmokeDomainSettings *sds, Smo int min[3], max[3], res[3]; int hires_multiplier = 1; + /* copy derivedmesh for thread safety because we modify it, + * main issue is its VertArray being modified, then replaced and freed + */ + dm = CDDM_copy(sfs->dm); + CDDM_calc_normals(dm); mvert = dm->getVertArray(dm); mvert_orig = dm->dupVertArray(dm); /* copy original mvert and restore when done */ |