[Bf-blender-cvs] [6da9fa1bf2c] temp_bmesh_multires: pre-valgrind commit
Joseph Eagar
noreply at git.blender.org
Mon Oct 26 04:06:51 CET 2020
Commit: 6da9fa1bf2ccb7e14505fce8430211884654c635
Author: Joseph Eagar
Date: Sun Oct 25 20:00:42 2020 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB6da9fa1bf2ccb7e14505fce8430211884654c635
pre-valgrind commit
===================================================================
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/BKE_pbvh.h
M source/blender/blenkernel/intern/paint.c
M source/blender/blenkernel/intern/pbvh.c
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/blenlib/intern/BLI_mempool.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/gpu/intern/gpu_buffers.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 20af2f1ae0e..fe3235bfe5d 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -478,6 +478,7 @@ typedef struct SculptSession {
struct BMesh *bm;
int cd_vert_node_offset;
int cd_face_node_offset;
+ int cd_vcol_offset;
bool bm_smooth_shading;
/* Undo/redo log for dynamic topology sculpting */
struct BMLog *bm_log;
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 44c3d595988..fd68a63f5b5 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -22,8 +22,8 @@
*/
#include "BLI_bitmap.h"
-#include "BLI_ghash.h"
#include "BLI_compiler_compat.h"
+#include "BLI_ghash.h"
/* For embedding CCGKey in iterator. */
#include "BKE_ccg.h"
@@ -33,7 +33,9 @@
extern "C" {
#endif
-typedef struct {int64_t i;} SculptVertRef;
+typedef struct {
+ int64_t i;
+} SculptVertRef;
BLI_INLINE SculptVertRef BKE_pbvh_make_vref(intptr_t i)
{
@@ -211,6 +213,11 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
const int cd_face_node_offset,
const int cd_origco_offset,
const int cd_origno_offset);
+void BKE_pbvh_update_offsets(PBVH *pbvh,
+ const int cd_vert_node_offset,
+ const int cd_face_node_offset,
+ const int cd_origco_offset,
+ const int cd_origno_offset);
void BKE_pbvh_free(PBVH *pbvh);
/* Hierarchical Search in the BVH, two methods:
@@ -455,6 +462,7 @@ typedef struct PBVHVertexIter {
struct CustomData *bm_vdata;
int cd_vert_mask_offset;
+ int cd_vcol_offset;
/* result: these are all computed in the macro, but we assume
* that compiler optimization's will skip the ones we don't use */
@@ -496,7 +504,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
vi.mask = vi.key.has_mask ? CCG_elem_mask(&vi.key, vi.grid) : NULL; \
vi.grid = CCG_elem_next(&vi.key, vi.grid); \
vi.index++; \
- vi.vertex.i++;\
+ vi.vertex.i++; \
vi.visible = true; \
if (vi.gh) { \
if (BLI_BITMAP_TEST(vi.gh, vi.gy * vi.gridsize + vi.gx)) { \
@@ -547,8 +555,12 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
if (!bv) { \
continue; \
} \
- vi.bm_vert = bv;\
- vi.vertex.i = (intptr_t)bv;\
+ vi.bm_vert = bv; \
+ if (vi.cd_vcol_offset >= 0) { \
+ MPropCol *vcol = BM_ELEM_CD_GET_VOID_P(bv, vi.cd_vcol_offset); \
+ vi.col = vcol->color; \
+ } \
+ vi.vertex.i = (intptr_t)bv; \
vi.index = BM_elem_index_get(vi.bm_vert); \
vi.visible = !BM_elem_flag_test_bool(vi.bm_vert, BM_ELEM_HIDDEN); \
if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \
@@ -569,7 +581,6 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
(BKE_pbvh_type(pbvh) == PBVH_BMESH && v.i != -1 ? BM_elem_index_get((BMVert *)(v.i)) : (v.i))
SculptVertRef BKE_pbvh_table_index_to_vertex(PBVH *pbvh, int idx);
-
void BKE_pbvh_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count);
void BKE_pbvh_node_free_proxies(PBVHNode *node);
PBVHProxyNode *BKE_pbvh_node_add_proxy(PBVH *pbvh, PBVHNode *node);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index c0b83591ce9..33a49bb159f 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -2068,6 +2068,8 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob)
if (subdiv_ccg != NULL) {
BKE_sculpt_bvh_update_from_ccg(pbvh, subdiv_ccg);
}
+ } else if (BKE_pbvh_type(pbvh) == PBVH_BMESH) {
+ SCULPT_dynamic_topology_sync_layers(ob);
}
return pbvh;
}
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index a7770af97be..0124564173a 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -2939,6 +2939,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
vi->grid = NULL;
vi->no = NULL;
+ vi->col = NULL;
vi->fno = NULL;
vi->mvert = NULL;
vi->vertex.i = 0;
@@ -2976,6 +2977,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
vi->bm_other_verts = node->bm_other_verts;
vi->bm_vdata = &pbvh->bm->vdata;
vi->bm_vert = NULL;
+ vi->cd_vcol_offset = CustomData_get_offset(vi->bm_vdata, CD_PROP_COLOR);
vi->cd_vert_mask_offset = CustomData_get_offset(vi->bm_vdata, CD_PAINT_MASK);
}
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 4a605374a1a..7cc9246cb9a 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -3136,3 +3136,16 @@ static void pbvh_bmesh_verify(PBVH *pbvh)
}
#endif
+
+void BKE_pbvh_update_offsets(PBVH *pbvh,
+ const int cd_vert_node_offset,
+ const int cd_face_node_offset,
+ const int cd_origco_offset,
+ const int cd_origno_offset)
+{
+ pbvh->cd_face_node_offset = cd_face_node_offset;
+ pbvh->cd_vert_node_offset = cd_vert_node_offset;
+ pbvh->cd_vert_mask_offset = CustomData_get_offset(&pbvh->bm->vdata, CD_PAINT_MASK);
+ pbvh->cd_origco_offset = cd_origco_offset;
+ pbvh->cd_origno_offset = cd_origno_offset;
+}
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index e5868abbe2c..798c0f5b644 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -37,6 +37,7 @@
#include "BLI_utildefines.h"
#include "BLI_mempool.h" /* own include */
+#include "BLI_asan.h"
#include "MEM_guardedalloc.h"
@@ -223,13 +224,18 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool,
while (j--) {
curnode->next = NODE_STEP_NEXT(curnode);
curnode->freeword = FREEWORD;
- curnode = curnode->next;
+
+ BLI_freenode *next = curnode->next;
+ //BLI_asan_poison(curnode, pool->esize);
+ curnode = next;
}
}
else {
while (j--) {
curnode->next = NODE_STEP_NEXT(curnode);
- curnode = curnode->next;
+ BLI_freenode *next = curnode->next;
+ //BLI_asan_poison(curnode, pool->esize);
+ curnode = next;
}
}
@@ -250,18 +256,20 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool,
return curnode;
}
-static void mempool_chunk_free(BLI_mempool_chunk *mpchunk)
+static void mempool_chunk_free(BLI_mempool *pool, BLI_mempool_chunk *mpchunk)
{
+ //BLI_asan_unpoison(mpchunk, sizeof(BLI_mempool_chunk) + pool->esize*pool->csize);
+
MEM_freeN(mpchunk);
}
-static void mempool_chunk_free_all(BLI_mempool_chunk *mpchunk)
+static void mempool_chunk_free_all(BLI_mempool *pool, BLI_mempool_chunk *mpchunk)
{
BLI_mempool_chunk *mpchunk_next;
for (; mpchunk; mpchunk = mpchunk_next) {
mpchunk_next = mpchunk->next;
- mempool_chunk_free(mpchunk);
+ mempool_chunk_free(pool, mpchunk);
}
}
@@ -343,6 +351,8 @@ void *BLI_mempool_alloc(BLI_mempool *pool)
free_pop = pool->free;
+ //BLI_asan_unpoison(free_pop, pool->esize);
+
BLI_assert(pool->chunk_tail->next == NULL);
if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) {
@@ -404,7 +414,9 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
newhead->freeword = FREEWORD;
}
+
newhead->next = pool->free;
+
pool->free = newhead;
pool->totused--;
@@ -421,7 +433,7 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
BLI_mempool_chunk *first;
first = pool->chunks;
- mempool_chunk_free_all(first->next);
+ mempool_chunk_free_all(pool, first->next);
first->next = NULL;
pool->chunk_tail = first;
@@ -439,15 +451,20 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
j = pool->pchunk;
while (j--) {
- curnode->next = NODE_STEP_NEXT(curnode);
- curnode = curnode->next;
+ BLI_freenode *next ; NODE_STEP_NEXT(curnode);
+ curnode->next = next;
+ //BLI_asan_poison(curnode, pool->esize);
+ curnode = next;
}
curnode = NODE_STEP_PREV(curnode);
curnode->next = NULL; /* terminate the list */
+ // BLI_asan_poison(newhead, pool->esize);
#ifdef WITH_MEM_VALGRIND
VALGRIND_MEMPOOL_FREE(pool, CHUNK_DATA(first));
#endif
+ } else {
+ //BLI_asan_poison(newhead, pool->esize);
}
}
@@ -722,7 +739,7 @@ void BLI_mempool_clear_ex(BLI_mempool *pool, const int totelem_reserve)
do {
mpchunk_next = mpchunk->next;
- mempool_chunk_free(mpchunk);
+ mempool_chunk_free(pool, mpchunk);
} while ((mpchunk = mpchunk_next));
}
@@ -756,7 +773,7 @@ void BLI_mempool_clear(BLI_mempool *pool)
*/
void BLI_mempool_destroy(BLI_mempool *pool)
{
- mempool_chunk_free_all(pool->chunks);
+ mempool_chunk_free_all(pool, pool->chunks);
#ifdef WITH_MEM_VALGRIND
VALGRIND_DESTROY_MEMPOOL(pool);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 49ed3513dc0..3ae53c52068 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -166,6 +166,12 @@ const float *SCULPT_vertex_color_get(SculptSession *ss, SculptVertRef index)
break;
case PBVH_BMESH: {
BMVert *v = (BMVert *)index.i;
+
+ if (ss->cd_vcol_offset >= 0) {
+ MPropCol *col = BM_ELEM_CD_GET_VOID_P(v, ss->cd_vcol_offset);
+ return col->color;
+ }
+
break;
}
case PBVH_GRIDS:
@@ -348,7 +354,7 @@ void SCULPT_vertex_visible_set(SculptSession *ss, SculptVertRef index, bool visi
ss->mvert[index.i].flag |= ME_VERT_PBVH_UPDATE;
break;
case PBVH_BMESH:
- BM_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list