made auto threads default (noob's get faster renders in their dual core CPU's)

changed env variable check order $TMP, $TMPDIR - aparently $TMP is more common.
This commit is contained in:
Campbell Barton 2008-02-21 08:43:13 +00:00
parent 91d44a9124
commit 7c7a931fed
6 changed files with 27 additions and 23 deletions

View File

@ -32,20 +32,20 @@
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h> /* for checking system threads */
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_threads.h"
/* for checking system threads - BLI_system_thread_count */
#ifdef WIN32
#include "Windows.h"
#endif
#ifdef __APPLE__
#elif defined(__APPLE__)
#include <sys/types.h>
#include <sys/sysctl.h>
#else
#include <unistd.h>
#endif
/* ********** basic thread control API ************

View File

@ -1615,26 +1615,31 @@ void BLI_where_is_temp(char *fullname, int usertemp)
strcpy(fullname, U.tempdir);
}
if (fullname[0] == '\0') {
#ifdef WIN32
if (fullname[0] == '\0') {
char *tmp = getenv("TEMP"); /* Windows */
if (tmp && BLI_exists(tmp)) {
strcpy(fullname, tmp);
}
}
#else
char *tmp = getenv("TMPDIR"); /* Other OS's - Try TMP and TMPDIR */
/* Other OS's - Try TMP and TMPDIR */
if (fullname[0] == '\0') {
char *tmp = getenv("TMP");
if (tmp && BLI_exists(tmp)) {
strcpy(fullname, tmp);
}
if (fullname[0] == '\0') {
tmp = getenv("TMP");
if (tmp && BLI_exists(tmp)) {
strcpy(fullname, tmp);
}
}
#endif
}
if (fullname[0] == '\0') {
char *tmp = getenv("TMPDIR");
if (tmp && BLI_exists(tmp)) {
strcpy(fullname, tmp);
}
}
#endif
if (fullname[0] == '\0') {
strcpy(fullname, "/tmp/");
} else {

View File

@ -577,7 +577,7 @@ typedef struct Scene {
/* threads obsolete... is there for old files, now use for autodetect threads */
#define R_THREADS 0x80000
/* Use the same flag for autothreads */
#define R_AUTO_THREADS 0x80000
#define R_FIXED_THREADS 0x80000
#define R_SPEED 0x100000
#define R_SSS 0x200000

View File

@ -2089,7 +2089,7 @@ static int RenderData_setModeBit( BPy_RenderData* self, PyObject *value,
#define MODE_MASK ( R_OSA | R_SHADOW | R_GAMMA | R_ENVMAP | R_EDGE | \
R_FIELDS | R_FIELDSTILL | R_RADIO | R_BORDER | R_PANORAMA | R_CROP | \
R_ODDFIELD | R_MBLUR | R_RAYTRACE | R_AUTO_THREADS )
R_ODDFIELD | R_MBLUR | R_RAYTRACE | R_FIXED_THREADS )
static PyObject *RenderData_getMode( BPy_RenderData *self )
{
@ -2593,13 +2593,12 @@ static PyGetSetDef BPy_RenderData_getseters[] = {
(getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
"Skip rendering existing image files",
(void *)R_NO_OVERWRITE},
{"autoThreads",
{"fixedThreads",
(getter)RenderData_getModeBit, (setter)RenderData_setModeBit,
"Use system number of processors",
(void *)R_AUTO_THREADS},
"Use the number of threads defined by the blend file",
(void *)R_FIXED_THREADS},
/* R_GAUSS unused */
/* R_FBUF unused */
/* R_AUTO_THREADS unused */
{"threads",
(getter)RenderData_getThreads, (setter)RenderData_setThreads,
"Number of threads used to render",
@ -3721,7 +3720,7 @@ static PyObject *M_Render_ModesDict( void )
PyConstant_Insert( d, "ODDFIELD", PyInt_FromLong( R_ODDFIELD ) );
PyConstant_Insert( d, "MBLUR", PyInt_FromLong( R_MBLUR ) );
PyConstant_Insert( d, "RAYTRACING", PyInt_FromLong( R_RAYTRACE ) );
PyConstant_Insert( d, "AUTOTHREADS", PyInt_FromLong( R_AUTO_THREADS ) );
PyConstant_Insert( d, "FIXEDTHREADS", PyInt_FromLong( R_FIXED_THREADS ) );
}
return M;
}

View File

@ -1108,7 +1108,7 @@ 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 (rd->mode & R_AUTO_THREADS || commandline_threads == 0) { /* Automatic threads */
if (rd->mode & R_FIXED_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;

View File

@ -2023,8 +2023,8 @@ static void render_panel_output(void)
uiBlockEndAlign(block);
uiBlockBeginAlign(block);
uiDefIconButBitI(block, TOG, R_AUTO_THREADS, B_REDR, ICON_AUTO, 10, 63, 20, 20, &G.scene->r.mode, 0.0, 0.0, 0, 0, "Automatically set the threads to the number of processors on the system");
if (G.scene->r.mode & R_AUTO_THREADS) {
uiDefIconButBitI(block, TOGN, R_FIXED_THREADS, B_REDR, ICON_AUTO, 10, 63, 20, 20, &G.scene->r.mode, 0.0, 0.0, 0, 0, "Automatically set the threads to the number of processors on the system");
if ((G.scene->r.mode & R_FIXED_THREADS)==0) {
char thread_str[16];
sprintf(thread_str, " Threads: %d", BLI_system_thread_count());
uiDefBut(block, LABEL, 0, thread_str, 30, 63,80,20, 0, 0, 0, 0, 0, "");