Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Main binary for DM. | 1 // Main binary for DM. |
| 2 // For a high-level overview, please see dm/README. | 2 // For a high-level overview, please see dm/README. |
| 3 | 3 |
| 4 #include "SkBenchmark.h" | 4 #include "SkBenchmark.h" |
| 5 #include "SkCommandLineFlags.h" | 5 #include "SkCommandLineFlags.h" |
| 6 #include "SkForceLinking.h" | 6 #include "SkForceLinking.h" |
| 7 #include "SkGraphics.h" | 7 #include "SkGraphics.h" |
| 8 #include "SkPicture.h" | 8 #include "SkPicture.h" |
| 9 #include "SkString.h" | 9 #include "SkString.h" |
| 10 #include "Test.h" | 10 #include "Test.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 # define RASTERIZE_PDF_PROC NULL | 29 # define RASTERIZE_PDF_PROC NULL |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #include <ctype.h> | 32 #include <ctype.h> |
| 33 | 33 |
| 34 using skiagm::GM; | 34 using skiagm::GM; |
| 35 using skiagm::GMRegistry; | 35 using skiagm::GMRegistry; |
| 36 using skiatest::Test; | 36 using skiatest::Test; |
| 37 using skiatest::TestRegistry; | 37 using skiatest::TestRegistry; |
| 38 | 38 |
| 39 static const char kGpuApiNameGL[] = "gl"; | |
| 40 static const char kGpuApiNameGLES[] = "gles"; | |
| 41 | |
| 39 DEFINE_int32(threads, -1, "Threads for CPU work. Default NUM_CPUS."); | 42 DEFINE_int32(threads, -1, "Threads for CPU work. Default NUM_CPUS."); |
| 40 DEFINE_int32(gpuThreads, 1, "Threads for GPU work."); | 43 DEFINE_int32(gpuThreads, 1, "Threads for GPU work."); |
| 44 DEFINE_string(forceGpuApi, "", "Force use of specific gpu API. Using \"gl\" " | |
|
mtklein
2014/06/09 14:10:46
Personally I'd go with just gpuAPI?
Is there any
bsalomon
2014/06/09 14:15:11
It definitely *could* be implemented that way. One
mtklein
2014/06/09 14:20:21
Yeah, this is fine, we can cross them here inside
bsalomon
2014/06/09 14:29:52
If we move towards supporting arbitrary members of
Kimmo Kinnunen
2014/06/16 12:36:40
Done.
| |
| 45 "forces OpenGL API. Using \"gles\" forces OpenGL ES API. " | |
| 46 "Defaults to empty string, which selects the API native to the " | |
| 47 "system."); | |
| 41 #ifdef SK_BUILD_JSON_WRITER | 48 #ifdef SK_BUILD_JSON_WRITER |
| 42 DEFINE_string2(expectations, r, "", | 49 DEFINE_string2(expectations, r, "", |
| 43 "If a directory, compare generated images against images under th is path. " | 50 "If a directory, compare generated images against images under th is path. " |
| 44 "If a file, compare generated images against JSON expectations at this path." | 51 "If a file, compare generated images against JSON expectations at this path." |
| 45 ); | 52 ); |
| 46 #else | 53 #else |
| 47 DEFINE_string2(expectations, r, "", | 54 DEFINE_string2(expectations, r, "", |
| 48 "If a directory, compare generated images against images under th is path. " | 55 "If a directory, compare generated images against images under th is path. " |
| 49 ); | 56 ); |
| 50 #endif | 57 #endif |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 #endif | 100 #endif |
| 94 static const GrContextFactory::GLContextType mesa = | 101 static const GrContextFactory::GLContextType mesa = |
| 95 #if SK_MESA | 102 #if SK_MESA |
| 96 GrContextFactory::kMESA_GLContextType; | 103 GrContextFactory::kMESA_GLContextType; |
| 97 #else | 104 #else |
| 98 native; | 105 native; |
| 99 #endif | 106 #endif |
| 100 | 107 |
| 101 static void kick_off_gms(const SkTDArray<GMRegistry::Factory>& gms, | 108 static void kick_off_gms(const SkTDArray<GMRegistry::Factory>& gms, |
| 102 const SkTArray<SkString>& configs, | 109 const SkTArray<SkString>& configs, |
| 110 GrGLStandard forcedGpuApi, | |
| 103 const DM::Expectations& expectations, | 111 const DM::Expectations& expectations, |
| 104 DM::Reporter* reporter, | 112 DM::Reporter* reporter, |
| 105 DM::TaskRunner* tasks) { | 113 DM::TaskRunner* tasks) { |
| 106 #define START(name, type, ...) \ | 114 #define START(name, type, ...) \ |
| 107 if (lowercase(configs[j]).equals(name)) { \ | 115 if (lowercase(configs[j]).equals(name)) { \ |
| 108 tasks->add(SkNEW_ARGS(DM::type, \ | 116 tasks->add(SkNEW_ARGS(DM::type, \ |
| 109 (name, reporter, tasks, expectations, gms[i], ## __VA_ARGS__ ))); \ | 117 (name, reporter, tasks, expectations, gms[i], ## __VA_ARGS__ ))); \ |
| 110 } | 118 } |
| 111 for (int i = 0; i < gms.count(); i++) { | 119 for (int i = 0; i < gms.count(); i++) { |
| 112 for (int j = 0; j < configs.count(); j++) { | 120 for (int j = 0; j < configs.count(); j++) { |
| 113 START("565", CpuGMTask, kRGB_565_SkColorType); | 121 START("565", CpuGMTask, kRGB_565_SkColorType); |
| 114 START("8888", CpuGMTask, kN32_SkColorType); | 122 START("8888", CpuGMTask, kN32_SkColorType); |
| 115 START("gpu", GpuGMTask, native, 0); | 123 START("gpu", GpuGMTask, native, forcedGpuApi, 0); |
| 116 START("msaa4", GpuGMTask, native, 4); | 124 START("msaa4", GpuGMTask, native, forcedGpuApi, 4); |
| 117 START("msaa16", GpuGMTask, native, 16); | 125 START("msaa16", GpuGMTask, native, forcedGpuApi, 16); |
| 118 START("nvprmsaa4", GpuGMTask, nvpr, 4); | 126 START("nvprmsaa4", GpuGMTask, nvpr, forcedGpuApi, 4); |
| 119 START("nvprmsaa16", GpuGMTask, nvpr, 16); | 127 START("nvprmsaa16", GpuGMTask, nvpr, forcedGpuApi, 16); |
| 120 START("gpunull", GpuGMTask, null, 0); | 128 START("gpunull", GpuGMTask, null, forcedGpuApi, 0); |
| 121 START("gpudebug", GpuGMTask, debug, 0); | 129 START("gpudebug", GpuGMTask, debug, forcedGpuApi, 0); |
| 122 START("angle", GpuGMTask, angle, 0); | 130 START("angle", GpuGMTask, angle, forcedGpuApi, 0); |
| 123 START("mesa", GpuGMTask, mesa, 0); | 131 START("mesa", GpuGMTask, mesa, forcedGpuApi, 0); |
| 124 START("pdf", PDFTask, RASTERIZE_PDF_PROC); | 132 START("pdf", PDFTask, RASTERIZE_PDF_PROC); |
| 125 } | 133 } |
| 126 } | 134 } |
| 127 #undef START | 135 #undef START |
| 128 } | 136 } |
| 129 | 137 |
| 130 static void kick_off_benches(const SkTDArray<BenchRegistry::Factory>& benches, | 138 static void kick_off_benches(const SkTDArray<BenchRegistry::Factory>& benches, |
| 131 const SkTArray<SkString>& configs, | 139 const SkTArray<SkString>& configs, |
| 140 GrGLStandard forcedGpuApi, | |
| 132 DM::Reporter* reporter, | 141 DM::Reporter* reporter, |
| 133 DM::TaskRunner* tasks) { | 142 DM::TaskRunner* tasks) { |
| 134 #define START(name, type, ...) \ | 143 #define START(name, type, ...) \ |
| 135 if (lowercase(configs[j]).equals(name)) { \ | 144 if (lowercase(configs[j]).equals(name)) { \ |
| 136 tasks->add(SkNEW_ARGS(DM::type, (name, reporter, tasks, benches[i], ## _ _VA_ARGS__))); \ | 145 tasks->add(SkNEW_ARGS(DM::type, (name, reporter, tasks, benches[i], ## _ _VA_ARGS__))); \ |
| 137 } | 146 } |
| 138 for (int i = 0; i < benches.count(); i++) { | 147 for (int i = 0; i < benches.count(); i++) { |
| 139 for (int j = 0; j < configs.count(); j++) { | 148 for (int j = 0; j < configs.count(); j++) { |
| 140 START("nonrendering", NonRenderingBenchTask); | 149 START("nonrendering", NonRenderingBenchTask); |
| 141 START("565", CpuBenchTask, kRGB_565_SkColorType); | 150 START("565", CpuBenchTask, kRGB_565_SkColorType); |
| 142 START("8888", CpuBenchTask, kN32_SkColorType); | 151 START("8888", CpuBenchTask, kN32_SkColorType); |
| 143 START("gpu", GpuBenchTask, native, 0); | 152 START("gpu", GpuBenchTask, native, forcedGpuApi, 0); |
| 144 START("msaa4", GpuBenchTask, native, 4); | 153 START("msaa4", GpuBenchTask, native, forcedGpuApi, 4); |
| 145 START("msaa16", GpuBenchTask, native, 16); | 154 START("msaa16", GpuBenchTask, native, forcedGpuApi, 16); |
| 146 START("nvprmsaa4", GpuBenchTask, nvpr, 4); | 155 START("nvprmsaa4", GpuBenchTask, nvpr, forcedGpuApi, 4); |
| 147 START("nvprmsaa16", GpuBenchTask, nvpr, 16); | 156 START("nvprmsaa16", GpuBenchTask, nvpr, forcedGpuApi, 16); |
| 148 START("gpunull", GpuBenchTask, null, 0); | 157 START("gpunull", GpuBenchTask, null, forcedGpuApi, 0); |
| 149 START("gpudebug", GpuBenchTask, debug, 0); | 158 START("gpudebug", GpuBenchTask, debug, forcedGpuApi, 0); |
| 150 START("angle", GpuBenchTask, angle, 0); | 159 START("angle", GpuBenchTask, angle, forcedGpuApi, 0); |
| 151 START("mesa", GpuBenchTask, mesa, 0); | 160 START("mesa", GpuBenchTask, mesa, forcedGpuApi, 0); |
| 152 } | 161 } |
| 153 } | 162 } |
| 154 #undef START | 163 #undef START |
| 155 } | 164 } |
| 156 | 165 |
| 157 static void kick_off_tests(const SkTDArray<TestRegistry::Factory>& tests, | 166 static void kick_off_tests(const SkTDArray<TestRegistry::Factory>& tests, |
| 158 DM::Reporter* reporter, | 167 DM::Reporter* reporter, |
| 159 DM::TaskRunner* tasks) { | 168 DM::TaskRunner* tasks) { |
| 160 for (int i = 0; i < tests.count(); i++) { | 169 for (int i = 0; i < tests.count(); i++) { |
| 161 SkAutoTDelete<Test> test(tests[i](NULL)); | 170 SkAutoTDelete<Test> test(tests[i](NULL)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 return; | 210 return; |
| 202 } | 211 } |
| 203 | 212 |
| 204 SkDebugf("Failures:\n"); | 213 SkDebugf("Failures:\n"); |
| 205 for (int i = 0; i < failures.count(); i++) { | 214 for (int i = 0; i < failures.count(); i++) { |
| 206 SkDebugf(" %s\n", failures[i].c_str()); | 215 SkDebugf(" %s\n", failures[i].c_str()); |
| 207 } | 216 } |
| 208 SkDebugf("%d failures.\n", failures.count()); | 217 SkDebugf("%d failures.\n", failures.count()); |
| 209 } | 218 } |
| 210 | 219 |
| 220 static void get_forced_gpu_api_if_matches(GrGLStandard* forcedGpuApi) { | |
|
mtklein
2014/06/09 14:10:45
Simplify?
static GrGLStandard get_gl_standard() {
Kimmo Kinnunen
2014/06/16 12:36:39
Done.
| |
| 221 if (1 == FLAGS_forceGpuApi.count()) { | |
| 222 if (strcmp(FLAGS_forceGpuApi[0], kGpuApiNameGL) == 0) { | |
| 223 *forcedGpuApi = kGL_GrGLStandard; | |
| 224 return; | |
| 225 } else if (strcmp(FLAGS_forceGpuApi[0], kGpuApiNameGLES) == 0) { | |
| 226 *forcedGpuApi = kGLES_GrGLStandard; | |
| 227 return; | |
| 228 } | |
| 229 } | |
| 230 *forcedGpuApi = kNone_GrGLStandard; | |
|
mtklein
2014/06/09 14:10:45
What happens if I run DM in None mode? Does that
Kimmo Kinnunen
2014/06/16 12:36:39
Yeah. None picks up the default for the platform.
| |
| 231 } | |
| 232 | |
| 211 template <typename T, typename Registry> | 233 template <typename T, typename Registry> |
| 212 static void append_matching_factories(Registry* head, SkTDArray<typename Registr y::Factory>* out) { | 234 static void append_matching_factories(Registry* head, SkTDArray<typename Registr y::Factory>* out) { |
| 213 for (const Registry* reg = head; reg != NULL; reg = reg->next()) { | 235 for (const Registry* reg = head; reg != NULL; reg = reg->next()) { |
| 214 SkAutoTDelete<T> forName(reg->factory()(NULL)); | 236 SkAutoTDelete<T> forName(reg->factory()(NULL)); |
| 215 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, forName->getName())) { | 237 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, forName->getName())) { |
| 216 *out->append() = reg->factory(); | 238 *out->append() = reg->factory(); |
| 217 } | 239 } |
| 218 } | 240 } |
| 219 } | 241 } |
| 220 | 242 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 231 #endif | 253 #endif |
| 232 GM::SetResourcePath(FLAGS_resources[0]); | 254 GM::SetResourcePath(FLAGS_resources[0]); |
| 233 SkBenchmark::SetResourcePath(FLAGS_resources[0]); | 255 SkBenchmark::SetResourcePath(FLAGS_resources[0]); |
| 234 Test::SetResourcePath(FLAGS_resources[0]); | 256 Test::SetResourcePath(FLAGS_resources[0]); |
| 235 | 257 |
| 236 SkTArray<SkString> configs; | 258 SkTArray<SkString> configs; |
| 237 for (int i = 0; i < FLAGS_config.count(); i++) { | 259 for (int i = 0; i < FLAGS_config.count(); i++) { |
| 238 SkStrSplit(FLAGS_config[i], ", ", &configs); | 260 SkStrSplit(FLAGS_config[i], ", ", &configs); |
| 239 } | 261 } |
| 240 | 262 |
| 263 GrGLStandard forcedGpuApi = kNone_GrGLStandard; | |
| 264 get_forced_gpu_api_if_matches(&forcedGpuApi); | |
| 265 | |
| 241 SkTDArray<GMRegistry::Factory> gms; | 266 SkTDArray<GMRegistry::Factory> gms; |
| 242 SkAutoTDelete<DM::Expectations> expectations(SkNEW(DM::NoExpectations)); | 267 SkAutoTDelete<DM::Expectations> expectations(SkNEW(DM::NoExpectations)); |
| 243 if (FLAGS_gms) { | 268 if (FLAGS_gms) { |
| 244 append_matching_factories<GM>(GMRegistry::Head(), &gms); | 269 append_matching_factories<GM>(GMRegistry::Head(), &gms); |
| 245 | 270 |
| 246 if (FLAGS_expectations.count() > 0) { | 271 if (FLAGS_expectations.count() > 0) { |
| 247 const char* path = FLAGS_expectations[0]; | 272 const char* path = FLAGS_expectations[0]; |
| 248 if (sk_isdir(path)) { | 273 if (sk_isdir(path)) { |
| 249 expectations.reset(SkNEW_ARGS(DM::WriteTask::Expectations, (path ))); | 274 expectations.reset(SkNEW_ARGS(DM::WriteTask::Expectations, (path ))); |
| 250 } else { | 275 } else { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 262 | 287 |
| 263 SkTDArray<TestRegistry::Factory> tests; | 288 SkTDArray<TestRegistry::Factory> tests; |
| 264 if (FLAGS_tests) { | 289 if (FLAGS_tests) { |
| 265 append_matching_factories<Test>(TestRegistry::Head(), &tests); | 290 append_matching_factories<Test>(TestRegistry::Head(), &tests); |
| 266 } | 291 } |
| 267 | 292 |
| 268 SkDebugf("(%d GMs, %d benches) x %d configs, %d tests\n", | 293 SkDebugf("(%d GMs, %d benches) x %d configs, %d tests\n", |
| 269 gms.count(), benches.count(), configs.count(), tests.count()); | 294 gms.count(), benches.count(), configs.count(), tests.count()); |
| 270 DM::Reporter reporter; | 295 DM::Reporter reporter; |
| 271 DM::TaskRunner tasks(FLAGS_threads, FLAGS_gpuThreads); | 296 DM::TaskRunner tasks(FLAGS_threads, FLAGS_gpuThreads); |
| 272 kick_off_gms(gms, configs, *expectations, &reporter, &tasks); | 297 kick_off_gms(gms, configs, forcedGpuApi, *expectations, &reporter, &tasks); |
|
mtklein
2014/06/09 14:10:45
e.g. could we logically just loop over GPU APIs he
Kimmo Kinnunen
2014/06/16 12:36:39
IIUC from the discussion above, this was not neede
bsalomon
2014/06/16 14:25:10
+1 for leaving any running of multiple APIs in a s
| |
| 273 kick_off_benches(benches, configs, &reporter, &tasks); | 298 kick_off_benches(benches, configs, forcedGpuApi, &reporter, &tasks); |
| 274 kick_off_tests(tests, &reporter, &tasks); | 299 kick_off_tests(tests, &reporter, &tasks); |
| 275 kick_off_skps(&reporter, &tasks); | 300 kick_off_skps(&reporter, &tasks); |
| 276 tasks.wait(); | 301 tasks.wait(); |
| 277 | 302 |
| 278 SkDebugf("\n"); | 303 SkDebugf("\n"); |
| 279 | 304 |
| 280 SkTArray<SkString> failures; | 305 SkTArray<SkString> failures; |
| 281 reporter.getFailures(&failures); | 306 reporter.getFailures(&failures); |
| 282 report_failures(failures); | 307 report_failures(failures); |
| 283 return failures.count() > 0; | 308 return failures.count() > 0; |
| 284 } | 309 } |
| 285 | 310 |
| 286 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 311 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 287 int main(int argc, char** argv) { | 312 int main(int argc, char** argv) { |
| 288 return tool_main(argc, argv); | 313 return tool_main(argc, argv); |
| 289 } | 314 } |
| 290 #endif | 315 #endif |
| OLD | NEW |