2727#define VKRT_TURBOJPEG_VERSION "unknown"
2828#endif
2929
30- static const uint32_t kBenchmarkWidth = 3840u ;
31- static const uint32_t kBenchmarkHeight = 2160u ;
32- static const uint32_t kBenchmarkTargetSamples = 16384u ;
30+ static const uint32_t kOfflineRenderWidth = 3840u ;
31+ static const uint32_t kOfflineRenderHeight = 2160u ;
32+ static const uint32_t kOfflineRenderTargetSamples = 16384u ;
3333
3434static int stringsEqual (const char * lhs , const char * rhs ) {
3535 if (!lhs || !rhs ) return 0 ;
@@ -125,9 +125,9 @@ void CLIDefaultLaunchOptions(CLILaunchOptions* options) {
125125 memset (options , 0 , sizeof (* options ));
126126 options -> mode = CLI_MODE_RUN ;
127127 options -> loadDefaultScene = 1u ;
128- options -> benchmark .width = kBenchmarkWidth ;
129- options -> benchmark .height = kBenchmarkHeight ;
130- options -> benchmark .targetSamples = kBenchmarkTargetSamples ;
128+ options -> offlineRender .width = kOfflineRenderWidth ;
129+ options -> offlineRender .height = kOfflineRenderHeight ;
130+ options -> offlineRender .targetSamples = kOfflineRenderTargetSamples ;
131131 VKRT_defaultCreateInfo (& options -> createInfo );
132132}
133133
@@ -179,7 +179,7 @@ static int parseWindowArgument(
179179 return -1 ;
180180}
181181
182- static int parseBenchmarkArgument (
182+ static int parseOfflineRenderArgument (
183183 const char * arg ,
184184 int argc ,
185185 char * argv [],
@@ -188,28 +188,28 @@ static int parseBenchmarkArgument(
188188 char * error ,
189189 size_t errorSize
190190) {
191- if (stringsEqual (arg , "--benchmark" )) {
192- options -> benchmark .enabled = 1u ;
193- options -> benchmark .headless = 0u ;
191+ if (stringsEqual (arg , "--render" ) || stringsEqual ( arg , "-- benchmark" )) {
192+ options -> offlineRender .enabled = 1u ;
193+ options -> offlineRender .headless = 0u ;
194194 return 1 ;
195195 }
196- if (stringsEqual (arg , "--benchmark -headless" )) {
197- options -> benchmark .enabled = 1u ;
198- options -> benchmark .headless = 1u ;
196+ if (stringsEqual (arg , "--render -headless" )) {
197+ options -> offlineRender .enabled = 1u ;
198+ options -> offlineRender .headless = 1u ;
199199 return 1 ;
200200 }
201- if (optionMatches (arg , "--benchmark -width" )) {
202- const char * value = requireOptionValue (argc , argv , index , "--benchmark -width" , error , errorSize );
203- return value && parseUnsignedValue (value , & options -> benchmark .width , "--benchmark -width" , error , errorSize );
201+ if (optionMatches (arg , "--render -width" )) {
202+ const char * value = requireOptionValue (argc , argv , index , "--render -width" , error , errorSize );
203+ return value && parseUnsignedValue (value , & options -> offlineRender .width , "--render -width" , error , errorSize );
204204 }
205- if (optionMatches (arg , "--benchmark -height" )) {
206- const char * value = requireOptionValue (argc , argv , index , "--benchmark -height" , error , errorSize );
207- return value && parseUnsignedValue (value , & options -> benchmark .height , "--benchmark -height" , error , errorSize );
205+ if (optionMatches (arg , "--render -height" )) {
206+ const char * value = requireOptionValue (argc , argv , index , "--render -height" , error , errorSize );
207+ return value && parseUnsignedValue (value , & options -> offlineRender .height , "--render -height" , error , errorSize );
208208 }
209- if (optionMatches (arg , "--benchmark -samples" )) {
210- const char * value = requireOptionValue (argc , argv , index , "--benchmark -samples" , error , errorSize );
209+ if (optionMatches (arg , "--render -samples" )) {
210+ const char * value = requireOptionValue (argc , argv , index , "--render -samples" , error , errorSize );
211211 return value &&
212- parseUnsignedValue (value , & options -> benchmark .targetSamples , "--benchmark -samples" , error , errorSize );
212+ parseUnsignedValue (value , & options -> offlineRender .targetSamples , "--render -samples" , error , errorSize );
213213 }
214214 return -1 ;
215215}
@@ -227,22 +227,38 @@ static int parseSceneArgument(
227227 options -> loadDefaultScene = 0u ;
228228 return 1 ;
229229 }
230+ if (optionMatches (arg , "--scene" )) {
231+ const char * value = requireOptionValue (argc , argv , index , "--scene" , error , errorSize );
232+ if (!value || !value [0 ]) return setCLIError (error , errorSize , "Invalid value for --scene" , NULL );
233+ options -> startupScenePath = value ;
234+ options -> loadDefaultScene = 0u ;
235+ return 1 ;
236+ }
230237 if (optionMatches (arg , "--import" )) {
231238 const char * value = requireOptionValue (argc , argv , index , "--import" , error , errorSize );
232239 if (!value || !value [0 ]) return setCLIError (error , errorSize , "Invalid value for --import" , NULL );
233240 options -> startupImportPath = value ;
234241 return 1 ;
235242 }
243+ if (optionMatches (arg , "--render-output" )) {
244+ const char * value = requireOptionValue (argc , argv , index , "--render-output" , error , errorSize );
245+ if (!value || !value [0 ]) return setCLIError (error , errorSize , "Invalid value for --render-output" , NULL );
246+ options -> renderOutputPath = value ;
247+ return 1 ;
248+ }
236249 return -1 ;
237250}
238251
239252static int validateCLIArgumentCombination (const CLILaunchOptions * options , char * error , size_t errorSize ) {
240- if (!options -> benchmark .enabled ) return 1 ;
241- if (!options -> loadDefaultScene ) {
242- return setCLIError (error , errorSize , "--benchmark requires the default scene" , NULL );
243- }
253+ if (!options -> offlineRender .enabled ) return 1 ;
244254 if (options -> startupImportPath ) {
245- return setCLIError (error , errorSize , "--benchmark cannot be combined with --import" , NULL );
255+ return setCLIError (error , errorSize , "--render cannot be combined with --import" , NULL );
256+ }
257+ if (!options -> loadDefaultScene && !options -> startupScenePath ) {
258+ return setCLIError (error , errorSize , "--render requires either the default scene or --scene" , NULL );
259+ }
260+ if (options -> renderOutputPath && !options -> offlineRender .headless ) {
261+ return setCLIError (error , errorSize , "--render-output currently requires --render-headless" , NULL );
246262 }
247263 return 1 ;
248264}
@@ -270,7 +286,7 @@ int CLIParseArguments(int argc, char* argv[], CLILaunchOptions* outOptions, char
270286 if (parseResult == 0 ) return 0 ;
271287 if (parseResult > 0 ) continue ;
272288
273- parseResult = parseBenchmarkArgument (arg , argc , argv , & i , outOptions , error , errorSize );
289+ parseResult = parseOfflineRenderArgument (arg , argc , argv , & i , outOptions , error , errorSize );
274290 if (parseResult == 0 ) return 0 ;
275291 if (parseResult > 0 ) continue ;
276292
@@ -345,15 +361,18 @@ void CLIPrintHelp(void) {
345361 printf (" --device-index <index> Force a Vulkan device by enumerated index\n" );
346362 printf (" --device-name <text> Force a Vulkan device if its name contains this text\n" );
347363 printf (" --empty-scene Skip loading the default starter scene\n" );
348- printf (" --benchmark Run the default benchmark with presentation enabled\n" );
364+ printf (" --scene <path> Load a vkrt scene (.json) on startup\n" );
365+ printf (" --render Run an offline render with presentation enabled\n" );
349366 printf (
350- " --benchmark -headless Run the default benchmark offscreen with no window or "
367+ " --render -headless Run an offline render offscreen with no window or "
351368 "presentation\n"
352369 );
353- printf (" --benchmark -width <px> Override benchmark render width (default: 3840)\n" );
354- printf (" --benchmark -height <px> Override benchmark render height (default: 2160)\n" );
355- printf (" --benchmark -samples <n> Override benchmark target samples (default: 16384)\n" );
370+ printf (" --render -width <px> Override offline render width (default: 3840)\n" );
371+ printf (" --render -height <px> Override offline render height (default: 2160)\n" );
372+ printf (" --render -samples <n> Override offline render target samples (default: 16384)\n" );
356373 printf (" --import <path> Import a mesh on startup\n" );
374+ printf (" --render-output <path> Save the --render-headless image after completion\n" );
375+ printf (" --benchmark Alias for --render\n" );
357376 printf ("\nViewport Controls:\n" );
358377 printf (" Middle mouse drag Orbit camera\n" );
359378 printf (" Shift + middle mouse drag Pan camera\n" );
0 commit comments