Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-05-08 17:23:17 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-05-08 17:23:17 +0400
commita07dcd67ebf63fad08536b1e78bbb61e18fa51e6 (patch)
tree7c96f23349f005187e87d19d23248bb40d4d2e91 /source/blender/blenkernel/intern
parent3e763d7e4dbbc4acb3deb7afb95e936ce950ebb5 (diff)
Fix #35240: command line -t number of threads option did not work for cycles.
Now it works for blender internal, cycles and other multithreading code in Blender in both background and UI mode.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/particle_system.c7
-rw-r--r--source/blender/blenkernel/intern/scene.c26
-rw-r--r--source/blender/blenkernel/intern/softbody.c11
3 files changed, 30 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 74a50389cd5..a2ba09dd6af 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -1439,12 +1439,7 @@ ParticleThread *psys_threads_create(ParticleSimulationData *sim)
{
ParticleThread *threads;
ParticleThreadContext *ctx;
- int i, totthread;
-
- if (sim->scene->r.mode & R_FIXED_THREADS)
- totthread= sim->scene->r.threads;
- else
- totthread= BLI_system_thread_count();
+ int i, totthread = BKE_scene_num_threads(sim->scene);
threads= MEM_callocN(sizeof(ParticleThread)*totthread, "ParticleThread");
ctx= MEM_callocN(sizeof(ParticleThreadContext), "ParticleThreadContext");
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index c7a8c96a232..e93c32ddf64 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -56,6 +56,7 @@
#include "BLI_utildefines.h"
#include "BLI_callbacks.h"
#include "BLI_string.h"
+#include "BLI_threads.h"
#include "BLF_translation.h"
@@ -1469,3 +1470,28 @@ int BKE_scene_check_rigidbody_active(const Scene *scene)
{
return scene && scene->rigidbody_world && scene->rigidbody_world->group && !(scene->rigidbody_world->flag & RBW_FLAG_MUTED);
}
+
+int BKE_render_num_threads(const RenderData *rd)
+{
+ int threads;
+
+ /* override set from command line? */
+ threads = BLI_system_num_threads_override_get();
+
+ if (threads > 0)
+ return threads;
+
+ /* fixed number of threads specified in scene? */
+ if (rd->mode & R_FIXED_THREADS)
+ threads = rd->threads;
+ else
+ threads = BLI_system_thread_count();
+
+ return max_ii(threads, 1);
+}
+
+int BKE_scene_num_threads(const Scene *scene)
+{
+ return BKE_render_num_threads(&scene->r);
+}
+
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index d600b82522d..5011080234e 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -79,6 +79,7 @@ variables on the UI for now
#include "BKE_pointcache.h"
#include "BKE_deform.h"
#include "BKE_mesh.h"
+#include "BKE_scene.h"
#include "PIL_time.h"
// #include "ONL_opennl.h" remove linking to ONL for now
@@ -1664,10 +1665,7 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,
do_effector= pdInitEffectors(scene, ob, NULL, ob->soft->effector_weights);
/* figure the number of threads while preventing pretty pointless threading overhead */
- if (scene->r.mode & R_FIXED_THREADS)
- totthread= scene->r.threads;
- else
- totthread= BLI_system_thread_count();
+ totthread= BKE_scene_num_threads(scene);
/* what if we got zillions of CPUs running but less to spread*/
while ((totsprings/totthread < lowsprings) && (totthread > 1)) {
totthread--;
@@ -2395,10 +2393,7 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t
int lowpoints =100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
/* figure the number of threads while preventing pretty pointless threading overhead */
- if (scene->r.mode & R_FIXED_THREADS)
- totthread= scene->r.threads;
- else
- totthread= BLI_system_thread_count();
+ totthread= BKE_scene_num_threads(scene);
/* what if we got zillions of CPUs running but less to spread*/
while ((totpoint/totthread < lowpoints) && (totthread > 1)) {
totthread--;