[Bf-blender-cvs] [2c7365aec7d] master: Fix unnecessary use of atomics in PBVH normal update
Brecht Van Lommel
noreply at git.blender.org
Sat Sep 28 12:30:41 CEST 2019
Commit: 2c7365aec7d8fc4b8b1ab748887d43e8076d899f
Author: Brecht Van Lommel
Date: Sat Sep 28 03:29:16 2019 +0200
Branches: master
https://developer.blender.org/rB2c7365aec7d8fc4b8b1ab748887d43e8076d899f
Fix unnecessary use of atomics in PBVH normal update
===================================================================
M source/blender/blenkernel/intern/pbvh.c
===================================================================
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 636a5c62e4d..c17c28fa110 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1059,11 +1059,12 @@ static void pbvh_update_normals_store_task_cb(void *__restrict userdata,
const int v = verts[i];
MVert *mvert = &bvh->verts[v];
- /* mvert is shared between nodes, hence between threads. */
- if (atomic_fetch_and_and_char(&mvert->flag, (char)~ME_VERT_PBVH_UPDATE) &
- ME_VERT_PBVH_UPDATE) {
+ /* No atomics necessary because we are iterating over uniq_verts only,
+ * so we know only this thread will handle this vertex. */
+ if (mvert->flag & ME_VERT_PBVH_UPDATE) {
normalize_v3(vnors[v]);
normal_float_to_short_v3(mvert->no, vnors[v]);
+ mvert->flag &= ~ME_VERT_PBVH_UPDATE;
}
}
More information about the Bf-blender-cvs
mailing list