Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: dm/DM.cpp

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

Powered by Google App Engine
This is Rietveld 408576698