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

Side by Side Diff: dm/DM.cpp

Issue 179233005: DM: make GPU tasks multithreaded again. Big refactor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: default 1 GPU thread Created 6 years, 9 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
« no previous file with comments | « no previous file | dm/DMBenchTask.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "GrContext.h" 4 #include "GrContext.h"
5 #include "GrContextFactory.h" 5 #include "GrContextFactory.h"
6 #include "SkBenchmark.h" 6 #include "SkBenchmark.h"
7 #include "SkCommandLineFlags.h" 7 #include "SkCommandLineFlags.h"
8 #include "SkForceLinking.h" 8 #include "SkForceLinking.h"
9 #include "SkGraphics.h" 9 #include "SkGraphics.h"
10 #include "SkString.h" 10 #include "SkString.h"
11 #include "Test.h" 11 #include "Test.h"
12 #include "gm.h" 12 #include "gm.h"
13 13
14 #include "DMBenchTask.h" 14 #include "DMBenchTask.h"
15 #include "DMCpuTask.h" 15 #include "DMCpuGMTask.h"
16 #include "DMGpuTask.h" 16 #include "DMGpuGMTask.h"
17 #include "DMReporter.h" 17 #include "DMReporter.h"
18 #include "DMTask.h" 18 #include "DMTask.h"
19 #include "DMTaskRunner.h" 19 #include "DMTaskRunner.h"
20 #include "DMTestTask.h" 20 #include "DMTestTask.h"
21 #include "DMWriteTask.h" 21 #include "DMWriteTask.h"
22 22
23 #include <string.h> 23 #include <string.h>
24 24
25 using skiagm::GM; 25 using skiagm::GM;
26 using skiagm::GMRegistry; 26 using skiagm::GMRegistry;
27 using skiatest::Test; 27 using skiatest::Test;
28 using skiatest::TestRegistry; 28 using skiatest::TestRegistry;
29 29
30 DEFINE_int32(threads, -1, "Threads for CPU work. Default NUM_CPUS."); 30 DEFINE_int32(threads, -1, "Threads for CPU work. Default NUM_CPUS.");
31 DEFINE_int32(gpuThreads, 1, "Threads for GPU work.");
31 DEFINE_string2(expectations, r, "", 32 DEFINE_string2(expectations, r, "",
32 "If a directory, compare generated images against images under th is path. " 33 "If a directory, compare generated images against images under th is path. "
33 "If a file, compare generated images against JSON expectations at this path."); 34 "If a file, compare generated images against JSON expectations at this path.");
34 DEFINE_string2(resources, i, "resources", "Path to resources directory."); 35 DEFINE_string2(resources, i, "resources", "Path to resources directory.");
35 DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n" 36 DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n"
36 "Multiple matches may be separated by spaces.\n" 37 "Multiple matches may be separated by spaces.\n"
37 "~ causes a matching GM to always be skipped\n" 38 "~ causes a matching GM to always be skipped\n"
38 "^ requires the start of the GM to match\n" 39 "^ requires the start of the GM to match\n"
39 "$ requires the end of the GM to match\n" 40 "$ requires the end of the GM to match\n"
40 "^ and $ requires an exact match\n" 41 "^ and $ requires an exact match\n"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 const DM::Expectations& expectations, 80 const DM::Expectations& expectations,
80 DM::Reporter* reporter, 81 DM::Reporter* reporter,
81 DM::TaskRunner* tasks) { 82 DM::TaskRunner* tasks) {
82 #define START(name, type, ...) \ 83 #define START(name, type, ...) \
83 if (lowercase(configs[j]).equals(name)) { \ 84 if (lowercase(configs[j]).equals(name)) { \
84 tasks->add(SkNEW_ARGS(DM::type, \ 85 tasks->add(SkNEW_ARGS(DM::type, \
85 (name, reporter, tasks, expectations, gms[i], ## __VA_ARGS__ ))); \ 86 (name, reporter, tasks, expectations, gms[i], ## __VA_ARGS__ ))); \
86 } 87 }
87 for (int i = 0; i < gms.count(); i++) { 88 for (int i = 0; i < gms.count(); i++) {
88 for (int j = 0; j < configs.count(); j++) { 89 for (int j = 0; j < configs.count(); j++) {
89 START("565", CpuTask, kRGB_565_SkColorType); 90 START("565", CpuGMTask, kRGB_565_SkColorType);
90 START("8888", CpuTask, kPMColor_SkColorType); 91 START("8888", CpuGMTask, kPMColor_SkColorType);
91 START("gpu", GpuTask, native, 0); 92 START("gpu", GpuGMTask, native, 0);
92 START("msaa4", GpuTask, native, 4); 93 START("msaa4", GpuGMTask, native, 4);
93 START("msaa16", GpuTask, native, 16); 94 START("msaa16", GpuGMTask, native, 16);
94 START("gpunull", GpuTask, null, 0); 95 START("gpunull", GpuGMTask, null, 0);
95 START("gpudebug", GpuTask, debug, 0); 96 START("gpudebug", GpuGMTask, debug, 0);
96 START("angle", GpuTask, angle, 0); 97 START("angle", GpuGMTask, angle, 0);
97 START("mesa", GpuTask, mesa, 0); 98 START("mesa", GpuGMTask, mesa, 0);
98 } 99 }
99 } 100 }
100 #undef START 101 #undef START
101 } 102 }
102 103
103 static void kick_off_benches(const SkTDArray<BenchRegistry::Factory>& benches, 104 static void kick_off_benches(const SkTDArray<BenchRegistry::Factory>& benches,
104 const SkTArray<SkString>& configs, 105 const SkTArray<SkString>& configs,
105 DM::Reporter* reporter, 106 DM::Reporter* reporter,
106 DM::TaskRunner* tasks) { 107 DM::TaskRunner* tasks) {
107 #define START(name, type, ...) \ 108 #define START(name, type, ...) \
(...skipping 14 matching lines...) Expand all
122 START("mesa", GpuBenchTask, mesa, 0); 123 START("mesa", GpuBenchTask, mesa, 0);
123 } 124 }
124 } 125 }
125 #undef START 126 #undef START
126 } 127 }
127 128
128 static void kick_off_tests(const SkTDArray<TestRegistry::Factory>& tests, 129 static void kick_off_tests(const SkTDArray<TestRegistry::Factory>& tests,
129 DM::Reporter* reporter, 130 DM::Reporter* reporter,
130 DM::TaskRunner* tasks) { 131 DM::TaskRunner* tasks) {
131 for (int i = 0; i < tests.count(); i++) { 132 for (int i = 0; i < tests.count(); i++) {
132 tasks->add(SkNEW_ARGS(DM::TestTask, (reporter, tasks, tests[i]))); 133 SkAutoTDelete<Test> test(tests[i](NULL));
134 if (test->isGPUTest()) {
135 tasks->add(SkNEW_ARGS(DM::GpuTestTask, (reporter, tasks, tests[i]))) ;
136 } else {
137 tasks->add(SkNEW_ARGS(DM::CpuTestTask, (reporter, tasks, tests[i]))) ;
138 }
133 } 139 }
134 } 140 }
135 141
136 static void report_failures(const DM::Reporter& reporter) { 142 static void report_failures(const DM::Reporter& reporter) {
137 SkTArray<SkString> failures; 143 SkTArray<SkString> failures;
138 reporter.getFailures(&failures); 144 reporter.getFailures(&failures);
139 145
140 if (failures.count() == 0) { 146 if (failures.count() == 0) {
141 return; 147 return;
142 } 148 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 200 }
195 201
196 SkTDArray<TestRegistry::Factory> tests; 202 SkTDArray<TestRegistry::Factory> tests;
197 if (FLAGS_tests) { 203 if (FLAGS_tests) {
198 append_matching_factories<Test>(TestRegistry::Head(), &tests); 204 append_matching_factories<Test>(TestRegistry::Head(), &tests);
199 } 205 }
200 206
201 SkDebugf("(%d GMs, %d benches) x %d configs, %d tests\n", 207 SkDebugf("(%d GMs, %d benches) x %d configs, %d tests\n",
202 gms.count(), benches.count(), configs.count(), tests.count()); 208 gms.count(), benches.count(), configs.count(), tests.count());
203 DM::Reporter reporter; 209 DM::Reporter reporter;
204 DM::TaskRunner tasks(FLAGS_threads); 210 DM::TaskRunner tasks(FLAGS_threads, FLAGS_gpuThreads);
205 kick_off_gms(gms, configs, *expectations, &reporter, &tasks); 211 kick_off_gms(gms, configs, *expectations, &reporter, &tasks);
206 kick_off_benches(benches, configs, &reporter, &tasks); 212 kick_off_benches(benches, configs, &reporter, &tasks);
207 kick_off_tests(tests, &reporter, &tasks); 213 kick_off_tests(tests, &reporter, &tasks);
208 tasks.wait(); 214 tasks.wait();
209 215
210 SkDebugf("\n"); 216 SkDebugf("\n");
211 report_failures(reporter); 217 report_failures(reporter);
212 218
213 SkGraphics::Term(); 219 SkGraphics::Term();
214 220
215 return reporter.failed() > 0; 221 return reporter.failed() > 0;
216 } 222 }
217 223
218 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 224 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
219 int main(int argc, char** argv) { 225 int main(int argc, char** argv) {
220 return tool_main(argc, argv); 226 return tool_main(argc, argv);
221 } 227 }
222 #endif 228 #endif
OLDNEW
« no previous file with comments | « no previous file | dm/DMBenchTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698