diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2013-07-08 19:35:53 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2013-07-08 19:35:53 +0400 |
commit | 861f9e10f7ea9d1d38130ecbc983fe8f8dac93d0 (patch) | |
tree | ef12905a6b1f3628f7102f27e094ce64c04f7715 /source/blender/editors | |
parent | 27734f5bec7b717e82128e637c805b95e2b0f889 (diff) |
Attempt to fix #35057, disable threading if diameter of the brush
becomes too small. Typically this would happen if the number of buckets
is clipped to the maximum value. This avoids thread overhead.
A better fix might be to do bucket-brush intersection on main thread and
dispatch threads to process bucket hits as they become available. This
way only one thread at most would end up being used in such cases
anyway. A better task scheduler is needed for that though, leaving for
after GSOC.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 553a5cbe9ac..19953723fef 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -2820,6 +2820,8 @@ static void project_paint_begin(ProjPaintState *ps) const int diameter = 2 * BKE_brush_size_get(ps->scene, ps->brush); + bool reset_threads = false; + /* ---- end defines ---- */ if (ps->source == PROJ_SRC_VIEW) @@ -3064,6 +3066,10 @@ static void project_paint_begin(ProjPaintState *ps) /* printf("\tscreenspace bucket division x:%d y:%d\n", ps->buckets_x, ps->buckets_y); */ + if (ps->buckets_x > PROJ_BUCKET_RECT_MAX || ps->buckets_y > PROJ_BUCKET_RECT_MAX) { + reset_threads = true; + } + /* really high values could cause problems since it has to allocate a few * (ps->buckets_x*ps->buckets_y) sized arrays */ CLAMP(ps->buckets_x, PROJ_BUCKET_RECT_MIN, PROJ_BUCKET_RECT_MAX); @@ -3089,6 +3095,11 @@ static void project_paint_begin(ProjPaintState *ps) ps->thread_tot = BKE_scene_num_threads(ps->scene); + /* workaround for #35057, disable threading if diameter is less than is possible for + * optimum bucket number generation */ + if (reset_threads) + ps->thread_tot = 1; + for (a = 0; a < ps->thread_tot; a++) { ps->arena_mt[a] = BLI_memarena_new(1 << 16, "project paint arena"); } |