From 0b5a3de2ddc376a6f034693efc1844031de00391 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sun, 5 Jun 2016 10:08:27 -0700 Subject: [PATCH] Added command line flag to set number of render threads. --- src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 809ae7d..f291773 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,6 +50,8 @@ Usage: Options: -i , --input Input .psy file. -s , --spp Number of samples per pixel. + -t , --threads Number of threads to render with. Defaults + to the number of logical cores on the system. -h, --help Show this screen. --version Show version. "#; @@ -58,6 +60,7 @@ Options: struct Args { flag_input: Option, flag_spp: Option, + flag_threads: Option, flag_version: bool, } @@ -101,8 +104,14 @@ fn main() { r.spp = spp; } - println!("Rendering scene..."); - r.render(num_cpus::get() as u32); + let thread_count = if let Some(threads) = args.flag_threads { + threads as u32 + } else { + num_cpus::get() as u32 + }; + + println!("Rendering scene with {} threads...", thread_count); + r.render(thread_count); } } }