[Bf-blender-cvs] [b1c01e3] new-filebrowser-preview-temp: On second thought, add a new API func to create a 'background' task pool.

Bastien Montagne noreply at git.blender.org
Sun Oct 18 15:20:07 CEST 2015


Commit: b1c01e35223cf7e6449559eb53f262956094512f
Author: Bastien Montagne
Date:   Sun Oct 18 15:04:38 2015 +0200
Branches: new-filebrowser-preview-temp
https://developer.blender.org/rBb1c01e35223cf7e6449559eb53f262956094512f

On second thought, add a new API func to create a 'background' task pool.

Will make the patch less verbose since it avoids changing existing code.

===================================================================

M	source/blender/blenkernel/intern/mesh_evaluate.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_distribute.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenlib/BLI_task.h
M	source/blender/blenlib/intern/task.c
M	source/blender/depsgraph/intern/depsgraph_eval.cc
M	source/blender/editors/armature/editarmature_retarget.c
M	source/blender/editors/mask/mask_draw.c
M	source/blender/editors/space_clip/clip_editor.c
M	source/blender/editors/space_clip/clip_ops.c
M	source/blender/editors/space_file/filelist.c
M	source/blender/imbuf/intern/imageprocess.c
M	source/blender/render/intern/source/volume_precache.c
M	source/gameengine/Ketsji/KX_Scene.cpp

===================================================================

diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 0537790..a65ac51 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -1309,7 +1309,7 @@ void BKE_mesh_normals_loop_split(
 		common_data.task_queue = BLI_thread_queue_init();
 
 		task_scheduler = BLI_task_scheduler_get();
-		task_pool = BLI_task_pool_create(task_scheduler, NULL, false);
+		task_pool = BLI_task_pool_create(task_scheduler, NULL);
 
 		nbr_workers = max_ii(2, BLI_task_scheduler_num_threads(task_scheduler));
 		for (i = 1; i < nbr_workers; i++) {
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index cfa3644..9aacba8 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -2358,7 +2358,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd
 		return;
 	
 	task_scheduler = BLI_task_scheduler_get();
-	task_pool = BLI_task_pool_create(task_scheduler, &ctx, false);
+	task_pool = BLI_task_pool_create(task_scheduler, &ctx);
 	totchild = ctx.totchild;
 	totparent = ctx.totparent;
 	
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index b0601be..87bc355 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -1118,7 +1118,7 @@ static void distribute_particles_on_dm(ParticleSimulationData *sim, int from)
 		return;
 	
 	task_scheduler = BLI_task_scheduler_get();
-	task_pool = BLI_task_pool_create(task_scheduler, &ctx, false);
+	task_pool = BLI_task_pool_create(task_scheduler, &ctx);
 	
 	totpart = (from == PART_FROM_CHILD ? sim->psys->totchild : sim->psys->totpart);
 	psys_tasks_create(&ctx, 0, totpart, &tasks, &numtasks);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index a6a9ab9..1ccc213 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1650,7 +1650,7 @@ static void scene_update_objects(EvaluationContext *eval_ctx, Main *bmain, Scene
 	state.has_mballs = false;
 #endif
 
-	task_pool = BLI_task_pool_create(task_scheduler, &state, false);
+	task_pool = BLI_task_pool_create(task_scheduler, &state);
 	if (G.debug & G_DEBUG_DEPSGRAPH_NO_THREADS) {
 		BLI_pool_set_num_threads(task_pool, 1);
 	}
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h
index 5f901ce..81c277c 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -76,7 +76,8 @@ typedef struct TaskPool TaskPool;
 typedef void (*TaskRunFunction)(TaskPool *__restrict pool, void *taskdata, int threadid);
 typedef void (*TaskFreeFunction)(TaskPool *__restrict pool, void *taskdata, int threadid);
 
-TaskPool *BLI_task_pool_create(TaskScheduler *scheduler, void *userdata, const bool is_background);
+TaskPool *BLI_task_pool_create(TaskScheduler *scheduler, void *userdata);
+TaskPool *BLI_task_pool_create_background(TaskScheduler *scheduler, void *userdata);
 void BLI_task_pool_free(TaskPool *pool);
 
 void BLI_task_pool_push_ex(
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index 1bb3a01..8850ef0 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -357,7 +357,7 @@ static void task_scheduler_clear(TaskScheduler *scheduler, TaskPool *pool)
 
 /* Task Pool */
 
-TaskPool *BLI_task_pool_create(TaskScheduler *scheduler, void *userdata, const bool is_background)
+static TaskPool *task_pool_create_ex(TaskScheduler *scheduler, void *userdata, const bool is_background)
 {
 	TaskPool *pool = MEM_callocN(sizeof(TaskPool), "TaskPool");
 
@@ -385,6 +385,27 @@ TaskPool *BLI_task_pool_create(TaskScheduler *scheduler, void *userdata, const b
 	return pool;
 }
 
+/**
+ * Create a normal task pool.
+ * This means that in mono-threaded context, it will not be executed at all until you call
+ * \a BLI_task_pool_work_and_wait() on it.
+ */
+TaskPool *BLI_task_pool_create(TaskScheduler *scheduler, void *userdata)
+{
+	return task_pool_create_ex(scheduler, userdata, false);
+}
+
+/**
+ * Create a background task pool.
+ * In multi-threaded context, there is no differences with \a BLI_task_pool_create(), but in mono-threaded case
+ * it is assured to have at least one worker thread to run on (i.e. you do not have to call
+ * \a BLI_task_pool_work_and_wait() on it to be sure it will be processed).
+ */
+TaskPool *BLI_task_pool_create_background(TaskScheduler *scheduler, void *userdata)
+{
+	return task_pool_create_ex(scheduler, userdata, true);
+}
+
 void BLI_task_pool_free(TaskPool *pool)
 {
 	BLI_task_pool_stop(pool);
@@ -626,7 +647,7 @@ void BLI_task_parallel_range_ex(
 	}
 
 	task_scheduler = BLI_task_scheduler_get();
-	task_pool = BLI_task_pool_create(task_scheduler, &state, false);
+	task_pool = BLI_task_pool_create(task_scheduler, &state);
 	num_threads = BLI_task_scheduler_num_threads(task_scheduler);
 
 	/* The idea here is to prevent creating task for each of the loop iterations
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc
index ada9d6f..e806576 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cc
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cc
@@ -323,7 +323,7 @@ void DEG_evaluate_on_refresh_ex(EvaluationContext *eval_ctx,
 	state.layers = layers;
 
 	TaskScheduler *task_scheduler = BLI_task_scheduler_get();
-	TaskPool *task_pool = BLI_task_pool_create(task_scheduler, &state, false);
+	TaskPool *task_pool = BLI_task_pool_create(task_scheduler, &state);
 
 	if (G.debug & G_DEBUG_DEPSGRAPH_NO_THREADS) {
 		BLI_pool_set_num_threads(task_pool, 1);
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
index cf1901a..2235f9f 100644
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ b/source/blender/editors/armature/editarmature_retarget.c
@@ -288,7 +288,7 @@ static RigGraph *newRigGraph(void)
 #endif
 
 	rg->task_scheduler = BLI_task_scheduler_create(totthread);
-	rg->task_pool = BLI_task_pool_create(rg->task_scheduler, NULL, false);
+	rg->task_pool = BLI_task_pool_create(rg->task_scheduler, NULL);
 
 	return rg;
 }
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index fd40fbb..2efa9e2 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -715,7 +715,7 @@ static float *threaded_mask_rasterize(Mask *mask, const int width, const int hei
 	state.width = width;
 	state.height = height;
 
-	task_pool = BLI_task_pool_create(task_scheduler, &state, false);
+	task_pool = BLI_task_pool_create(task_scheduler, &state);
 
 	scanlines_per_thread = height / num_threads;
 	for (i = 0; i < num_threads; i++) {
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index b2827f8..dbedfaa 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -845,7 +845,7 @@ static void start_prefetch_threads(MovieClip *clip, int start_frame, int current
 	queue.do_update = do_update;
 	queue.progress = progress;
 
-	task_pool = BLI_task_pool_create(task_scheduler, &queue, false);
+	task_pool = BLI_task_pool_create(task_scheduler, &queue);
 	for (i = 0; i < tot_thread; i++) {
 		BLI_task_pool_push(task_pool,
 		                   prefetch_task_func,
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index d91b975..af3d460 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -1233,7 +1233,7 @@ static void do_sequence_proxy(void *pjv, int *build_sizes, int build_count,
 	queue.do_update = do_update;
 	queue.progress = progress;
 
-	task_pool = BLI_task_pool_create(task_scheduler, &queue, false);
+	task_pool = BLI_task_pool_create(task_scheduler, &queue);
 	handles = MEM_callocN(sizeof(ProxyThread) * tot_thread,
 	                      "proxy threaded handles");
 	for (i = 0; i < tot_thread; i++) {
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 256d42f..0357692 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1113,7 +1113,7 @@ static void filelist_cache_preview_ensure_running(FileListEntryCache *cache)
 	if (!cache->previews_pool) {
 		TaskScheduler *scheduler = BLI_task_scheduler_get();
 
-		cache->previews_pool = BLI_task_pool_create(scheduler, cache, true);
+		cache->previews_pool = BLI_task_pool_create_background(scheduler, cache);
 		cache->previews_done = BLI_thread_queue_init();
 
 		IMB_thumb_locks_acquire();
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index ea5df9f..d44f0dc 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -344,7 +344,7 @@ void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_
 	int total_tasks = (buffer_lines + lines_per_task - 1) / lines_per_task;
 	int i, start_line;
 
-	task_pool = BLI_task_pool_create(task_scheduler, do_thread, false);
+	task_pool = BLI_task_pool_create(task_scheduler, do_thread);
 
 	handles = MEM_callocN(handle_size * total_tasks, "processor apply threaded handles");
 
diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c
index c88e612..78ede01 100644
--- a/source/blender/render/intern/source/volume_precache.c
+++ b/source/blender/render/intern/source/volume_precache.c
@@ -618,7 +618,7 @@ static void precache_launch_parts(Render *re, RayObject *tree, ShadeInput *shi,
 	state.lasttime = PIL_check_seconds_timer();
 	
 	task_scheduler = BLI_task_scheduler_create(totthread);
-	task_pool = BLI_task_pool_create(task_scheduler, &state, false);
+	task_pool = 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list