1
1
/*
2
- Copyright (c) 2005-2022 Intel Corporation
2
+ Copyright (c) 2005-2025 Intel Corporation
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
55
55
#include " util.hpp"
56
56
#include " tachyon_video.hpp"
57
57
#include " common/utility/utility.hpp"
58
+ #include " common/utility/measurements.hpp"
58
59
59
60
#if WIN8UI_EXAMPLE
60
61
#include " oneapi/tbb.h"
@@ -74,9 +75,11 @@ bool global_usegraphics;
74
75
75
76
bool silent_mode = false ; /* silent mode */
76
77
78
+ utility::measurements *global_measurements = nullptr ;
77
79
class tachyon_video *video = nullptr ;
78
80
79
81
typedef struct {
82
+ int iterations; /* how many times to repeat rendering for statistics */
80
83
int foundfilename; /* was a model file name found in the args? */
81
84
char filename[1024 ]; /* model file to render */
82
85
int useoutfilename; /* command line override of output filename */
@@ -92,6 +95,7 @@ typedef struct {
92
95
93
96
void initoptions (argoptions *opt) {
94
97
memset (opt, 0 , sizeof (argoptions));
98
+ opt->iterations = 1 ;
95
99
opt->foundfilename = -1 ;
96
100
opt->useoutfilename = -1 ;
97
101
opt->verbosemode = -1 ;
@@ -289,6 +293,9 @@ argoptions ParseCommandLine(int argc, const char *argv[]) {
289
293
.positional_arg (opt.boundthresh , " boundthresh" , " bounding threshold value" )
290
294
.arg (nodisp, " no-display-updating" , " disable run-time display updating" )
291
295
.arg (nobounding, " no-bounding" , " disable bounding technique" )
296
+ .arg (opt.iterations ,
297
+ " n-of-iterations" ,
298
+ " number of rendering iterations to collect its reliable performance statistics" )
292
299
.arg (silent_mode, " silent" , " no output except elapsed time" ));
293
300
294
301
strcpy (opt.filename , filename.c_str ());
@@ -345,9 +352,21 @@ int main(int argc, char *argv[]) {
345
352
global_window_title = window_title_string (argc, (const char **)argv);
346
353
347
354
argoptions opt = ParseCommandLine (argc, (const char **)argv);
355
+ if (opt.iterations > 1 ) {
356
+ fprintf (stdout, " Repeating ray tracing %d times ...\n " , opt.iterations );
357
+ }
358
+ else if (opt.iterations < 1 ) {
359
+ fprintf (stderr, " Incorrect n-of-iterations=%d, exit.\n " , opt.iterations );
360
+ return -1 ;
361
+ }
362
+
363
+ utility::measurements measurements (opt.iterations );
364
+ global_measurements = &measurements;
348
365
349
- if (CreateScene (opt) != 0 )
366
+ if (CreateScene (opt) != 0 ) {
367
+ fprintf (stderr, " Failed to create scene!, exit.\n " );
350
368
return -1 ;
369
+ }
351
370
352
371
tachyon_video tachyon;
353
372
tachyon.threaded = true ;
@@ -356,12 +375,17 @@ int main(int argc, char *argv[]) {
356
375
tachyon.title = global_window_title;
357
376
// always using window even if(!global_usegraphics)
358
377
global_usegraphics = tachyon.init_window (global_xwinsize, global_ywinsize);
359
- if (!tachyon.running )
378
+ if (!tachyon.running ) {
379
+ fprintf (stderr, " Failed to start tracing!, exit.\n " );
360
380
return -1 ;
381
+ }
361
382
362
383
video = &tachyon;
363
384
tachyon.main_loop ();
364
385
386
+ if (opt.iterations > 1 ) {
387
+ utility::report_relative_error (measurements.computeRelError ());
388
+ }
365
389
utility::report_elapsed_time (timertime (mainStartTime, gettimer ()));
366
390
return 0 ;
367
391
}
0 commit comments