Thread support for commandline:

-t <threads>

It overrides the settings as saved in scenes. Only works for background
rendering, to force thread amounts to match the cpus in system.
For funny jokers: amount is clipped for MAXTHREADS :)
This commit is contained in:
Ton Roosendaal 2006-11-29 19:31:45 +00:00
parent f1b74d0098
commit 5a3959e54b
3 changed files with 25 additions and 1 deletions

@ -159,6 +159,9 @@ void RE_Database_Free (struct Render *re);
/* project dbase again, when viewplane/perspective changed */
void RE_DataBase_ApplyWindow(struct Render *re);
/* override the scene setting for amount threads, commandline */
void RE_set_max_threads(int threads);
/* the main processor, assumes all was set OK! */
void RE_TileProcessor(struct Render *re, int firsttile);

@ -114,6 +114,9 @@ static struct ListBase RenderList= {NULL, NULL};
/* hardcopy of current render, used while rendering for speed */
Render R;
/* commandline thread override */
static int commandline_threads= 0;
/* ********* alloc and free ******** */
@ -812,6 +815,9 @@ void RE_InitState(Render *re, RenderData *rd, int winx, int winy, rcti *disprect
re->result= MEM_callocN(sizeof(RenderResult), "new render result");
re->result->rectx= re->rectx;
re->result->recty= re->recty;
if(commandline_threads>0 && commandline_threads<=BLENDER_MAX_THREADS)
re->r.threads= commandline_threads;
}
}
@ -2067,3 +2073,11 @@ void RE_ReadRenderResult(Scene *scene, Scene *scenode)
read_render_result(re);
}
void RE_set_max_threads(int threads)
{
if(threads>0 && threads<=BLENDER_MAX_THREADS)
commandline_threads= threads;
else
printf("Error, threads has to be in range 1-%d\n", BLENDER_MAX_THREADS);
}

@ -187,6 +187,7 @@ static void print_help(void)
printf (" (formats that can be compiled into blender, not available on all systems)\n");
printf (" \tHDR TIFF EXR MPEG AVICODEC QUICKTIME CINEON DPX\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");
printf ("\nAnimation options:\n");
printf (" -a <file(s)>\tPlayback <file(s)>\n");
printf (" -p <sx> <sy>\tOpen with lower left corner at <sx>, <sy>\n");
@ -353,7 +354,6 @@ int main(int argc, char **argv)
case 'h':
print_help();
exit(0);
case 'v':
print_version();
exit(0);
@ -398,6 +398,7 @@ int main(int argc, char **argv)
case 'd':
G.f |= G_DEBUG; /* std output printf's */
printf ("Blender V %d.%02d\n", G.version/100, G.version%100);
MEM_set_memory_debug();
#ifdef NAN_BUILDINFO
printf("Build: %s %s %s %s\n", build_date, build_time, build_platform, build_type);
@ -649,6 +650,12 @@ int main(int argc, char **argv)
}
break;
case 't':
a++;
if(G.background) {
RE_set_max_threads(atoi(argv[a]));
}
break;
case 'x': /* extension */
a++;
if (a < argc) {