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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-02-20 01:23:21 +0300
committerCampbell Barton <ideasman42@gmail.com>2008-02-20 01:23:21 +0300
commit82d769c79f5e18b5b33030c188e3b2b93f9a346b (patch)
tree688cf07fed8e67cdc247bc0c8f23042a56761e0f /source
parent190a35f690b1048a32547a4cb0de369e3f7dde4b (diff)
automatic threads, next to the Threads button, so you can set threads to use whatever the system has, useful in the studio with 2,4,8 core systems when sharing files.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/BLI_threads.h1
-rw-r--r--source/blender/blenlib/intern/threads.c13
-rw-r--r--source/blender/makesdna/DNA_scene_types.h5
-rw-r--r--source/blender/render/intern/source/pipeline.c14
-rw-r--r--source/blender/src/buttons_scene.c12
-rw-r--r--source/creator/creator.c11
6 files changed, 40 insertions, 16 deletions
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index 60ecce3f9d8..39162b8bd91 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -50,5 +50,6 @@ void BLI_end_threads (struct ListBase *threadbase);
void BLI_lock_thread (int type);
void BLI_unlock_thread (int type);
+int BLI_system_thread_count( void ); /* gets the number of threads the system can make use of */
#endif
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 1f05070b034..d6048b4bade 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -32,6 +32,7 @@
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
+#include <unistd.h> /* for checking system threads */
#include "MEM_guardedalloc.h"
@@ -224,4 +225,16 @@ void BLI_unlock_thread(int type)
pthread_mutex_unlock(&_custom1_lock);
}
+/* how many threads are native on this system? */
+int BLI_system_thread_count( void )
+{
+ int t = (int)sysconf(_SC_NPROCESSORS_ONLN);
+ if (t>RE_MAX_THREAD)
+ return RE_MAX_THREAD;
+ if (t<1)
+ return 1;
+
+ return t;
+}
+
/* eof */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 7a577d22685..39e27667645 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -573,8 +573,9 @@ typedef struct Scene {
#define R_GAUSS 0x20000
/* fbuf obsolete... */
#define R_FBUF 0x40000
- /* threads obsolete... is there for old files */
-#define R_THREADS 0x80000
+ /* threads obsolete... is there for old files, now use for autodetect threads */
+#define R_THREADS 0x80000
+
#define R_SPEED 0x100000
#define R_SSS 0x200000
#define R_NO_OVERWRITE 0x400000 /* skip existing files */
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 177d7ec58e2..5de109a16f4 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -117,7 +117,7 @@ static struct ListBase RenderList= {NULL, NULL};
Render R;
/* commandline thread override */
-static int commandline_threads= 0;
+static int commandline_threads= -1;
/* ********* alloc and free ******** */
@@ -1108,8 +1108,11 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, int winx, int winy
/* we clip faces with a minimum of 2 pixel boundary outside of image border. see zbuf.c */
re->clipcrop= 1.0f + 2.0f/(float)(re->winx>re->winy?re->winy:re->winx);
- if(commandline_threads>0 && commandline_threads<=BLENDER_MAX_THREADS)
+ if (rd->mode & R_THREADS || commandline_threads == 0) { /* Automatic threads */
+ re->r.threads = BLI_system_thread_count();
+ } else if(commandline_threads >= 1 && commandline_threads<=BLENDER_MAX_THREADS) {
re->r.threads= commandline_threads;
+ }
}
}
@@ -2651,8 +2654,11 @@ void RE_ReadRenderResult(Scene *scene, Scene *scenode)
void RE_set_max_threads(int threads)
{
- if(threads>0 && threads<=BLENDER_MAX_THREADS)
+ if (threads==0) {
+ commandline_threads = BLI_system_thread_count();
+ } else if(threads>=1 && threads<=BLENDER_MAX_THREADS) {
commandline_threads= threads;
- else
+ } else {
printf("Error, threads has to be in range 1-%d\n", BLENDER_MAX_THREADS);
+ }
}
diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c
index 055674097b0..7654bc44b75 100644
--- a/source/blender/src/buttons_scene.c
+++ b/source/blender/src/buttons_scene.c
@@ -2022,7 +2022,17 @@ static void render_panel_output(void)
}
uiBlockEndAlign(block);
- uiDefButS(block, NUM, B_NOP, "Threads:", 10, 63, 100, 20, &G.scene->r.threads, 1, BLENDER_MAX_THREADS, 0, 0, "Amount of threads for render (takes advantage of multi-core and multi-processor computers)");
+ uiBlockBeginAlign(block);
+ uiDefIconButBitI(block, TOG, R_THREADS, B_REDR, ICON_AUTO, 10, 63, 20, 20, &G.scene->r.mode, 0.0, 0.0, 0, 0, "Automatic threads from system");
+ if (G.scene->r.mode & R_THREADS) {
+ char thread_str[32];
+ sprintf(thread_str, "Threads: %d", BLI_system_thread_count());
+ uiDefBut(block, LABEL, 0, thread_str, 30, 63,80,20, 0, 0, 0, 0, 0, "");
+ } else {
+ uiDefButS(block, NUM, B_NOP, "Threads:", 35, 63, 80, 20, &G.scene->r.threads, 1, BLENDER_MAX_THREADS, 0, 0, "Amount of threads for render (takes advantage of multi-core and multi-processor computers)");
+ }
+ uiBlockEndAlign(block);
+
uiBlockSetCol(block, TH_AUTO);
uiBlockBeginAlign(block);
diff --git a/source/creator/creator.c b/source/creator/creator.c
index d4a0bb49614..ab6f9681978 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -200,15 +200,8 @@ static void print_help(void)
printf (" (formats that can be compiled into blender, not available on all systems)\n");
printf (" \tHDR TIFF EXR MULTILAYER MPEG AVICODEC QUICKTIME CINEON DPX DDS\n");
printf (" -x <bool>\tSet option to add the file extension to the end of the file.\n");
- printf (" -t <threads>\tUse amount of <threads> for rendering\n");
- /*Add these later - Campbell*/
- /*
- printf (" -colorchannel <type>\tColors to save, valid types are: BW RGB RGBA \n");
- printf (" -compression <type>\t Use with EXR format, valid types are..\n");
- printf (" \tZIP Pxr24 PIZ RLE\n");
- printf (" -zbuf <bool>\tUse with EXR format, set the zbuf save option\n");
- printf (" -halffloat <bool>\tUse with EXR format, set the half float option\n");
- printf (" -preview <bool>\tUse with EXR format, save a jpeg for viewing as well as the EXR\n");*/
+ printf (" -t <threads>\tUse amount of <threads> for rendering.\n");
+ printf (" [1-8], 0 for systems processor count.\n");
printf ("\nAnimation playback options:\n");
printf (" -a <file(s)>\tPlayback <file(s)>, only operates this way when -b is not used.\n");
printf (" -p <sx> <sy>\tOpen with lower left corner at <sx>, <sy>\n");