Page MenuHome
Paste P1208

Sculpt PBVH performance test
ActivePublic

Authored by Pablo Dobarro (pablodp606) on Jan 13 2020, 6:53 PM.
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 011c2a8b39a..b865d98e2f9 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -889,6 +889,17 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
col = flow.column()
col.prop(sculpt, "use_deform_only")
+ col = flow.column()
+ col.prop(sculpt, "grainsize", text="Grain Size")
+ col = flow.column()
+ col.prop(sculpt, "free_threads", text="Free threads")
+ col = flow.column()
+ col.prop(sculpt, "tbb_partitioner", text="Partitioner")
+
+ mesh = context.active_object.data
+ col = flow.column()
+ col.prop(mesh, "pbvh_leaf_limit")
+
class VIEW3D_PT_sculpt_options_gravity(Panel, View3DPaintPanel):
bl_context = ".sculpt_mode" # dot on purpose (access from topbar)
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 9eb10d296de..30b2ddbc297 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -25,6 +25,8 @@
#include "BLI_bitmap.h"
#include "BLI_ghash.h"
+#include "DNA_scene_types.h"
+
/* For embedding CCGKey in iterator. */
#include "BKE_ccg.h"
@@ -451,6 +453,9 @@ typedef void (*PBVHParallelReduceFunc)(const void *__restrict userdata,
void *__restrict chunk);
typedef struct PBVHParallelSettings {
+ int grainsize;
+ int free_threads;
+ PBVHTBBPartitioner partitioner;
bool use_threading;
void *userdata_chunk;
size_t userdata_chunk_size;
@@ -461,6 +466,10 @@ void BKE_pbvh_parallel_range_settings(struct PBVHParallelSettings *settings,
bool use_threading,
int totnode);
+void BKE_pbvh_sculpt_parallel_range_settings(struct PBVHParallelSettings *settings,
+ struct Sculpt *sd,
+ int totnode);
+
void BKE_pbvh_parallel_range(const int start,
const int stop,
void *userdata,
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 01612ded396..f8731658f2b 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -28,6 +28,7 @@
#include "BLI_task.h"
#include "DNA_mesh_types.h"
+#include "DNA_scene_types.h"
#include "DNA_meshdata_types.h"
#include "BKE_pbvh.h"
@@ -555,7 +556,7 @@ void BKE_pbvh_build_mesh(PBVH *bvh,
bvh->verts = verts;
bvh->vert_bitmap = BLI_BITMAP_NEW(totvert, "bvh->vert_bitmap");
bvh->totvert = totvert;
- bvh->leaf_limit = LEAF_LIMIT;
+ bvh->leaf_limit = max_ii(1, mesh->pbvh_leaf_limit);
bvh->vdata = vdata;
bvh->ldata = ldata;
@@ -2746,5 +2747,20 @@ void BKE_pbvh_parallel_range_settings(PBVHParallelSettings *settings,
int totnode)
{
memset(settings, 0, sizeof(*settings));
+ settings->partitioner = PBVHTBBPARTITIONER_AUTO;
settings->use_threading = use_threading && totnode > 1;
+ settings->grainsize = 1;
+}
+
+void BKE_pbvh_sculpt_parallel_range_settings(PBVHParallelSettings *settings,
+ Sculpt *sd,
+ int totnode)
+{
+
+ memset(settings, 0, sizeof(*settings));
+ settings->partitioner = PBVHTBBPARTITIONER_AUTO;
+ settings->use_threading = sd->flags & SCULPT_USE_OPENMP && totnode > 1;
+ settings->grainsize = sd->grainsize;
+ settings->free_threads = sd->free_threads;
+ settings->partitioner = sd->tbb_partitioner;
}
diff --git a/source/blender/blenkernel/intern/pbvh_parallel.cc b/source/blender/blenkernel/intern/pbvh_parallel.cc
index 2534fdea3ee..f25b2d58dcf 100644
--- a/source/blender/blenkernel/intern/pbvh_parallel.cc
+++ b/source/blender/blenkernel/intern/pbvh_parallel.cc
@@ -16,6 +16,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_math.h"
#include "BLI_task.h"
#include "BLI_threads.h"
@@ -123,14 +124,48 @@ void BKE_pbvh_parallel_range(const int start,
if (settings->use_threading) {
PBVHTask task(func, userdata, settings);
+ const int grainsize = max_ii(1, settings->grainsize);
+ int max_threads = tbb::task_scheduler_init::default_num_threads();
+ tbb::task_scheduler_init init(max_ii(1, max_threads - settings->free_threads));
+
if (settings->func_reduce) {
- parallel_reduce(tbb::blocked_range<int>(start, stop), task);
+ switch (settings->partitioner) {
+ case PBVHTBBPARTITIONER_AUTO:
+ parallel_reduce(tbb::blocked_range<int>(start, stop, grainsize), task);
+ break;
+ case PBVHTBBPARTITIONER_AFFINITY:
+ parallel_reduce(tbb::blocked_range<int>(start, stop, grainsize), task);
+ break;
+ case PBVHTBBPARTITIONER_SIMPLE:
+ parallel_reduce(
+ tbb::blocked_range<int>(start, stop, grainsize), task, tbb::simple_partitioner());
+ break;
+ case PBVHTBBPARTITIONER_STATIC:
+ parallel_reduce(
+ tbb::blocked_range<int>(start, stop, grainsize), task, tbb::static_partitioner());
+ break;
+ }
if (settings->userdata_chunk) {
memcpy(settings->userdata_chunk, task.userdata_chunk, settings->userdata_chunk_size);
}
}
else {
- parallel_for(tbb::blocked_range<int>(start, stop), task);
+ switch (settings->partitioner) {
+ case PBVHTBBPARTITIONER_AUTO:
+ parallel_for(tbb::blocked_range<int>(start, stop, grainsize), task);
+ break;
+ case PBVHTBBPARTITIONER_AFFINITY:
+ parallel_for(tbb::blocked_range<int>(start, stop, grainsize), task);
+ break;
+ case PBVHTBBPARTITIONER_SIMPLE:
+ parallel_for(
+ tbb::blocked_range<int>(start, stop, grainsize), task, tbb::simple_partitioner());
+ break;
+ case PBVHTBBPARTITIONER_STATIC:
+ parallel_for(
+ tbb::blocked_range<int>(start, stop, grainsize), task, tbb::static_partitioner());
+ break;
+ }
}
return;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index a9334edd39b..98091843b3a 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -473,7 +473,7 @@ static int sculpt_nearest_vertex_get(
nvtd.nearest_vertex_distance_squared = FLT_MAX;
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
settings.func_reduce = nearest_vertex_get_reduce;
settings.userdata_chunk = &nvtd;
settings.userdata_chunk_size = sizeof(NearestVertexTLSData);
@@ -1596,7 +1596,7 @@ static void calc_area_center(
AreaNormalCenterTLSData anctd = {{{0}}};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
settings.func_reduce = calc_area_normal_and_center_reduce;
settings.userdata_chunk = &anctd;
settings.userdata_chunk_size = sizeof(AreaNormalCenterTLSData);
@@ -1689,7 +1689,7 @@ static void calc_area_normal_and_center(
AreaNormalCenterTLSData anctd = {{{0}}};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
settings.func_reduce = calc_area_normal_and_center_reduce;
settings.userdata_chunk = &anctd;
settings.userdata_chunk_size = sizeof(AreaNormalCenterTLSData);
@@ -2724,7 +2724,7 @@ static void smooth(Sculpt *sd,
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
switch (type) {
case PBVH_GRIDS:
@@ -2763,7 +2763,7 @@ static void bmesh_topology_rake(
.strength = factor,
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_topology_rake_bmesh_task_cb_ex, &settings);
}
@@ -2825,7 +2825,7 @@ static void do_mask_brush_draw(Sculpt *sd, Object *ob, PBVHNode **nodes, int tot
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_mask_brush_draw_task_cb_ex, &settings);
}
@@ -2912,7 +2912,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_draw_brush_task_cb_ex, &settings);
}
@@ -2988,7 +2988,7 @@ static void do_draw_sharp_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_draw_sharp_brush_task_cb_ex, &settings);
}
@@ -3161,7 +3161,7 @@ static void do_topology_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totn
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
if (ss->cache->alt_smooth) {
for (int i = 0; i < 4; i++) {
BKE_pbvh_parallel_range(0, totnode, &data, do_topology_relax_task_cb_ex, &settings);
@@ -3286,7 +3286,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_crease_brush_task_cb_ex, &settings);
}
@@ -3348,7 +3348,7 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_pinch_brush_task_cb_ex, &settings);
}
@@ -3420,7 +3420,7 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_grab_brush_task_cb_ex, &settings);
}
@@ -3529,7 +3529,7 @@ static void do_elastic_deform_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_elastic_deform_brush_task_cb_ex, &settings);
}
@@ -3800,7 +3800,7 @@ static void do_pose_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_pose_brush_task_cb_ex, &settings);
}
@@ -3883,7 +3883,7 @@ static void sculpt_pose_grow_pose_factor(Sculpt *sd,
PoseGrowFactorTLSData gftd;
gftd.pos_count = 0;
zero_v3(gftd.pos_avg);
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
settings.func_reduce = pose_brush_grow_factor_reduce;
settings.userdata_chunk = &gftd;
settings.userdata_chunk_size = sizeof(PoseGrowFactorTLSData);
@@ -4206,7 +4206,7 @@ static void sculpt_pose_brush_init(Sculpt *sd, Object *ob, SculptSession *ss, Br
data.pose_factor = ss->cache->pose_ik_chain->segments[ik].weights;
for (int i = 0; i < br->pose_smooth_iterations; i++) {
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, pose_brush_init_task_cb_ex, &settings);
}
}
@@ -4277,7 +4277,7 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_nudge_brush_task_cb_ex, &settings);
}
@@ -4398,7 +4398,7 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_snake_hook_brush_task_cb_ex, &settings);
}
@@ -4470,7 +4470,7 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_thumb_brush_task_cb_ex, &settings);
}
@@ -4543,7 +4543,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_rotate_brush_task_cb_ex, &settings);
}
@@ -4640,7 +4640,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
BLI_mutex_init(&data.mutex);
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_layer_brush_task_cb_ex, &settings);
BLI_mutex_end(&data.mutex);
@@ -4708,7 +4708,7 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_inflate_brush_task_cb_ex, &settings);
}
@@ -4917,7 +4917,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_flatten_brush_task_cb_ex, &settings);
}
@@ -5104,7 +5104,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_clay_brush_task_cb_ex, &settings);
}
@@ -5439,7 +5439,7 @@ static void do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes,
plane_from_point_normal_v3(data.multiplane_scrape_planes[0], area_co, plane_no);
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_multiplane_scrape_brush_task_cb_ex, &settings);
}
@@ -5571,7 +5571,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_clay_strips_brush_task_cb_ex, &settings);
}
@@ -5664,7 +5664,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_fill_brush_task_cb_ex, &settings);
}
@@ -5756,7 +5756,7 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_scrape_brush_task_cb_ex, &settings);
}
@@ -5825,7 +5825,7 @@ static void do_gravity(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, fl
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, do_gravity_task_cb_ex, &settings);
}
@@ -5994,7 +5994,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &task_data, do_brush_action_task_cb, &settings);
if (sculpt_brush_needs_normal(ss, brush)) {
@@ -6232,7 +6232,7 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob)
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, sculpt_combine_proxies_task_cb, &settings);
}
@@ -6322,7 +6322,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob, bool is_proxy_use
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, sculpt_flush_stroke_deform_task_cb, &settings);
if (vertCos) {
@@ -9582,7 +9582,7 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op)
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
BKE_pbvh_parallel_range(0, totnode, &data, mask_filter_task_cb, &settings);
if (ELEM(filter_type, MASK_FILTER_GROW, MASK_FILTER_SHRINK)) {
@@ -9778,7 +9778,7 @@ static int sculpt_dirty_mask_exec(bContext *C, wmOperator *op)
};
PBVHParallelSettings settings;
- BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
+ BKE_pbvh_sculpt_parallel_range_settings(&settings, sd, totnode);
settings.func_reduce = dirty_mask_compute_range_reduce;
settings.userdata_chunk = &range;
diff --git a/source/blender/makesdna/DNA_mesh_defaults.h b/source/blender/makesdna/DNA_mesh_defaults.h
index f605827d120..694ae8617cb 100644
--- a/source/blender/makesdna/DNA_mesh_defaults.h
+++ b/source/blender/makesdna/DNA_mesh_defaults.h
@@ -35,6 +35,7 @@
.texflag = ME_AUTOSPACE, \
.remesh_voxel_size = 0.1f, \
.remesh_voxel_adaptivity = 0.0f, \
+ .pbvh_leaf_limit = 10000, \
.flag = ME_REMESH_FIX_POLES | ME_REMESH_REPROJECT_VOLUME, \
}
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index 86ea22690ee..69934bcddf7 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -195,8 +195,9 @@ typedef struct Mesh {
float remesh_voxel_size;
float remesh_voxel_adaptivity;
+ int pbvh_leaf_limit;
char remesh_mode;
- char _pad1[3];
+ char _pad1[7];
/** Deprecated multiresolution modeling data, only keep for loading old files. */
struct Multires *mr DNA_DEPRECATED;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 7cfd19b4bd9..b4f90e99b0b 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -959,6 +959,13 @@ typedef struct ParticleEditSettings {
/* ------------------------------------------- */
/* Sculpt */
+typedef enum PBVHTBBPartitioner {
+ PBVHTBBPARTITIONER_AUTO,
+ PBVHTBBPARTITIONER_AFFINITY,
+ PBVHTBBPARTITIONER_STATIC,
+ PBVHTBBPARTITIONER_SIMPLE,
+} PBVHTBBPartitioner;
+
/* Sculpt */
typedef struct Sculpt {
Paint paint;
@@ -984,7 +991,10 @@ typedef struct Sculpt {
/** Constant detail resolution (Blender unit / constant_detail). */
float constant_detail;
float detail_percent;
- char _pad[4];
+
+ int grainsize;
+ int free_threads;
+ int tbb_partitioner;
struct Object *gravity_object;
} Sculpt;
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 5e21fc883a9..2ddedccfadf 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -2984,6 +2984,13 @@ static void rna_def_mesh(BlenderRNA *brna)
rna_def_paint_mask(brna, prop);
/* End paint mask */
+ prop = RNA_def_property(srna, "pbvh_leaf_limit", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "pbvh_leaf_limit");
+ RNA_def_property_range(prop, 1, 1000000);
+ RNA_def_property_ui_range(prop, 1, 1000000, 1, 1000000);
+ RNA_def_property_ui_text(prop, "PBVH Leaf limit", "");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+
/* Remesh */
prop = RNA_def_property(srna, "remesh_voxel_size", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "remesh_voxel_size");
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 1457bbfd3c3..dead6ced43f 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -149,6 +149,14 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
{0, NULL, 0, NULL, NULL},
};
+const EnumPropertyItem rna_enum_pbvh_tbb_partitioner_items[] = {
+ {PBVHTBBPARTITIONER_AUTO, "AUTO", 0, "Auto", ""},
+ {PBVHTBBPARTITIONER_AFFINITY, "AFFINITY", 0, "Affinity", ""},
+ {PBVHTBBPARTITIONER_SIMPLE, "SIMPLE", 0, "Simple", ""},
+ {PBVHTBBPARTITIONER_STATIC, "STATIC", 0, "Static", ""},
+ {0, NULL, 0, NULL, NULL},
+};
+
#ifdef RNA_RUNTIME
# include "MEM_guardedalloc.h"
@@ -838,6 +846,20 @@ static void rna_def_sculpt(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update");
+ prop = RNA_def_property(srna, "grainsize", PROP_INT, PROP_NONE);
+ RNA_def_property_ui_range(prop, 1, 200, 1, 1);
+ RNA_def_property_ui_text(prop, "Grain Size", "");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+
+ prop = RNA_def_property(srna, "free_threads", PROP_INT, PROP_NONE);
+ RNA_def_property_ui_range(prop, 0, 64, 1, 1);
+ RNA_def_property_ui_text(prop, "Free Threads", "");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+
+ prop = RNA_def_property(srna, "tbb_partitioner", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, rna_enum_pbvh_tbb_partitioner_items);
+ RNA_def_property_ui_text(prop, "Partitioner", "");
+
prop = RNA_def_property(srna, "symmetrize_direction", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_symmetrize_direction_items);
RNA_def_property_ui_text(prop, "Direction", "Source and destination for symmetrize operator");