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/ocean.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/ocean.c')
-rw-r--r-- | source/blender/blenkernel/intern/ocean.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index c1e43365a84..3458f149aa2 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -846,6 +846,8 @@ void BKE_init_ocean(struct Ocean *o, int M, int N, float Lx, float Lz, float V, o->_fft_in = (fftw_complex *)MEM_mallocN(o->_M * (1 + o->_N / 2) * sizeof(fftw_complex), "ocean_fft_in"); o->_htilda = (fftw_complex *)MEM_mallocN(o->_M * (1 + o->_N / 2) * sizeof(fftw_complex), "ocean_htilda"); + BLI_lock_thread(LOCK_FFTW); + if (o->_do_disp_y) { o->_disp_y = (double *)MEM_mallocN(o->_M * o->_N * sizeof(double), "ocean_disp_y"); o->_disp_y_plan = fftw_plan_dft_c2r_2d(o->_M, o->_N, o->_fft_in, o->_disp_y, FFTW_ESTIMATE); @@ -890,6 +892,8 @@ void BKE_init_ocean(struct Ocean *o, int M, int N, float Lx, float Lz, float V, o->_Jxz_plan = fftw_plan_dft_c2r_2d(o->_M, o->_N, o->_fft_in_jxz, o->_Jxz, FFTW_ESTIMATE); } + BLI_unlock_thread(LOCK_FFTW); + BLI_rw_mutex_unlock(&o->oceanmutex); set_height_normalize_factor(o); @@ -903,6 +907,8 @@ void BKE_free_ocean_data(struct Ocean *oc) BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_WRITE); + BLI_lock_thread(LOCK_FFTW); + if (oc->_do_disp_y) { fftw_destroy_plan(oc->_disp_y_plan); MEM_freeN(oc->_disp_y); @@ -939,6 +945,8 @@ void BKE_free_ocean_data(struct Ocean *oc) MEM_freeN(oc->_Jxz); } + BLI_unlock_thread(LOCK_FFTW); + if (oc->_fft_in) MEM_freeN(oc->_fft_in); |