From 5a3959e54b7a08ee852e5e65d46fe6ea2e37d342 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 29 Nov 2006 19:31:45 +0000 Subject: [PATCH] Thread support for commandline: -t 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 :) --- source/blender/render/extern/include/RE_pipeline.h | 3 +++ source/blender/render/intern/source/pipeline.c | 14 ++++++++++++++ source/creator/creator.c | 9 ++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 65a0bf0b7ad..0a07dd4cdac 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -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); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index cd954b8c363..ef6434cf65a 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -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); +} diff --git a/source/creator/creator.c b/source/creator/creator.c index c31f66d1973..b3e807bef03 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -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 \tSet option to add the file extension to the end of the file.\n"); + printf (" -t \tUse amount of for rendering\n"); printf ("\nAnimation options:\n"); printf (" -a \tPlayback \n"); printf (" -p \tOpen with lower left corner at , \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) {