blob: 2694a75c1589f0103b2fc0030bd3830ec889e919 [file] [log] [blame]
Chris Dalton7f0b8972020-04-23 15:52:24 -06001/*
2 * Copyright 2020 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "bench/Benchmark.h"
Robert Phillipsf0288102020-07-06 13:45:34 -04009#include "include/gpu/GrDirectContext.h"
Chris Daltonf6bf5162020-05-13 19:18:46 -060010#include "src/core/SkPathPriv.h"
Chris Dalton8447f132021-05-21 15:54:23 -060011#include "src/core/SkRectPriv.h"
Adlai Hollera0693042020-10-14 11:23:11 -040012#include "src/gpu/GrDirectContextPriv.h"
Chris Dalton7f0b8972020-04-23 15:52:24 -060013#include "src/gpu/GrOpFlushState.h"
Michael Ludwig4e9d5e22021-05-11 10:00:12 -040014#include "src/gpu/geometry/GrWangsFormula.h"
Chris Dalton90ad0fe2020-11-09 14:13:39 -070015#include "src/gpu/mock/GrMockOpTarget.h"
Chris Daltonb5391d92020-05-24 14:55:54 -060016#include "src/gpu/tessellate/GrMiddleOutPolygonTriangulator.h"
Chris Daltond9bdc322021-06-01 19:22:05 -060017#include "src/gpu/tessellate/GrPathCurveTessellator.h"
Chris Daltond9bdc322021-06-01 19:22:05 -060018#include "src/gpu/tessellate/GrPathWedgeTessellator.h"
Chris Dalton82007f52021-04-20 00:45:50 -060019#include "src/gpu/tessellate/GrStrokeFixedCountTessellator.h"
Chris Dalton22241002021-02-04 09:47:40 -070020#include "src/gpu/tessellate/GrStrokeHardwareTessellator.h"
Chris Daltonf5132a02020-04-27 23:40:03 -060021#include "tools/ToolUtils.h"
Chris Daltonc2a17462020-12-09 16:46:22 -070022#include <vector>
Chris Dalton7f0b8972020-04-23 15:52:24 -060023
Chris Dalton3b412782021-06-01 13:40:03 -060024using ShaderFlags = GrStrokeTessellationShader::ShaderFlags;
Chris Dalton42582fc2021-02-18 11:29:49 -070025
Chris Dalton7f0b8972020-04-23 15:52:24 -060026// This is the number of cubics in desk_chalkboard.skp. (There are no quadratics in the chalkboard.)
27constexpr static int kNumCubicsInChalkboard = 47182;
28
Chris Dalton90ad0fe2020-11-09 14:13:39 -070029static sk_sp<GrDirectContext> make_mock_context() {
30 GrMockOptions mockOptions;
31 mockOptions.fDrawInstancedSupport = true;
32 mockOptions.fMaxTessellationSegments = 64;
33 mockOptions.fMapBufferFlags = GrCaps::kCanMap_MapFlag;
34 mockOptions.fConfigOptions[(int)GrColorType::kAlpha_8].fRenderability =
35 GrMockOptions::ConfigOptions::Renderability::kMSAA;
36 mockOptions.fConfigOptions[(int)GrColorType::kAlpha_8].fTexturable = true;
37 mockOptions.fIntegerSupport = true;
38
39 GrContextOptions ctxOptions;
40 ctxOptions.fGpuPathRenderers = GpuPathRenderers::kTessellation;
Chris Dalton4ac9aad2021-02-24 17:41:44 -070041 ctxOptions.fEnableExperimentalHardwareTessellation = true;
Chris Dalton90ad0fe2020-11-09 14:13:39 -070042
43 return GrDirectContext::MakeMock(&mockOptions, ctxOptions);
44}
45
Chris Dalton8447f132021-05-21 15:54:23 -060046static SkPath make_cubic_path(int maxPow2) {
Chris Dalton7f0b8972020-04-23 15:52:24 -060047 SkRandom rand;
48 SkPath path;
49 for (int i = 0; i < kNumCubicsInChalkboard/2; ++i) {
Chris Dalton8447f132021-05-21 15:54:23 -060050 float x = std::ldexp(rand.nextF(), (i % maxPow2)) / 1e3f;
Chris Dalton7f0b8972020-04-23 15:52:24 -060051 path.cubicTo(111.625f*x, 308.188f*x, 764.62f*x, -435.688f*x, 742.63f*x, 85.187f*x);
52 path.cubicTo(764.62f*x, -435.688f*x, 111.625f*x, 308.188f*x, 0, 0);
53 }
54 return path;
55}
56
Tyler Denniston04f471a2021-02-04 13:07:03 -050057static SkPath make_conic_path() {
58 SkRandom rand;
59 SkPath path;
60 for (int i = 0; i < kNumCubicsInChalkboard / 40; ++i) {
61 for (int j = -10; j <= 10; j++) {
62 const float x = std::ldexp(rand.nextF(), (i % 18)) / 1e3f;
63 const float w = std::ldexp(1 + rand.nextF(), j);
64 path.conicTo(111.625f * x, 308.188f * x, 764.62f * x, -435.688f * x, w);
65 }
66 }
67 return path;
68}
69
Chris Dalton078f8752020-07-30 19:50:46 -060070// This serves as a base class for benchmarking individual methods on GrPathTessellateOp.
Chris Daltond7177432021-01-15 13:12:50 -070071class PathTessellateBenchmark : public Benchmark {
Chris Dalton7f0b8972020-04-23 15:52:24 -060072public:
Chris Daltond7177432021-01-15 13:12:50 -070073 PathTessellateBenchmark(const char* subName, const SkPath& p, const SkMatrix& m)
74 : fPath(p), fMatrix(m) {
Chris Dalton7f0b8972020-04-23 15:52:24 -060075 fName.printf("tessellate_%s", subName);
76 }
77
78 const char* onGetName() override { return fName.c_str(); }
79 bool isSuitableFor(Backend backend) final { return backend == kNonRendering_Backend; }
80
Chris Daltond7177432021-01-15 13:12:50 -070081protected:
Chris Dalton0e543092020-11-03 14:09:16 -070082 void onDelayedSetup() override {
Chris Dalton90ad0fe2020-11-09 14:13:39 -070083 fTarget = std::make_unique<GrMockOpTarget>(make_mock_context());
Chris Dalton0e543092020-11-03 14:09:16 -070084 }
85
Chris Dalton7f0b8972020-04-23 15:52:24 -060086 void onDraw(int loops, SkCanvas*) final {
Chris Dalton0e543092020-11-03 14:09:16 -070087 if (!fTarget->mockContext()) {
Chris Dalton1443c9d2020-05-27 09:43:34 -060088 SkDebugf("ERROR: could not create mock context.");
89 return;
90 }
Chris Dalton7f0b8972020-04-23 15:52:24 -060091 for (int i = 0; i < loops; ++i) {
Chris Daltond7177432021-01-15 13:12:50 -070092 this->runBench();
Chris Dalton0e543092020-11-03 14:09:16 -070093 fTarget->resetAllocator();
Chris Dalton7f0b8972020-04-23 15:52:24 -060094 }
95 }
96
Chris Daltond7177432021-01-15 13:12:50 -070097 virtual void runBench() = 0;
Chris Dalton7f0b8972020-04-23 15:52:24 -060098
Chris Dalton7f0b8972020-04-23 15:52:24 -060099 SkString fName;
Chris Daltond7177432021-01-15 13:12:50 -0700100 std::unique_ptr<GrMockOpTarget> fTarget;
101 const SkPath fPath;
Chris Daltone1314a32021-01-29 13:22:33 -0700102 const SkMatrix fMatrix;
Chris Dalton7f0b8972020-04-23 15:52:24 -0600103};
104
Chris Daltond7177432021-01-15 13:12:50 -0700105#define DEF_PATH_TESS_BENCH(NAME, PATH, MATRIX) \
106 class PathTessellateBenchmark_##NAME : public PathTessellateBenchmark { \
Chris Daltonb5391d92020-05-24 14:55:54 -0600107 public: \
Chris Daltond7177432021-01-15 13:12:50 -0700108 PathTessellateBenchmark_##NAME() : PathTessellateBenchmark(#NAME, (PATH), (MATRIX)) {} \
109 void runBench() override; \
Chris Daltonb5391d92020-05-24 14:55:54 -0600110 }; \
Chris Daltond7177432021-01-15 13:12:50 -0700111 DEF_BENCH( return new PathTessellateBenchmark_##NAME(); ); \
112 void PathTessellateBenchmark_##NAME::runBench()
Chris Dalton7f0b8972020-04-23 15:52:24 -0600113
Chris Dalton8447f132021-05-21 15:54:23 -0600114DEF_PATH_TESS_BENCH(GrPathOuterCurveTessellator, make_cubic_path(8), SkMatrix::I()) {
Chris Dalton569c01b2021-05-25 10:11:46 -0600115 SkArenaAlloc arena(1024);
Chris Daltond9bdc322021-06-01 19:22:05 -0600116 auto tess = GrPathCurveTessellator::Make(&arena, fMatrix, SK_PMColor4fTRANSPARENT,
Chris Dalton6b2121d2021-06-08 20:33:56 -0600117 GrPathCurveTessellator::DrawInnerFan::kNo,
Chris Dalton26666bd2021-06-08 16:25:46 -0600118 fTarget->caps().minPathVerbsForHwTessellation(),
119 fTarget->caps());
Chris Dalton569c01b2021-05-25 10:11:46 -0600120 tess->prepare(fTarget.get(), SkRectPriv::MakeLargest(), fPath, nullptr);
Chris Daltonb5391d92020-05-24 14:55:54 -0600121}
Chris Dalton7f0b8972020-04-23 15:52:24 -0600122
Chris Dalton8447f132021-05-21 15:54:23 -0600123DEF_PATH_TESS_BENCH(GrPathWedgeTessellator, make_cubic_path(8), SkMatrix::I()) {
Chris Dalton569c01b2021-05-25 10:11:46 -0600124 SkArenaAlloc arena(1024);
Chris Daltond2b8ba32021-06-09 00:12:59 -0600125 auto tess = GrPathWedgeTessellator::Make(&arena, fMatrix, SK_PMColor4fTRANSPARENT,
126 fTarget->caps().minPathVerbsForHwTessellation(),
127 fTarget->caps());
Chris Dalton569c01b2021-05-25 10:11:46 -0600128 tess->prepare(fTarget.get(), SkRectPriv::MakeLargest(), fPath, nullptr);
Chris Daltonb5391d92020-05-24 14:55:54 -0600129}
Chris Daltonf6bf5162020-05-13 19:18:46 -0600130
Chris Daltonb5391d92020-05-24 14:55:54 -0600131static void benchmark_wangs_formula_cubic_log2(const SkMatrix& matrix, const SkPath& path) {
132 int sum = 0;
133 GrVectorXform xform(matrix);
134 for (auto [verb, pts, w] : SkPathPriv::Iterate(path)) {
135 if (verb == SkPathVerb::kCubic) {
136 sum += GrWangsFormula::cubic_log2(4, pts, xform);
Chris Daltonf6bf5162020-05-13 19:18:46 -0600137 }
138 }
Chris Daltonb5391d92020-05-24 14:55:54 -0600139 // Don't let the compiler optimize away GrWangsFormula::cubic_log2.
140 if (sum <= 0) {
141 SK_ABORT("sum should be > 0.");
142 }
143}
Chris Daltonf6bf5162020-05-13 19:18:46 -0600144
Chris Dalton8447f132021-05-21 15:54:23 -0600145DEF_PATH_TESS_BENCH(wangs_formula_cubic_log2, make_cubic_path(18), SkMatrix::I()) {
Chris Daltond7177432021-01-15 13:12:50 -0700146 benchmark_wangs_formula_cubic_log2(fMatrix, fPath);
Chris Daltonb5391d92020-05-24 14:55:54 -0600147}
148
Chris Dalton8447f132021-05-21 15:54:23 -0600149DEF_PATH_TESS_BENCH(wangs_formula_cubic_log2_scale, make_cubic_path(18),
Chris Daltond7177432021-01-15 13:12:50 -0700150 SkMatrix::Scale(1.1f, 0.9f)) {
151 benchmark_wangs_formula_cubic_log2(fMatrix, fPath);
Chris Daltonb5391d92020-05-24 14:55:54 -0600152}
153
Chris Dalton8447f132021-05-21 15:54:23 -0600154DEF_PATH_TESS_BENCH(wangs_formula_cubic_log2_affine, make_cubic_path(18),
Chris Daltond7177432021-01-15 13:12:50 -0700155 SkMatrix::MakeAll(.9f,0.9f,0, 1.1f,1.1f,0, 0,0,1)) {
156 benchmark_wangs_formula_cubic_log2(fMatrix, fPath);
Chris Daltonb5391d92020-05-24 14:55:54 -0600157}
158
Tyler Denniston04f471a2021-02-04 13:07:03 -0500159static void benchmark_wangs_formula_conic(const SkMatrix& matrix, const SkPath& path) {
Tyler Denniston04f471a2021-02-04 13:07:03 -0500160 int sum = 0;
161 GrVectorXform xform(matrix);
162 for (auto [verb, pts, w] : SkPathPriv::Iterate(path)) {
163 if (verb == SkPathVerb::kConic) {
Chris Daltone6f45312021-06-02 12:00:01 -0600164 sum += GrWangsFormula::conic(4, pts, *w, xform);
Tyler Denniston04f471a2021-02-04 13:07:03 -0500165 }
166 }
167 // Don't let the compiler optimize away GrWangsFormula::conic.
168 if (sum <= 0) {
169 SK_ABORT("sum should be > 0.");
170 }
171}
172
173static void benchmark_wangs_formula_conic_log2(const SkMatrix& matrix, const SkPath& path) {
Tyler Denniston04f471a2021-02-04 13:07:03 -0500174 int sum = 0;
175 GrVectorXform xform(matrix);
176 for (auto [verb, pts, w] : SkPathPriv::Iterate(path)) {
177 if (verb == SkPathVerb::kConic) {
Chris Daltone6f45312021-06-02 12:00:01 -0600178 sum += GrWangsFormula::conic_log2(4, pts, *w, xform);
Tyler Denniston04f471a2021-02-04 13:07:03 -0500179 }
180 }
181 // Don't let the compiler optimize away GrWangsFormula::conic.
182 if (sum <= 0) {
183 SK_ABORT("sum should be > 0.");
184 }
185}
186
187DEF_PATH_TESS_BENCH(wangs_formula_conic, make_conic_path(), SkMatrix::I()) {
188 benchmark_wangs_formula_conic(fMatrix, fPath);
189}
190
191DEF_PATH_TESS_BENCH(wangs_formula_conic_log2, make_conic_path(), SkMatrix::I()) {
192 benchmark_wangs_formula_conic_log2(fMatrix, fPath);
193}
194
Chris Daltone2067642020-09-23 11:07:20 -0600195DEF_PATH_TESS_BENCH(middle_out_triangulation,
196 ToolUtils::make_star(SkRect::MakeWH(500, 500), kNumCubicsInChalkboard),
Chris Daltond7177432021-01-15 13:12:50 -0700197 SkMatrix::I()) {
Chris Dalton8ed7a8d2021-03-31 10:40:29 -0600198 sk_sp<const GrBuffer> buffer;
Chris Daltonb5391d92020-05-24 14:55:54 -0600199 int baseVertex;
Chris Dalton8731a712021-05-14 14:48:54 -0600200 GrVertexWriter vertexWriter = static_cast<SkPoint*>(fTarget->makeVertexSpace(
Chris Dalton8ed7a8d2021-03-31 10:40:29 -0600201 sizeof(SkPoint), kNumCubicsInChalkboard, &buffer, &baseVertex));
Chris Daltondf2dbad2021-05-14 16:21:15 -0600202 GrMiddleOutPolygonTriangulator::WritePathInnerFan(
203 &vertexWriter, GrMiddleOutPolygonTriangulator::OutputType::kTriangles, fPath);
Chris Daltonb5391d92020-05-24 14:55:54 -0600204}
Chris Daltone2067642020-09-23 11:07:20 -0600205
Chris Dalton981e4a72021-02-22 12:13:49 -0700206using PathStrokeList = GrStrokeTessellator::PathStrokeList;
Chris Dalton13adb4a2021-05-26 10:21:56 -0600207using MakeTessellatorFn = std::unique_ptr<GrStrokeTessellator>(*)(ShaderFlags, const GrShaderCaps&,
208 const SkMatrix&, PathStrokeList*,
Chris Dalton0638df12021-05-14 15:57:39 -0600209 std::array<float, 2>, const
210 SkRect&);
Chris Dalton82007f52021-04-20 00:45:50 -0600211
Chris Dalton0638df12021-05-14 15:57:39 -0600212static std::unique_ptr<GrStrokeTessellator> make_hw_tessellator(
Chris Dalton13adb4a2021-05-26 10:21:56 -0600213 ShaderFlags shaderFlags, const GrShaderCaps& shaderCaps, const SkMatrix& viewMatrix,
214 PathStrokeList* pathStrokeList, std::array<float, 2> matrixMinMaxScales,
215 const SkRect& strokeCullBounds) {
216 return std::make_unique<GrStrokeHardwareTessellator>(shaderFlags, shaderCaps, viewMatrix,
217 pathStrokeList, matrixMinMaxScales,
218 strokeCullBounds);
Chris Dalton82007f52021-04-20 00:45:50 -0600219}
220
221static std::unique_ptr<GrStrokeTessellator> make_fixed_count_tessellator(
Chris Dalton13adb4a2021-05-26 10:21:56 -0600222 ShaderFlags shaderFlags, const GrShaderCaps&, const SkMatrix& viewMatrix,
223 PathStrokeList* pathStrokeList, std::array<float, 2> matrixMinMaxScales,
224 const SkRect& strokeCullBounds) {
Chris Dalton0638df12021-05-14 15:57:39 -0600225 return std::make_unique<GrStrokeFixedCountTessellator>(shaderFlags, viewMatrix, pathStrokeList,
226 matrixMinMaxScales, strokeCullBounds);
Chris Dalton82007f52021-04-20 00:45:50 -0600227}
228
Chris Dalton981e4a72021-02-22 12:13:49 -0700229using MakePathStrokesFn = std::vector<PathStrokeList>(*)();
230
231static std::vector<PathStrokeList> make_simple_cubic_path() {
232 auto path = SkPath().moveTo(0, 0);
233 for (int i = 0; i < kNumCubicsInChalkboard/2; ++i) {
234 path.cubicTo(100, 0, 50, 100, 100, 100);
235 path.cubicTo(0, -100, 200, 100, 0, 0);
236 }
237 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
238 stroke.setStrokeStyle(8);
239 stroke.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kMiter_Join, 4);
240 return {{path, stroke, SK_PMColor4fWHITE}};
241}
242
243// Generates a list of paths that resemble the MotionMark benchmark.
244static std::vector<PathStrokeList> make_motionmark_paths() {
245 std::vector<PathStrokeList> pathStrokes;
246 SkRandom rand;
247 for (int i = 0; i < 8702; ++i) {
248 // The number of paths with a given number of verbs in the MotionMark bench gets cut in half
249 // every time the number of verbs increases by 1.
250 int numVerbs = 28 - SkNextLog2(rand.nextRangeU(0, (1 << 27) - 1));
251 SkPath path;
252 for (int j = 0; j < numVerbs; ++j) {
253 switch (rand.nextU() & 3) {
254 case 0:
255 case 1:
256 path.lineTo(rand.nextRangeF(0, 150), rand.nextRangeF(0, 150));
257 break;
258 case 2:
259 if (rand.nextULessThan(10) == 0) {
260 // Cusp.
261 auto [x, y] = (path.isEmpty())
262 ? SkPoint{0,0}
263 : SkPathPriv::PointData(path)[path.countPoints() - 1];
264 path.quadTo(x + rand.nextRangeF(0, 150), y, x - rand.nextRangeF(0, 150), y);
265 } else {
266 path.quadTo(rand.nextRangeF(0, 150), rand.nextRangeF(0, 150),
267 rand.nextRangeF(0, 150), rand.nextRangeF(0, 150));
268 }
269 break;
270 case 3:
271 if (rand.nextULessThan(10) == 0) {
272 // Cusp.
273 float y = (path.isEmpty())
274 ? 0 : SkPathPriv::PointData(path)[path.countPoints() - 1].fY;
275 path.cubicTo(rand.nextRangeF(0, 150), y, rand.nextRangeF(0, 150), y,
276 rand.nextRangeF(0, 150), y);
277 } else {
278 path.cubicTo(rand.nextRangeF(0, 150), rand.nextRangeF(0, 150),
279 rand.nextRangeF(0, 150), rand.nextRangeF(0, 150),
280 rand.nextRangeF(0, 150), rand.nextRangeF(0, 150));
281 }
282 break;
283 }
284 }
285 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
286 // The number of paths with a given stroke width in the MotionMark bench gets cut in half
287 // every time the stroke width increases by 1.
288 float strokeWidth = 21 - log2f(rand.nextRangeF(0, 1 << 20));
289 stroke.setStrokeStyle(strokeWidth);
290 stroke.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kBevel_Join, 0);
291 pathStrokes.emplace_back(path, stroke, SK_PMColor4fWHITE);
292 }
293 return pathStrokes;
294}
295
Chris Dalton82007f52021-04-20 00:45:50 -0600296class TessPrepareBench : public Benchmark {
Chris Dalton2882e702020-11-02 12:43:06 -0700297public:
Chris Dalton82007f52021-04-20 00:45:50 -0600298 TessPrepareBench(MakePathStrokesFn makePathStrokesFn, MakeTessellatorFn makeTessellatorFn,
299 ShaderFlags shaderFlags, float matrixScale, const char* suffix)
300 : fMakePathStrokesFn(makePathStrokesFn)
301 , fMakeTessellatorFn(makeTessellatorFn)
Chris Daltonbb33be22021-02-24 16:30:34 -0700302 , fShaderFlags(shaderFlags)
Chris Dalton981e4a72021-02-22 12:13:49 -0700303 , fMatrixScale(matrixScale) {
Chris Dalton82007f52021-04-20 00:45:50 -0600304 fName.printf("tessellate_%s", suffix);
Chris Dalton2882e702020-11-02 12:43:06 -0700305 }
306
307private:
308 const char* onGetName() override { return fName.c_str(); }
Chris Daltone2067642020-09-23 11:07:20 -0600309 bool isSuitableFor(Backend backend) final { return backend == kNonRendering_Backend; }
310
311 void onDelayedSetup() override {
Chris Dalton90ad0fe2020-11-09 14:13:39 -0700312 fTarget = std::make_unique<GrMockOpTarget>(make_mock_context());
Chris Dalton0e543092020-11-03 14:09:16 -0700313 if (!fTarget->mockContext()) {
Chris Daltone2067642020-09-23 11:07:20 -0600314 SkDebugf("ERROR: could not create mock context.");
315 return;
316 }
Chris Dalton981e4a72021-02-22 12:13:49 -0700317
318 fPathStrokes = fMakePathStrokesFn();
319 for (size_t i = 0; i < fPathStrokes.size(); ++i) {
320 if (i + 1 < fPathStrokes.size()) {
321 fPathStrokes[i].fNext = &fPathStrokes[i + 1];
322 }
323 fTotalVerbCount += fPathStrokes[i].fPath.countVerbs();
Chris Daltone2067642020-09-23 11:07:20 -0600324 }
Chris Dalton82007f52021-04-20 00:45:50 -0600325
Chris Dalton13adb4a2021-05-26 10:21:56 -0600326 fTessellator = fMakeTessellatorFn(fShaderFlags, *fTarget->caps().shaderCaps(),
327 SkMatrix::Scale(fMatrixScale, fMatrixScale),
Chris Dalton0638df12021-05-14 15:57:39 -0600328 fPathStrokes.data(), {fMatrixScale, fMatrixScale},
Chris Dalton8447f132021-05-21 15:54:23 -0600329 SkRectPriv::MakeLargest());
Chris Daltone2067642020-09-23 11:07:20 -0600330 }
331
Chris Dalton981e4a72021-02-22 12:13:49 -0700332 void onDraw(int loops, SkCanvas*) final {
Chris Dalton981e4a72021-02-22 12:13:49 -0700333 for (int i = 0; i < loops; ++i) {
Chris Dalton82007f52021-04-20 00:45:50 -0600334 fTessellator->prepare(fTarget.get(), fTotalVerbCount);
Chris Dalton981e4a72021-02-22 12:13:49 -0700335 fTarget->resetAllocator();
336 }
337 }
338
Chris Dalton2882e702020-11-02 12:43:06 -0700339 SkString fName;
Chris Dalton981e4a72021-02-22 12:13:49 -0700340 MakePathStrokesFn fMakePathStrokesFn;
Chris Dalton82007f52021-04-20 00:45:50 -0600341 MakeTessellatorFn fMakeTessellatorFn;
Chris Daltonbb33be22021-02-24 16:30:34 -0700342 const ShaderFlags fShaderFlags;
Chris Dalton981e4a72021-02-22 12:13:49 -0700343 float fMatrixScale;
Chris Dalton90ad0fe2020-11-09 14:13:39 -0700344 std::unique_ptr<GrMockOpTarget> fTarget;
Chris Dalton981e4a72021-02-22 12:13:49 -0700345 std::vector<PathStrokeList> fPathStrokes;
Chris Dalton82007f52021-04-20 00:45:50 -0600346 std::unique_ptr<GrStrokeTessellator> fTessellator;
Chris Dalton981e4a72021-02-22 12:13:49 -0700347 SkArenaAlloc fPersistentArena{1024};
348 int fTotalVerbCount = 0;
Chris Daltone2067642020-09-23 11:07:20 -0600349};
350
Chris Dalton82007f52021-04-20 00:45:50 -0600351DEF_BENCH(return new TessPrepareBench(
352 make_simple_cubic_path, make_hw_tessellator, ShaderFlags::kNone, 1,
353 "GrStrokeHardwareTessellator");
Chris Daltonbb33be22021-02-24 16:30:34 -0700354)
355
Chris Dalton82007f52021-04-20 00:45:50 -0600356DEF_BENCH(return new TessPrepareBench(
357 make_simple_cubic_path, make_hw_tessellator, ShaderFlags::kNone, 5,
358 "GrStrokeHardwareTessellator_one_chop");
Chris Daltonbb33be22021-02-24 16:30:34 -0700359)
360
Chris Dalton82007f52021-04-20 00:45:50 -0600361DEF_BENCH(return new TessPrepareBench(
362 make_motionmark_paths, make_hw_tessellator, ShaderFlags::kDynamicStroke, 1,
363 "GrStrokeHardwareTessellator_motionmark");
364)
365
366DEF_BENCH(return new TessPrepareBench(
367 make_simple_cubic_path, make_fixed_count_tessellator, ShaderFlags::kNone, 1,
368 "GrStrokeFixedCountTessellator");
369)
370
371DEF_BENCH(return new TessPrepareBench(
372 make_simple_cubic_path, make_fixed_count_tessellator, ShaderFlags::kNone, 5,
373 "GrStrokeFixedCountTessellator_one_chop");
374)
375
376DEF_BENCH(return new TessPrepareBench(
377 make_motionmark_paths, make_fixed_count_tessellator, ShaderFlags::kDynamicStroke, 1,
378 "GrStrokeFixedCountTessellator_motionmark");
Chris Daltonbb33be22021-02-24 16:30:34 -0700379)