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:
authorBastien Montagne <montagne29@wanadoo.fr>2017-09-25 10:56:02 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2017-09-25 10:56:02 +0300
commit01a3c6b204bfbe149dc2cc2278dd58f206af7ae2 (patch)
treed997f65227966b031083bf50f60718513a6b0a36 /source/blender/blenkernel/intern/editderivedmesh.c
parentcb6f07f59e4045f4bc3d4c3f8e2bba681cc6bb79 (diff)
Tweak to fix for thread concurency in looptri generation.
Even if pointer assignment may be atomic, it does not prevent reordering and other nifty compiler tricks, we need a memory barrier to ensure not only that transferring pointer from wip array to final one is atomic, but also that all previous writing to memory are “flushed” to (visible by) all CPUs... Thanks @sergey for finding the potential (though quite unlikely) issue.
Diffstat (limited to 'source/blender/blenkernel/intern/editderivedmesh.c')
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index 9f688432988..357420179dd 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -41,6 +41,8 @@
* is likely to be a little slow.
*/
+#include "atomic_ops.h"
+
#include "BLI_math.h"
#include "BLI_jitter.h"
#include "BLI_bitmap.h"
@@ -662,7 +664,8 @@ static void emDM_recalcLoopTri(DerivedMesh *dm)
}
BLI_assert(dm->looptris.array == NULL);
- SWAP(MLoopTri *, dm->looptris.array, dm->looptris.array_wip);
+ atomic_cas_z((size_t *)&dm->looptris.array, *(size_t *)&dm->looptris.array, *(size_t *)&dm->looptris.array_wip);
+ dm->looptris.array_wip = NULL;
}
static void emDM_foreachMappedVert(