[Bf-blender-cvs] [5f631ca7c85] sculpt-dev: sculpt-dev: started work on new customdata backend for BMesh for profiling purposes
Joseph Eagar
noreply at git.blender.org
Thu Feb 24 05:59:34 CET 2022
Commit: 5f631ca7c85e5e44f5582c45504947ea7633d751
Author: Joseph Eagar
Date: Tue Feb 1 20:14:27 2022 -0800
Branches: sculpt-dev
https://developer.blender.org/rB5f631ca7c85e5e44f5582c45504947ea7633d751
sculpt-dev: started work on new customdata
backend for BMesh for profiling
purposes
* Purpose is to test the performance of
block vs page vs array CustomData allocation.
* Code is as simple as possible.
* Patches existing BMesh CustomData API.
* Not intended for master.
===================================================================
M source/blender/blenkernel/BKE_customdata.h
M source/blender/blenkernel/BKE_pbvh.h
M source/blender/blenkernel/intern/brush_engine.c
M source/blender/blenkernel/intern/customdata.cc
M source/blender/blenkernel/intern/pbvh.c
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/bmesh/CMakeLists.txt
M source/blender/bmesh/bmesh_class.h
M source/blender/bmesh/intern/bmesh_construct.c
M source/blender/bmesh/intern/bmesh_core.c
A source/blender/bmesh/intern/bmesh_data_attr.cc
A source/blender/bmesh/intern/bmesh_data_attr.h
M source/blender/bmesh/intern/bmesh_mesh.c
M source/blender/bmesh/intern/bmesh_mesh_convert.cc
M source/blender/editors/sculpt_paint/sculpt_face_set.c
M source/blender/makesdna/DNA_customdata_types.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 8b7c3ca5054..a09d808a56a 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -793,6 +793,16 @@ void CustomData_bmesh_asan_poison(const CustomData *data, void *block);
void CustomData_bmesh_asan_unpoison(const CustomData *data, void *block);
int CustomData_get_named_offset(const CustomData *data, int type, const char *name);
+void CustomData_setDefaultData(CustomDataType type, void *block, int totelem);
+size_t CustomData_getTypeSize(CustomDataType type);
+void CustomData_freeData(CustomDataType type, void *block, int totelem);
+void CustomData_interpData(CustomDataType type,
+ void *block,
+ int tot,
+ const void **srcs,
+ const float *ws,
+ const float *sub_ws);
+
#ifndef NDEBUG
struct DynStr;
/** Use to inspect mesh data when debugging. */
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index c0f40ac4180..70de1b7d9e0 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -353,9 +353,7 @@ void BKE_pbvh_update_sculpt_verts(struct BMesh *bm,
/** update original data, only data whose r_** parameters are passed in will be updated*/
void BKE_pbvh_bmesh_update_origvert(
- PBVH *pbvh, struct BMVert *v, float **r_co, float **r_no, float **r_color, bool log_undo);
-void BKE_pbvh_update_origcolor_bmesh(PBVH *pbvh, PBVHNode *node);
-void BKE_pbvh_update_origco_bmesh(PBVH *pbvh, PBVHNode *node);
+ PBVH *pbvh, struct BMVert *v, float **r_co, float **r_no, float **r_color);
/**
checks if original data needs to be updated for v, and if so updates it. Stroke_id
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index c8559dd94dd..a26572b519d 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -102,7 +102,7 @@ struct CurveMappingCache *brush_curve_cache = NULL;
extern BrushChannelType brush_builtin_channels[];
extern int brush_builtin_channel_len;
-static bool brush_mapping_inherits(BrushChannel *ch, BrushMapping *mp)
+static bool brush_mapping_inherits(const BrushChannel *ch, const BrushMapping *mp)
{
switch (mp->inherit_mode) {
case BRUSH_MAPPING_INHERIT_NEVER:
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index 89ac0ee66ce..abc467572e3 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -3939,6 +3939,7 @@ void CustomData_bmesh_do_versions_update_active_layers(CustomData *fdata, Custom
}
}
+#ifndef USE_BMESH_PAGE_CUSTOMDATA
void CustomData_bmesh_init_pool(CustomData *data, int totelem, const char htype)
{
CustomData_bmesh_init_pool_ex(data, totelem, htype, __func__);
@@ -3978,6 +3979,7 @@ void CustomData_bmesh_init_pool_ex(CustomData *data,
data->pool = BLI_mempool_create_ex(data->totsize, totelem, chunksize, BLI_MEMPOOL_NOP, memtag);
}
}
+#endif
bool CustomData_bmesh_merge(const CustomData *source,
CustomData *dest,
@@ -4122,6 +4124,7 @@ void CustomData_bmesh_free_block_data(CustomData *data, void *block)
CustomData_bmesh_asan_poison(data, block);
}
+#ifndef USE_BMESH_PAGE_CUSTOMDATA
static void CustomData_bmesh_alloc_block(CustomData *data, void **block)
{
if (*block) {
@@ -4149,6 +4152,7 @@ static void CustomData_bmesh_alloc_block(CustomData *data, void **block)
*block = nullptr;
}
}
+#endif
void CustomData_bmesh_free_block_data_exclude_by_type(CustomData *data,
void *block,
@@ -4176,6 +4180,7 @@ void CustomData_bmesh_free_block_data_exclude_by_type(CustomData *data,
CustomData_bmesh_asan_poison(data, block);
}
+#ifndef USE_BMESH_PAGE_CUSTOMDATA
static void CustomData_bmesh_set_default_n(CustomData *data, void **block, int n)
{
if (ELEM(data->layers[n].type, CD_TOOLFLAGS, CD_MESH_ID)) {
@@ -4204,6 +4209,7 @@ void CustomData_bmesh_set_default(CustomData *data, void **block)
CustomData_bmesh_set_default_n(data, block, i);
}
}
+#endif
void CustomData_bmesh_swap_data_simple(CustomData *data, void **block1, void **block2)
{
@@ -4663,6 +4669,7 @@ void CustomData_bmesh_interp_n(CustomData *data,
typeInfo->interp(src_blocks_ofs, weights, sub_weights, count, dst_block_ofs);
}
+#ifndef USE_BMESH_PAGE_CUSTOMDATA
void CustomData_bmesh_interp(CustomData *data,
const void **src_blocks,
const float *weights,
@@ -4845,6 +4852,8 @@ void CustomData_from_bmesh_block(const CustomData *source,
}
}
}
+#endif
+
void CustomData_file_write_info(int type, const char **r_struct_name, int *r_struct_num)
{
@@ -5857,6 +5866,64 @@ void CustomData_blend_read(BlendDataReader *reader, CustomData *data, int count)
CustomData_regen_active_refs(data); // check for corrupted active layer refs
}
+size_t CustomData_getTypeSize(CustomDataType type)
+{
+ const LayerTypeInfo *info = layerType_getInfo(type);
+
+ return info ? info->size : 0ULL;
+}
+
+void CustomData_setDefaultData(CustomDataType type, void *block, int totelem)
+{
+ const LayerTypeInfo *info = layerType_getInfo(type);
+
+ if (info->set_default) {
+ info->set_default(block, totelem);
+ }
+ else {
+ memset(block, 0, info->size * totelem);
+ }
+}
+
+void CustomData_freeData(CustomDataType type, void *block, int totelem)
+{
+ const LayerTypeInfo *info = layerType_getInfo(type);
+
+ if (info->free) {
+ info->free(block, totelem, info->size);
+ }
+}
+
+#include "BLI_alloca.h"
+
+void CustomData_interpData(CustomDataType type,
+ void *block,
+ int tot,
+ const void **srcs,
+ const float *ws,
+ const float *sub_ws)
+{
+ const LayerTypeInfo *info = layerType_getInfo(type);
+
+ if (!info->interp) {
+ return;
+ }
+
+ if (!ws) {
+ float *ws2 = static_cast<float *>(BLI_array_alloca(ws2, tot));
+ float w = 1.0f / (float)tot;
+
+ for (int i = 0; i < tot; i++) {
+ ws2[i] = w;
+ }
+
+ info->interp(srcs, ws2, sub_ws, 1, block);
+ }
+ else {
+ info->interp(srcs, ws, sub_ws, 1, block);
+ }
+}
+
#ifndef NDEBUG
void CustomData_debug_info_from_layers(const CustomData *data, const char *indent, DynStr *dynstr)
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index d8dc5fe0a50..ce6183a7205 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1796,44 +1796,6 @@ static int pbvh_flush_bb(PBVH *pbvh, PBVHNode *node, int flag)
return update;
}
-void BKE_pbvh_update_origcolor_bmesh(PBVH *pbvh, PBVHNode *node)
-{
- PBVHVertexIter vd;
-
- if (!pbvh->bm || pbvh->vcol_type == -1) {
- return;
- }
-
- if (pbvh->vcol_type == -1) {
- return;
- }
-
- BKE_pbvh_vertex_iter_begin (pbvh, node, vd, PBVH_ITER_UNIQUE) {
- MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, vd.bm_vert);
-
- BKE_pbvh_bmesh_get_vcol(
- vd.bm_vert, mv->origcolor, pbvh->vcol_type, pbvh->vcol_domain, pbvh->cd_vcol_offset);
- }
- BKE_pbvh_vertex_iter_end;
-}
-
-void BKE_pbvh_update_origco_bmesh(PBVH *pbvh, PBVHNode *node)
-{
- PBVHVertexIter vd;
-
- if (!pbvh->bm || pbvh->cd_sculpt_vert < 0) {
- return;
- }
-
- BKE_pbvh_vertex_iter_begin (pbvh, node, vd, PBVH_ITER_UNIQUE) {
- MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, vd.bm_vert);
-
- copy_v3_v3(mv->origco, vd.bm_vert->co);
- copy_v3_v3(mv->origno, vd.bm_vert->no);
- }
- BKE_pbvh_vertex_iter_end;
-}
-
void BKE_pbvh_update_bounds(PBVH *pbvh, int flag)
{
if (!pbvh->nodes) {
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 6f57d1d415a..495b0f0d795 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -943,16 +943,10 @@ void BKE_pbvh_bmesh_get_vcol(
}
void BKE_pbvh_bmesh_update_origvert(
- PBVH *pbvh, BMVert *v, float **r_co, float **r_no, float **r_color, bool log_undo)
+ PBVH *pbvh, BMVert *v, float **r_co, float **r_no, float **r_color)
{
MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
- if (log_undo) {
- bm_logstack_push();
- BM_log_vert_before_modified(pbvh->bm_log, v, pbvh->cd_vert_mask_offset, r_color != NULL);
- bm_logstack_pop();
- }
-
if (pbvh->cd_vert_mask_offset) {
mv->origmask = (short)(BM_ELEM_CD_GET_FLOAT(v, pbvh->cd_vert_mask_offset) * 65535.0f);
}
@@ -995,7 +989,7 @@ bool BKE_pbvh_bmesh_check_origdata(PBVH *pbvh, BMVert *v, int stroke_id)
if (mv->stroke_id != stroke_id) {
float *dummy;
- BKE_pbvh_bmesh_update_origvert(pbvh, v, &dummy, &dummy, &dummy, false);
+ BKE_pbvh_bmesh_update_origvert(pbvh, v, &dummy, &dummy, &dummy);
mv->stroke_id = stroke_id;
return true;
}
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index e738e9f43e0..2c0fd90a592 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -82,6 +82,8 @@ set(SRC
intern/bmesh_construct.h
intern/bmesh_core.c
intern/bmesh_core.h
+ intern/bmesh_data_attr.h
+ intern/bmesh_data_attr.cc
intern/bmesh_delete.c
intern/bmesh_delete.h
intern/bmesh_edgeloop.c
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index fae428a6787..c494c28f3f5 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -401,6 +401,10 @@ typedef struct BMesh {
int map_size;
int cd_id_off[15];
} idmap;
+
+#ifdef USE_BMESH_PAGE_CUSTOMDATA
+ struct BMeshAttrList *attr_list;
+#endif
} BMesh;
enum {
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_const
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list