OLD | NEW |
1 /* | 1 /* |
2 Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. | 2 Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. |
3 All Rights Reserved. | 3 All Rights Reserved. |
4 | 4 |
5 Redistribution and use in source and binary forms, with or without | 5 Redistribution and use in source and binary forms, with or without |
6 modification, are permitted provided that the following conditions are | 6 modification, are permitted provided that the following conditions are |
7 met: | 7 met: |
8 * Redistributions of source code must retain the above copyright | 8 * Redistributions of source code must retain the above copyright |
9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
10 * Redistributions in binary form must reproduce the above copyright | 10 * Redistributions in binary form must reproduce the above copyright |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 | 49 |
50 | 50 |
51 | 51 |
52 static ShadingSystem *shadingsys = NULL; | 52 static ShadingSystem *shadingsys = NULL; |
53 static std::vector<std::string> shadernames; | 53 static std::vector<std::string> shadernames; |
54 static std::vector<std::string> outputfiles; | 54 static std::vector<std::string> outputfiles; |
55 static std::vector<std::string> outputvars; | 55 static std::vector<std::string> outputvars; |
56 static std::string dataformatname = ""; | 56 static std::string dataformatname = ""; |
57 static bool debug = false; | 57 static bool debug = false; |
| 58 static bool stats = false; |
58 static int xres = 1, yres = 1; | 59 static int xres = 1, yres = 1; |
59 static std::string layername; | 60 static std::string layername; |
60 static std::vector<std::string> connections; | 61 static std::vector<std::string> connections; |
61 static std::vector<std::string> iparams, fparams, vparams, sparams; | 62 static std::vector<std::string> iparams, fparams, vparams, sparams; |
62 static float fparamdata[1000]; // bet that's big enough | 63 static float fparamdata[1000]; // bet that's big enough |
63 static int fparamindex = 0; | 64 static int fparamindex = 0; |
64 static int iparamdata[1000]; | 65 static int iparamdata[1000]; |
65 static int iparamindex = 0; | 66 static int iparamindex = 0; |
66 static ustring sparamdata[1000]; | 67 static ustring sparamdata[1000]; |
67 static int sparamindex = 0; | 68 static int sparamindex = 0; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 131 |
131 static void | 132 static void |
132 getargs (int argc, const char *argv[]) | 133 getargs (int argc, const char *argv[]) |
133 { | 134 { |
134 static bool help = false; | 135 static bool help = false; |
135 ArgParse ap; | 136 ArgParse ap; |
136 ap.options ("Usage: testshade [options] shader...", | 137 ap.options ("Usage: testshade [options] shader...", |
137 "%*", add_shader, "", | 138 "%*", add_shader, "", |
138 "--help", &help, "Print help message", | 139 "--help", &help, "Print help message", |
139 "--debug", &debug, "Lots of debugging info", | 140 "--debug", &debug, "Lots of debugging info", |
| 141 "--stats", &stats, "Print run statistics", |
140 "-g %d %d", &xres, &yres, "Make an X x Y grid of shading points"
, | 142 "-g %d %d", &xres, &yres, "Make an X x Y grid of shading points"
, |
141 "-o %L %L", &outputvars, &outputfiles, | 143 "-o %L %L", &outputvars, &outputfiles, |
142 "Output (variable, filename)", | 144 "Output (variable, filename)", |
143 "-od %s", &dataformatname, "Set the output data format to one of
:\n" | 145 "-od %s", &dataformatname, "Set the output data format to one of
:\n" |
144 "\t\t\tuint8, half, float", | 146 "\t\t\tuint8, half, float", |
145 "--layer %s", &layername, "Set next layer name", | 147 "--layer %s", &layername, "Set next layer name", |
146 "--fparam %L %L", | 148 "--fparam %L %L", |
147 &fparams, &fparams, | 149 &fparams, &fparams, |
148 "Add a float param (args: name value)", | 150 "Add a float param (args: name value)", |
149 "--iparam %L %L", | 151 "--iparam %L %L", |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 OpenImageIO::convert_types (tbase, | 342 OpenImageIO::convert_types (tbase, |
341 (char *)sym->data() + n*sym->step(), | 343 (char *)sym->data() + n*sym->step(), |
342 TypeDesc::FLOAT, &pixel[0], nchans); | 344 TypeDesc::FLOAT, &pixel[0], nchans); |
343 img.setpixel (x, y, &pixel[0]); | 345 img.setpixel (x, y, &pixel[0]); |
344 } | 346 } |
345 } | 347 } |
346 img.save (); | 348 img.save (); |
347 } | 349 } |
348 ssi->release_context (ctx); | 350 ssi->release_context (ctx); |
349 | 351 |
350 if (debug) { | 352 if (debug || stats) { |
351 std::cout << "\n"; | 353 std::cout << "\n"; |
352 std::cout << "Setup: " << Strutil::timeintervalformat (setuptime,2) << "
\n"; | 354 std::cout << "Setup: " << Strutil::timeintervalformat (setuptime,2) << "
\n"; |
353 std::cout << "Bind : " << Strutil::timeintervalformat (bindtime,2) << "\
n"; | 355 std::cout << "Bind : " << Strutil::timeintervalformat (bindtime,2) << "\
n"; |
354 std::cout << "Run : " << Strutil::timeintervalformat (runtime,2) << "\n
"; | 356 std::cout << "Run : " << Strutil::timeintervalformat (runtime,2) << "\n
"; |
355 std::cout << "\n"; | 357 std::cout << "\n"; |
356 std::cout << shadingsys->getstats (5) << "\n"; | 358 std::cout << shadingsys->getstats (5) << "\n"; |
357 } | 359 } |
358 | 360 |
359 ShadingSystem::destroy (shadingsys); | 361 ShadingSystem::destroy (shadingsys); |
360 return EXIT_SUCCESS; | 362 return EXIT_SUCCESS; |
361 } | 363 } |
OLD | NEW |