blob: c30bd014ec70de2846a93281f8deca5b8b3a9fda [file] [log] [blame]
caryclark17f0b6d2014-07-22 10:15:34 -07001/*
2 * Copyright 2014 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
Chris Dalton040238b2017-12-18 14:22:34 -07008#include "GrContextOptions.h"
caryclark17f0b6d2014-07-22 10:15:34 -07009#include "SkCommonFlags.h"
Brian Osmanf9810662017-08-30 10:02:10 -040010#include "SkExecutor.h"
11#include "SkOnce.h"
scroggo86737142016-02-03 12:19:11 -080012#include "SkOSFile.h"
Ben Wagnerbf111d72016-11-07 18:05:29 -050013#include "SkOSPath.h"
caryclark17f0b6d2014-07-22 10:15:34 -070014
caryclark17f0b6d2014-07-22 10:15:34 -070015DEFINE_bool(cpu, true, "master switch for running CPU-bound work.");
16
17DEFINE_bool(dryRun, false,
18 "just print the tests that would be run, without actually running them.");
19
20DEFINE_bool(gpu, true, "master switch for running GPU-bound work.");
21
scroggo86737142016-02-03 12:19:11 -080022DEFINE_string(images, "", "List of images and/or directories to decode. A directory with no images"
23 " is treated as a fatal error.");
msarett95f192d2015-02-13 09:05:41 -080024
msarett69deca82016-04-29 09:38:40 -070025DEFINE_string(colorImages, "", "List of images and/or directories to decode with color correction. "
26 "A directory with no images is treated as a fatal error.");
27
msarettdb197a52016-06-21 09:44:29 -070028DEFINE_bool(simpleCodec, false, "Runs of a subset of the codec tests. "
29 "For DM, this means no scaling or subsetting, always using the "
30 "canvas color type. "
31 "For nanobench, this means always N32, Premul or Opaque.");
32
halcanary96fcdcc2015-08-27 07:41:13 -070033DEFINE_string2(match, m, nullptr,
Ben Wagner483c7722018-02-20 17:06:07 -050034 "[~][^]substring[$] [...] of name to run.\n"
caryclark17f0b6d2014-07-22 10:15:34 -070035 "Multiple matches may be separated by spaces.\n"
Ben Wagner483c7722018-02-20 17:06:07 -050036 "~ causes a matching name to always be skipped\n"
37 "^ requires the start of the name to match\n"
38 "$ requires the end of the name to match\n"
caryclark17f0b6d2014-07-22 10:15:34 -070039 "^ and $ requires an exact match\n"
Ben Wagner483c7722018-02-20 17:06:07 -050040 "If a name does not match any list entry,\n"
caryclark17f0b6d2014-07-22 10:15:34 -070041 "it is skipped unless some list entry starts with ~");
42
43DEFINE_bool2(quiet, q, false, "if true, don't print status updates.");
44
bsalomon6e2aad42016-04-01 11:54:31 -070045DEFINE_bool(preAbandonGpuContext, false, "Test abandoning the GrContext before running the test.");
joshualitt5f5a8d72015-02-25 14:09:45 -080046
bsalomon6e2aad42016-04-01 11:54:31 -070047DEFINE_bool(abandonGpuContext, false, "Test abandoning the GrContext after running each test.");
48
49DEFINE_bool(releaseAndAbandonGpuContext, false,
50 "Test releasing all gpu resources and abandoning the GrContext after running each "
51 "test");
caryclark17f0b6d2014-07-22 10:15:34 -070052
Brian Salomon01b476a2018-01-23 11:06:41 -050053DEFINE_bool(disableDriverCorrectnessWorkarounds, false, "Disables all GPU driver correctness "
54 "workarounds");
55
Ben Wagner483c7722018-02-20 17:06:07 -050056#ifdef SK_BUILD_FOR_ANDROID
57DEFINE_string(skps, "/data/local/tmp/skps", "Directory to read skps from.");
58DEFINE_string(jpgs, "/data/local/tmp/resources", "Directory to read jpgs from.");
Eric Boren8c172ba2018-07-19 13:27:49 -040059DEFINE_string(lotties, "/data/local/tmp/lotties", "Directory to read (Bodymovin) jsons from.");
Ruiqi Maof5101492018-06-29 14:32:21 -040060DEFINE_string(nimas, "/data/local/tmp/nimas", "Directory to read NIMA animations from.");
Ben Wagner483c7722018-02-20 17:06:07 -050061#else
mtklein34580f72014-08-07 12:46:29 -070062DEFINE_string(skps, "skps", "Directory to read skps from.");
Ben Wagner483c7722018-02-20 17:06:07 -050063DEFINE_string(jpgs, "jpgs", "Directory to read jpgs from.");
Eric Boren8c172ba2018-07-19 13:27:49 -040064DEFINE_string(lotties, "lotties", "Directory to read (Bodymovin) jsons from.");
Ruiqi Maof5101492018-06-29 14:32:21 -040065DEFINE_string(nimas, "nimas", "Directory to read NIMA animations from.");
Ben Wagner483c7722018-02-20 17:06:07 -050066#endif
mtklein92007582014-08-01 07:46:52 -070067
Robert Phillips33f02ed2018-03-27 08:06:57 -040068DEFINE_int32(skpViewportSize, 1000, "Width & height of the viewport used to crop skp rendering.");
69
Ben Wagner483c7722018-02-20 17:06:07 -050070DEFINE_bool(nativeFonts, true, "If true, use native font manager and rendering. "
71 "If false, fonts will draw as portably as possible.");
Florin Malitafc043dc2017-12-31 11:08:42 -050072
fmalita95573e42016-09-14 09:05:43 -070073DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file.");
74
Mike Klein08c89632016-11-08 14:16:01 -050075DEFINE_int32_2(threads, j, -1, "Run threadsafe tests on a threadpool with this many extra threads, "
76 "defaulting to one extra thread per core.");
caryclark17f0b6d2014-07-22 10:15:34 -070077
78DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
79
80DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose.");
mtkleinb5110422014-08-07 15:20:02 -070081
82DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs.");
mtkleinea65bfa2014-09-09 07:59:46 -070083
84DEFINE_string(key, "",
85 "Space-separated key/value pairs to add to JSON identifying this builder.");
86DEFINE_string(properties, "",
87 "Space-separated key/value pairs to add to JSON identifying this run.");
benjaminwagner8d61f0d2016-01-25 13:02:40 -080088DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehensible when threading");
scroggo86737142016-02-03 12:19:11 -080089
Yuqian Liba62b4a2016-12-14 13:46:53 -050090DEFINE_bool(analyticAA, true, "If false, disable analytic anti-aliasing");
liyuqian38911a72016-10-04 11:23:22 -070091
Yuqian Li550148b2017-01-13 10:13:13 -050092DEFINE_bool(forceAnalyticAA, false, "Force analytic anti-aliasing even if the path is complicated: "
93 "whether it's concave or convex, we consider a path complicated"
94 "if its number of points is comparable to its resolution.");
95
Yuqian Li737b9a92018-05-03 11:28:28 -040096#if (defined(_MSC_VER) && !defined(__clang__))
Yuqian Li93fe0cc2017-07-29 13:41:52 -040097constexpr bool kDefaultDeltaAA = false;
98#else
99constexpr bool kDefaultDeltaAA = true;
100#endif
101DEFINE_bool(deltaAA, kDefaultDeltaAA,
Yuqian Lidf60e362017-07-25 11:26:31 -0400102 "If true, use delta anti-aliasing in suitable cases (it overrides forceAnalyticAA.");
103
104DEFINE_bool(forceDeltaAA, false, "Force delta anti-aliasing for all paths.");
105
Yuqian Lib8b62532018-02-23 14:13:36 +0800106DEFINE_int32(backendTiles, 3, "Number of tiles in the experimental threaded backend.");
107DEFINE_int32(backendThreads, 2, "Number of threads in the experimental threaded backend.");
108
msarett69deca82016-04-29 09:38:40 -0700109bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* output) {
scroggo86737142016-02-03 12:19:11 -0800110 SkASSERT(output);
111
112 static const char* const exts[] = {
Leon Scroggins427da6f2016-12-16 13:51:59 +0000113 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
Brian Osman00c5d0f2018-09-06 16:06:27 -0400114#if !defined(SK_BUILD_FOR_WIN)
Leon Scroggins427da6f2016-12-16 13:51:59 +0000115 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
Brian Osman00c5d0f2018-09-06 16:06:27 -0400116#endif
Chong Zhangc1868cd2017-09-06 17:40:16 -0700117#ifdef SK_HAS_HEIF_LIBRARY
118 "heic",
Brian Osman00c5d0f2018-09-06 16:06:27 -0400119#if !defined(SK_BUILD_FOR_WIN)
Chong Zhangc1868cd2017-09-06 17:40:16 -0700120 "HEIC",
121#endif
Brian Osman00c5d0f2018-09-06 16:06:27 -0400122#endif
scroggo86737142016-02-03 12:19:11 -0800123#ifdef SK_CODEC_DECODES_RAW
124 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
Brian Osman00c5d0f2018-09-06 16:06:27 -0400125#if !defined(SK_BUILD_FOR_WIN)
scroggo86737142016-02-03 12:19:11 -0800126 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
127#endif
Brian Osman00c5d0f2018-09-06 16:06:27 -0400128#endif
scroggo86737142016-02-03 12:19:11 -0800129 };
130
msarett69deca82016-04-29 09:38:40 -0700131 for (int i = 0; i < images.count(); ++i) {
132 const char* flag = images[i];
scroggo86737142016-02-03 12:19:11 -0800133 if (!sk_exists(flag)) {
134 SkDebugf("%s does not exist!\n", flag);
135 return false;
136 }
137
138 if (sk_isdir(flag)) {
139 // If the value passed in is a directory, add all the images
140 bool foundAnImage = false;
141 for (const char* ext : exts) {
142 SkOSFile::Iter it(flag, ext);
143 SkString file;
144 while (it.next(&file)) {
145 foundAnImage = true;
146 output->push_back() = SkOSPath::Join(flag, file.c_str());
147 }
148 }
149 if (!foundAnImage) {
150 SkDebugf("No supported images found in %s!\n", flag);
151 return false;
152 }
153 } else {
154 // Also add the value if it is a single image
155 output->push_back() = flag;
156 }
157 }
158 return true;
159}
Brian Osmanf9810662017-08-30 10:02:10 -0400160
Chris Dalton040238b2017-12-18 14:22:34 -0700161#include "SkCommonFlagsGpu.h"
162
163DEFINE_int32(gpuThreads, 2, "Create this many extra threads to assist with GPU work, "
164 "including software path rendering. Defaults to two.");
165
166DEFINE_bool(cachePathMasks, true, "Allows path mask textures to be cached in GPU configs.");
167
168DEFINE_bool(noGS, false, "Disables support for geometry shaders.");
169
Chris Dalton9acfc6c2018-07-26 12:34:49 -0600170DEFINE_string(pr, "all",
Chris Dalton040238b2017-12-18 14:22:34 -0700171 "Set of enabled gpu path renderers. Defined as a list of: "
Chris Dalton9acfc6c2018-07-26 12:34:49 -0600172 "[~]none [~]dashline [~]nvpr [~]ccpr [~]aahairline [~]aaconvex [~]aalinearizing "
173 "[~]small [~]tess] [~]all");
Chris Dalton040238b2017-12-18 14:22:34 -0700174
Robert Phillipscb2275b2018-08-07 08:34:38 -0400175DEFINE_bool(disableExplicitAlloc, false, "Disable explicit allocation of GPU resources");
176
Chris Daltonc70817a2017-12-20 09:10:26 -0700177void SetCtxOptionsFromCommonFlags(GrContextOptions* ctxOptions) {
Brian Osmanf9810662017-08-30 10:02:10 -0400178 static std::unique_ptr<SkExecutor> gGpuExecutor = (0 != FLAGS_gpuThreads)
Mike Klein022cfa22017-09-01 11:53:16 -0400179 ? SkExecutor::MakeFIFOThreadPool(FLAGS_gpuThreads) : nullptr;
Chris Daltonc70817a2017-12-20 09:10:26 -0700180 ctxOptions->fExecutor = gGpuExecutor.get();
Chris Dalton040238b2017-12-18 14:22:34 -0700181 ctxOptions->fAllowPathMaskCaching = FLAGS_cachePathMasks;
182 ctxOptions->fSuppressGeometryShaders = FLAGS_noGS;
Chris Daltonc70817a2017-12-20 09:10:26 -0700183 ctxOptions->fGpuPathRenderers = CollectGpuPathRenderersFromFlags();
Brian Salomon01b476a2018-01-23 11:06:41 -0500184 ctxOptions->fDisableDriverCorrectnessWorkarounds = FLAGS_disableDriverCorrectnessWorkarounds;
Robert Phillipscb2275b2018-08-07 08:34:38 -0400185
186 if (FLAGS_disableExplicitAlloc) {
187 ctxOptions->fExplicitlyAllocateGPUResources = GrContextOptions::Enable::kNo;
188 // Can't have sorting enabled when explicit allocation is disabled.
189 ctxOptions->fSortRenderTargets = GrContextOptions::Enable::kNo;
190 }
Chris Dalton040238b2017-12-18 14:22:34 -0700191}