[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58079] trunk/blender/source/blender/ editors/sculpt_paint/paint_image_proj.c: Attempt to fix #35057, disable threading if diameter of the brush

Antony Riakiotakis kalast at gmail.com
Mon Jul 8 17:35:54 CEST 2013


Revision: 58079
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58079
Author:   psy-fi
Date:     2013-07-08 15:35:53 +0000 (Mon, 08 Jul 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-07-08 13:56:34 UTC (rev 58078)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-07-08 15:35:53 UTC (rev 58079)
@@ -2820,6 +2820,8 @@
 
 	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 @@
 
 	/* 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 @@
 
 	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");
 	}




More information about the Bf-blender-cvs mailing list