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 "Benchmark.h" | 4 #include "Benchmark.h" |
5 #include "CrashHandler.h" | 5 #include "CrashHandler.h" |
6 #include "SkCommandLineFlags.h" | 6 #include "SkCommandLineFlags.h" |
7 #include "SkForceLinking.h" | 7 #include "SkForceLinking.h" |
8 #include "SkGraphics.h" | 8 #include "SkGraphics.h" |
9 #include "SkPicture.h" | 9 #include "SkPicture.h" |
10 #include "SkString.h" | 10 #include "SkString.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 # define RASTERIZE_PDF_PROC NULL | 30 # define RASTERIZE_PDF_PROC NULL |
31 #endif | 31 #endif |
32 | 32 |
33 #include <ctype.h> | 33 #include <ctype.h> |
34 | 34 |
35 using skiagm::GM; | 35 using skiagm::GM; |
36 using skiagm::GMRegistry; | 36 using skiagm::GMRegistry; |
37 using skiatest::Test; | 37 using skiatest::Test; |
38 using skiatest::TestRegistry; | 38 using skiatest::TestRegistry; |
39 | 39 |
40 static const char kGpuAPINameGL[] = "gl"; | |
41 static const char kGpuAPINameGLES[] = "gles"; | |
42 | |
43 DEFINE_int32(threads, -1, "Threads for CPU work. Default NUM_CPUS."); | 40 DEFINE_int32(threads, -1, "Threads for CPU work. Default NUM_CPUS."); |
44 DEFINE_int32(gpuThreads, 1, "Threads for GPU work."); | 41 DEFINE_int32(gpuThreads, 1, "Threads for GPU work."); |
45 DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" " | |
46 "forces OpenGL API. Using \"gles\" forces OpenGL ES API. " | |
47 "Defaults to empty string, which selects the API native to the " | |
48 "system."); | |
49 DEFINE_string2(expectations, r, "", | 42 DEFINE_string2(expectations, r, "", |
50 "If a directory, compare generated images against images under th
is path. " | 43 "If a directory, compare generated images against images under th
is path. " |
51 "If a file, compare generated images against JSON expectations at
this path." | 44 "If a file, compare generated images against JSON expectations at
this path." |
52 ); | 45 ); |
53 DEFINE_string2(resources, i, "resources", "Path to resources directory."); | 46 DEFINE_string2(resources, i, "resources", "Path to resources directory."); |
54 DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n" | 47 DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n" |
55 "Multiple matches may be separated by spaces.\n" | 48 "Multiple matches may be separated by spaces.\n" |
56 "~ causes a matching GM to always be skipped\n" | 49 "~ causes a matching GM to always be skipped\n" |
57 "^ requires the start of the GM to match\n" | 50 "^ requires the start of the GM to match\n" |
58 "$ requires the end of the GM to match\n" | 51 "$ requires the end of the GM to match\n" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 #endif | 88 #endif |
96 static const GrContextFactory::GLContextType mesa = | 89 static const GrContextFactory::GLContextType mesa = |
97 #if SK_MESA | 90 #if SK_MESA |
98 GrContextFactory::kMESA_GLContextType; | 91 GrContextFactory::kMESA_GLContextType; |
99 #else | 92 #else |
100 native; | 93 native; |
101 #endif | 94 #endif |
102 | 95 |
103 static void kick_off_gms(const SkTDArray<GMRegistry::Factory>& gms, | 96 static void kick_off_gms(const SkTDArray<GMRegistry::Factory>& gms, |
104 const SkTArray<SkString>& configs, | 97 const SkTArray<SkString>& configs, |
105 GrGLStandard gpuAPI, | |
106 const DM::Expectations& expectations, | 98 const DM::Expectations& expectations, |
107 DM::Reporter* reporter, | 99 DM::Reporter* reporter, |
108 DM::TaskRunner* tasks) { | 100 DM::TaskRunner* tasks) { |
109 #define START(name, type, ...)
\ | 101 #define START(name, type, ...)
\ |
110 if (lowercase(configs[j]).equals(name)) {
\ | 102 if (lowercase(configs[j]).equals(name)) {
\ |
111 tasks->add(SkNEW_ARGS(DM::type, (name, reporter, tasks, gms[i], ## __VA_
ARGS__))); \ | 103 tasks->add(SkNEW_ARGS(DM::type, (name, reporter, tasks, gms[i], ## __VA_
ARGS__))); \ |
112 } | 104 } |
113 for (int i = 0; i < gms.count(); i++) { | 105 for (int i = 0; i < gms.count(); i++) { |
114 for (int j = 0; j < configs.count(); j++) { | 106 for (int j = 0; j < configs.count(); j++) { |
115 | |
116 START("565", CpuGMTask, expectations, kRGB_565_SkColorType); | 107 START("565", CpuGMTask, expectations, kRGB_565_SkColorType); |
117 START("8888", CpuGMTask, expectations, kN32_SkColorType); | 108 START("8888", CpuGMTask, expectations, kN32_SkColorType); |
118 START("gpu", GpuGMTask, expectations, native, gpuAPI, 0); | 109 START("gpu", GpuGMTask, expectations, native, 0); |
119 START("msaa4", GpuGMTask, expectations, native, gpuAPI, 4); | 110 START("msaa4", GpuGMTask, expectations, native, 4); |
120 START("msaa16", GpuGMTask, expectations, native, gpuAPI, 16); | 111 START("msaa16", GpuGMTask, expectations, native, 16); |
121 START("nvprmsaa4", GpuGMTask, expectations, nvpr, gpuAPI, 4); | 112 START("nvprmsaa4", GpuGMTask, expectations, nvpr, 4); |
122 START("nvprmsaa16", GpuGMTask, expectations, nvpr, gpuAPI, 16); | 113 START("nvprmsaa16", GpuGMTask, expectations, nvpr, 16); |
123 START("gpunull", GpuGMTask, expectations, null, gpuAPI, 0); | 114 START("gpunull", GpuGMTask, expectations, null, 0); |
124 START("gpudebug", GpuGMTask, expectations, debug, gpuAPI, 0); | 115 START("gpudebug", GpuGMTask, expectations, debug, 0); |
125 START("angle", GpuGMTask, expectations, angle, gpuAPI, 0); | 116 START("angle", GpuGMTask, expectations, angle, 0); |
126 START("mesa", GpuGMTask, expectations, mesa, gpuAPI, 0); | 117 START("mesa", GpuGMTask, expectations, mesa, 0); |
127 START("pdf", PDFTask, RASTERIZE_PDF_PROC); | 118 START("pdf", PDFTask, RASTERIZE_PDF_PROC); |
128 } | 119 } |
129 } | 120 } |
130 #undef START | 121 #undef START |
131 } | 122 } |
132 | 123 |
133 static void kick_off_benches(const SkTDArray<BenchRegistry::Factory>& benches, | 124 static void kick_off_benches(const SkTDArray<BenchRegistry::Factory>& benches, |
134 const SkTArray<SkString>& configs, | 125 const SkTArray<SkString>& configs, |
135 GrGLStandard gpuAPI, | |
136 DM::Reporter* reporter, | 126 DM::Reporter* reporter, |
137 DM::TaskRunner* tasks) { | 127 DM::TaskRunner* tasks) { |
138 #define START(name, type, ...)
\ | 128 #define START(name, type, ...)
\ |
139 if (lowercase(configs[j]).equals(name)) {
\ | 129 if (lowercase(configs[j]).equals(name)) {
\ |
140 tasks->add(SkNEW_ARGS(DM::type, (name, reporter, tasks, benches[i], ## _
_VA_ARGS__))); \ | 130 tasks->add(SkNEW_ARGS(DM::type, (name, reporter, tasks, benches[i], ## _
_VA_ARGS__))); \ |
141 } | 131 } |
142 for (int i = 0; i < benches.count(); i++) { | 132 for (int i = 0; i < benches.count(); i++) { |
143 for (int j = 0; j < configs.count(); j++) { | 133 for (int j = 0; j < configs.count(); j++) { |
144 START("nonrendering", NonRenderingBenchTask); | 134 START("nonrendering", NonRenderingBenchTask); |
145 START("565", CpuBenchTask, kRGB_565_SkColorType); | 135 START("565", CpuBenchTask, kRGB_565_SkColorType); |
146 START("8888", CpuBenchTask, kN32_SkColorType); | 136 START("8888", CpuBenchTask, kN32_SkColorType); |
147 START("gpu", GpuBenchTask, native, gpuAPI, 0); | 137 START("gpu", GpuBenchTask, native, 0); |
148 START("msaa4", GpuBenchTask, native, gpuAPI, 4); | 138 START("msaa4", GpuBenchTask, native, 4); |
149 START("msaa16", GpuBenchTask, native, gpuAPI, 16); | 139 START("msaa16", GpuBenchTask, native, 16); |
150 START("nvprmsaa4", GpuBenchTask, nvpr, gpuAPI, 4); | 140 START("nvprmsaa4", GpuBenchTask, nvpr, 4); |
151 START("nvprmsaa16", GpuBenchTask, nvpr, gpuAPI, 16); | 141 START("nvprmsaa16", GpuBenchTask, nvpr, 16); |
152 START("gpunull", GpuBenchTask, null, gpuAPI, 0); | 142 START("gpunull", GpuBenchTask, null, 0); |
153 START("gpudebug", GpuBenchTask, debug, gpuAPI, 0); | 143 START("gpudebug", GpuBenchTask, debug, 0); |
154 START("angle", GpuBenchTask, angle, gpuAPI, 0); | 144 START("angle", GpuBenchTask, angle, 0); |
155 START("mesa", GpuBenchTask, mesa, gpuAPI, 0); | 145 START("mesa", GpuBenchTask, mesa, 0); |
156 } | 146 } |
157 } | 147 } |
158 #undef START | 148 #undef START |
159 } | 149 } |
160 | 150 |
161 static void kick_off_tests(const SkTDArray<TestRegistry::Factory>& tests, | 151 static void kick_off_tests(const SkTDArray<TestRegistry::Factory>& tests, |
162 DM::Reporter* reporter, | 152 DM::Reporter* reporter, |
163 DM::TaskRunner* tasks) { | 153 DM::TaskRunner* tasks) { |
164 for (int i = 0; i < tests.count(); i++) { | 154 for (int i = 0; i < tests.count(); i++) { |
165 SkAutoTDelete<Test> test(tests[i](NULL)); | 155 SkAutoTDelete<Test> test(tests[i](NULL)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 return; | 197 return; |
208 } | 198 } |
209 | 199 |
210 SkDebugf("Failures:\n"); | 200 SkDebugf("Failures:\n"); |
211 for (int i = 0; i < failures.count(); i++) { | 201 for (int i = 0; i < failures.count(); i++) { |
212 SkDebugf(" %s\n", failures[i].c_str()); | 202 SkDebugf(" %s\n", failures[i].c_str()); |
213 } | 203 } |
214 SkDebugf("%d failures.\n", failures.count()); | 204 SkDebugf("%d failures.\n", failures.count()); |
215 } | 205 } |
216 | 206 |
217 static GrGLStandard get_gl_standard() { | |
218 if (FLAGS_gpuAPI.contains(kGpuAPINameGL)) { | |
219 return kGL_GrGLStandard; | |
220 } | |
221 if (FLAGS_gpuAPI.contains(kGpuAPINameGLES)) { | |
222 return kGLES_GrGLStandard; | |
223 } | |
224 return kNone_GrGLStandard; | |
225 } | |
226 | |
227 template <typename T, typename Registry> | 207 template <typename T, typename Registry> |
228 static void append_matching_factories(Registry* head, SkTDArray<typename Registr
y::Factory>* out) { | 208 static void append_matching_factories(Registry* head, SkTDArray<typename Registr
y::Factory>* out) { |
229 for (const Registry* reg = head; reg != NULL; reg = reg->next()) { | 209 for (const Registry* reg = head; reg != NULL; reg = reg->next()) { |
230 SkAutoTDelete<T> forName(reg->factory()(NULL)); | 210 SkAutoTDelete<T> forName(reg->factory()(NULL)); |
231 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, forName->getName())) { | 211 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, forName->getName())) { |
232 *out->append() = reg->factory(); | 212 *out->append() = reg->factory(); |
233 } | 213 } |
234 } | 214 } |
235 } | 215 } |
236 | 216 |
237 int tool_main(int argc, char** argv); | 217 int tool_main(int argc, char** argv); |
238 int tool_main(int argc, char** argv) { | 218 int tool_main(int argc, char** argv) { |
239 SetupCrashHandler(); | 219 SetupCrashHandler(); |
240 SkAutoGraphics ag; | 220 SkAutoGraphics ag; |
241 SkCommandLineFlags::Parse(argc, argv); | 221 SkCommandLineFlags::Parse(argc, argv); |
242 | 222 |
243 if (FLAGS_dryRun) { | 223 if (FLAGS_dryRun) { |
244 FLAGS_verbose = true; | 224 FLAGS_verbose = true; |
245 } | 225 } |
246 #if SK_ENABLE_INST_COUNT | 226 #if SK_ENABLE_INST_COUNT |
247 gPrintInstCount = FLAGS_leaks; | 227 gPrintInstCount = FLAGS_leaks; |
248 #endif | 228 #endif |
249 | 229 |
250 SkTArray<SkString> configs; | 230 SkTArray<SkString> configs; |
251 for (int i = 0; i < FLAGS_config.count(); i++) { | 231 for (int i = 0; i < FLAGS_config.count(); i++) { |
252 SkStrSplit(FLAGS_config[i], ", ", &configs); | 232 SkStrSplit(FLAGS_config[i], ", ", &configs); |
253 } | 233 } |
254 | 234 |
255 GrGLStandard gpuAPI = get_gl_standard(); | |
256 | |
257 SkTDArray<GMRegistry::Factory> gms; | 235 SkTDArray<GMRegistry::Factory> gms; |
258 SkAutoTDelete<DM::Expectations> expectations(SkNEW(DM::NoExpectations)); | 236 SkAutoTDelete<DM::Expectations> expectations(SkNEW(DM::NoExpectations)); |
259 if (FLAGS_gms) { | 237 if (FLAGS_gms) { |
260 append_matching_factories<GM>(GMRegistry::Head(), &gms); | 238 append_matching_factories<GM>(GMRegistry::Head(), &gms); |
261 | 239 |
262 if (FLAGS_expectations.count() > 0) { | 240 if (FLAGS_expectations.count() > 0) { |
263 const char* path = FLAGS_expectations[0]; | 241 const char* path = FLAGS_expectations[0]; |
264 if (sk_isdir(path)) { | 242 if (sk_isdir(path)) { |
265 expectations.reset(SkNEW_ARGS(DM::WriteTask::Expectations, (path
))); | 243 expectations.reset(SkNEW_ARGS(DM::WriteTask::Expectations, (path
))); |
266 } else { | 244 } else { |
267 expectations.reset(SkNEW_ARGS(DM::JsonExpectations, (path))); | 245 expectations.reset(SkNEW_ARGS(DM::JsonExpectations, (path))); |
268 } | 246 } |
269 } | 247 } |
270 } | 248 } |
271 | 249 |
272 SkTDArray<BenchRegistry::Factory> benches; | 250 SkTDArray<BenchRegistry::Factory> benches; |
273 if (FLAGS_benches) { | 251 if (FLAGS_benches) { |
274 append_matching_factories<Benchmark>(BenchRegistry::Head(), &benches); | 252 append_matching_factories<Benchmark>(BenchRegistry::Head(), &benches); |
275 } | 253 } |
276 | 254 |
277 SkTDArray<TestRegistry::Factory> tests; | 255 SkTDArray<TestRegistry::Factory> tests; |
278 if (FLAGS_tests) { | 256 if (FLAGS_tests) { |
279 append_matching_factories<Test>(TestRegistry::Head(), &tests); | 257 append_matching_factories<Test>(TestRegistry::Head(), &tests); |
280 } | 258 } |
281 | 259 |
282 SkDebugf("(%d GMs, %d benches) x %d configs, %d tests\n", | 260 SkDebugf("(%d GMs, %d benches) x %d configs, %d tests\n", |
283 gms.count(), benches.count(), configs.count(), tests.count()); | 261 gms.count(), benches.count(), configs.count(), tests.count()); |
284 DM::Reporter reporter; | 262 DM::Reporter reporter; |
285 DM::TaskRunner tasks(FLAGS_threads, FLAGS_gpuThreads); | 263 DM::TaskRunner tasks(FLAGS_threads, FLAGS_gpuThreads); |
286 kick_off_gms(gms, configs, gpuAPI, *expectations, &reporter, &tasks); | 264 kick_off_gms(gms, configs, *expectations, &reporter, &tasks); |
287 kick_off_benches(benches, configs, gpuAPI, &reporter, &tasks); | 265 kick_off_benches(benches, configs, &reporter, &tasks); |
288 kick_off_tests(tests, &reporter, &tasks); | 266 kick_off_tests(tests, &reporter, &tasks); |
289 kick_off_skps(&reporter, &tasks); | 267 kick_off_skps(&reporter, &tasks); |
290 tasks.wait(); | 268 tasks.wait(); |
291 | 269 |
292 SkDebugf("\n"); | 270 SkDebugf("\n"); |
293 | 271 |
294 SkTArray<SkString> failures; | 272 SkTArray<SkString> failures; |
295 reporter.getFailures(&failures); | 273 reporter.getFailures(&failures); |
296 report_failures(failures); | 274 report_failures(failures); |
297 return failures.count() > 0; | 275 return failures.count() > 0; |
298 } | 276 } |
299 | 277 |
300 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 278 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
301 int main(int argc, char** argv) { | 279 int main(int argc, char** argv) { |
302 return tool_main(argc, argv); | 280 return tool_main(argc, argv); |
303 } | 281 } |
304 #endif | 282 #endif |
OLD | NEW |