caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 1 | /* |
| 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 Dalton | 040238b | 2017-12-18 14:22:34 -0700 | [diff] [blame] | 8 | #include "GrContextOptions.h" |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 9 | #include "SkCommonFlags.h" |
Brian Osman | f981066 | 2017-08-30 10:02:10 -0400 | [diff] [blame] | 10 | #include "SkExecutor.h" |
| 11 | #include "SkOnce.h" |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 12 | #include "SkOSFile.h" |
Ben Wagner | bf111d7 | 2016-11-07 18:05:29 -0500 | [diff] [blame] | 13 | #include "SkOSPath.h" |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 14 | |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 15 | DEFINE_bool(cpu, true, "master switch for running CPU-bound work."); |
| 16 | |
| 17 | DEFINE_bool(dryRun, false, |
| 18 | "just print the tests that would be run, without actually running them."); |
| 19 | |
| 20 | DEFINE_bool(gpu, true, "master switch for running GPU-bound work."); |
| 21 | |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 22 | DEFINE_string(images, "", "List of images and/or directories to decode. A directory with no images" |
| 23 | " is treated as a fatal error."); |
msarett | 95f192d | 2015-02-13 09:05:41 -0800 | [diff] [blame] | 24 | |
msarett | 69deca8 | 2016-04-29 09:38:40 -0700 | [diff] [blame] | 25 | DEFINE_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 | |
msarett | db197a5 | 2016-06-21 09:44:29 -0700 | [diff] [blame] | 28 | DEFINE_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 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 33 | DEFINE_string2(match, m, nullptr, |
Ben Wagner | 483c772 | 2018-02-20 17:06:07 -0500 | [diff] [blame] | 34 | "[~][^]substring[$] [...] of name to run.\n" |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 35 | "Multiple matches may be separated by spaces.\n" |
Ben Wagner | 483c772 | 2018-02-20 17:06:07 -0500 | [diff] [blame] | 36 | "~ 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" |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 39 | "^ and $ requires an exact match\n" |
Ben Wagner | 483c772 | 2018-02-20 17:06:07 -0500 | [diff] [blame] | 40 | "If a name does not match any list entry,\n" |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 41 | "it is skipped unless some list entry starts with ~"); |
| 42 | |
| 43 | DEFINE_bool2(quiet, q, false, "if true, don't print status updates."); |
| 44 | |
bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 45 | DEFINE_bool(preAbandonGpuContext, false, "Test abandoning the GrContext before running the test."); |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 46 | |
bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 47 | DEFINE_bool(abandonGpuContext, false, "Test abandoning the GrContext after running each test."); |
| 48 | |
| 49 | DEFINE_bool(releaseAndAbandonGpuContext, false, |
| 50 | "Test releasing all gpu resources and abandoning the GrContext after running each " |
| 51 | "test"); |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 52 | |
Brian Salomon | 01b476a | 2018-01-23 11:06:41 -0500 | [diff] [blame] | 53 | DEFINE_bool(disableDriverCorrectnessWorkarounds, false, "Disables all GPU driver correctness " |
| 54 | "workarounds"); |
| 55 | |
Ben Wagner | 483c772 | 2018-02-20 17:06:07 -0500 | [diff] [blame] | 56 | #ifdef SK_BUILD_FOR_ANDROID |
| 57 | DEFINE_string(skps, "/data/local/tmp/skps", "Directory to read skps from."); |
| 58 | DEFINE_string(jpgs, "/data/local/tmp/resources", "Directory to read jpgs from."); |
Eric Boren | 8c172ba | 2018-07-19 13:27:49 -0400 | [diff] [blame] | 59 | DEFINE_string(lotties, "/data/local/tmp/lotties", "Directory to read (Bodymovin) jsons from."); |
Ruiqi Mao | f510149 | 2018-06-29 14:32:21 -0400 | [diff] [blame] | 60 | DEFINE_string(nimas, "/data/local/tmp/nimas", "Directory to read NIMA animations from."); |
Ben Wagner | 483c772 | 2018-02-20 17:06:07 -0500 | [diff] [blame] | 61 | #else |
mtklein | 34580f7 | 2014-08-07 12:46:29 -0700 | [diff] [blame] | 62 | DEFINE_string(skps, "skps", "Directory to read skps from."); |
Ben Wagner | 483c772 | 2018-02-20 17:06:07 -0500 | [diff] [blame] | 63 | DEFINE_string(jpgs, "jpgs", "Directory to read jpgs from."); |
Eric Boren | 8c172ba | 2018-07-19 13:27:49 -0400 | [diff] [blame] | 64 | DEFINE_string(lotties, "lotties", "Directory to read (Bodymovin) jsons from."); |
Ruiqi Mao | f510149 | 2018-06-29 14:32:21 -0400 | [diff] [blame] | 65 | DEFINE_string(nimas, "nimas", "Directory to read NIMA animations from."); |
Ben Wagner | 483c772 | 2018-02-20 17:06:07 -0500 | [diff] [blame] | 66 | #endif |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 67 | |
Robert Phillips | 33f02ed | 2018-03-27 08:06:57 -0400 | [diff] [blame] | 68 | DEFINE_int32(skpViewportSize, 1000, "Width & height of the viewport used to crop skp rendering."); |
| 69 | |
Ben Wagner | 483c772 | 2018-02-20 17:06:07 -0500 | [diff] [blame] | 70 | DEFINE_bool(nativeFonts, true, "If true, use native font manager and rendering. " |
| 71 | "If false, fonts will draw as portably as possible."); |
Florin Malita | fc043dc | 2017-12-31 11:08:42 -0500 | [diff] [blame] | 72 | |
fmalita | 95573e4 | 2016-09-14 09:05:43 -0700 | [diff] [blame] | 73 | DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file."); |
| 74 | |
Mike Klein | 08c8963 | 2016-11-08 14:16:01 -0500 | [diff] [blame] | 75 | DEFINE_int32_2(threads, j, -1, "Run threadsafe tests on a threadpool with this many extra threads, " |
| 76 | "defaulting to one extra thread per core."); |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 77 | |
| 78 | DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver."); |
| 79 | |
| 80 | DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose."); |
mtklein | b511042 | 2014-08-07 15:20:02 -0700 | [diff] [blame] | 81 | |
| 82 | DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs."); |
mtklein | ea65bfa | 2014-09-09 07:59:46 -0700 | [diff] [blame] | 83 | |
| 84 | DEFINE_string(key, "", |
| 85 | "Space-separated key/value pairs to add to JSON identifying this builder."); |
| 86 | DEFINE_string(properties, "", |
| 87 | "Space-separated key/value pairs to add to JSON identifying this run."); |
benjaminwagner | 8d61f0d | 2016-01-25 13:02:40 -0800 | [diff] [blame] | 88 | DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehensible when threading"); |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 89 | |
Yuqian Li | ba62b4a | 2016-12-14 13:46:53 -0500 | [diff] [blame] | 90 | DEFINE_bool(analyticAA, true, "If false, disable analytic anti-aliasing"); |
liyuqian | 38911a7 | 2016-10-04 11:23:22 -0700 | [diff] [blame] | 91 | |
Yuqian Li | 550148b | 2017-01-13 10:13:13 -0500 | [diff] [blame] | 92 | DEFINE_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 | |
Mike Klein | 830ab79 | 2019-02-05 10:56:39 -0500 | [diff] [blame^] | 96 | DEFINE_bool(deltaAA, false, |
Yuqian Li | df60e36 | 2017-07-25 11:26:31 -0400 | [diff] [blame] | 97 | "If true, use delta anti-aliasing in suitable cases (it overrides forceAnalyticAA."); |
Yuqian Li | df60e36 | 2017-07-25 11:26:31 -0400 | [diff] [blame] | 98 | DEFINE_bool(forceDeltaAA, false, "Force delta anti-aliasing for all paths."); |
| 99 | |
Yuqian Li | b8b6253 | 2018-02-23 14:13:36 +0800 | [diff] [blame] | 100 | DEFINE_int32(backendTiles, 3, "Number of tiles in the experimental threaded backend."); |
| 101 | DEFINE_int32(backendThreads, 2, "Number of threads in the experimental threaded backend."); |
| 102 | |
msarett | 69deca8 | 2016-04-29 09:38:40 -0700 | [diff] [blame] | 103 | bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* output) { |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 104 | SkASSERT(output); |
| 105 | |
| 106 | static const char* const exts[] = { |
Leon Scroggins | 427da6f | 2016-12-16 13:51:59 +0000 | [diff] [blame] | 107 | "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico", |
Brian Osman | 00c5d0f | 2018-09-06 16:06:27 -0400 | [diff] [blame] | 108 | #if !defined(SK_BUILD_FOR_WIN) |
Leon Scroggins | 427da6f | 2016-12-16 13:51:59 +0000 | [diff] [blame] | 109 | "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO", |
Brian Osman | 00c5d0f | 2018-09-06 16:06:27 -0400 | [diff] [blame] | 110 | #endif |
Chong Zhang | c1868cd | 2017-09-06 17:40:16 -0700 | [diff] [blame] | 111 | #ifdef SK_HAS_HEIF_LIBRARY |
| 112 | "heic", |
Brian Osman | 00c5d0f | 2018-09-06 16:06:27 -0400 | [diff] [blame] | 113 | #if !defined(SK_BUILD_FOR_WIN) |
Chong Zhang | c1868cd | 2017-09-06 17:40:16 -0700 | [diff] [blame] | 114 | "HEIC", |
| 115 | #endif |
Brian Osman | 00c5d0f | 2018-09-06 16:06:27 -0400 | [diff] [blame] | 116 | #endif |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 117 | #ifdef SK_CODEC_DECODES_RAW |
| 118 | "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw", |
Brian Osman | 00c5d0f | 2018-09-06 16:06:27 -0400 | [diff] [blame] | 119 | #if !defined(SK_BUILD_FOR_WIN) |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 120 | "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW", |
| 121 | #endif |
Brian Osman | 00c5d0f | 2018-09-06 16:06:27 -0400 | [diff] [blame] | 122 | #endif |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 123 | }; |
| 124 | |
msarett | 69deca8 | 2016-04-29 09:38:40 -0700 | [diff] [blame] | 125 | for (int i = 0; i < images.count(); ++i) { |
| 126 | const char* flag = images[i]; |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 127 | if (!sk_exists(flag)) { |
| 128 | SkDebugf("%s does not exist!\n", flag); |
| 129 | return false; |
| 130 | } |
| 131 | |
| 132 | if (sk_isdir(flag)) { |
| 133 | // If the value passed in is a directory, add all the images |
| 134 | bool foundAnImage = false; |
| 135 | for (const char* ext : exts) { |
| 136 | SkOSFile::Iter it(flag, ext); |
| 137 | SkString file; |
| 138 | while (it.next(&file)) { |
| 139 | foundAnImage = true; |
| 140 | output->push_back() = SkOSPath::Join(flag, file.c_str()); |
| 141 | } |
| 142 | } |
| 143 | if (!foundAnImage) { |
| 144 | SkDebugf("No supported images found in %s!\n", flag); |
| 145 | return false; |
| 146 | } |
| 147 | } else { |
| 148 | // Also add the value if it is a single image |
| 149 | output->push_back() = flag; |
| 150 | } |
| 151 | } |
| 152 | return true; |
| 153 | } |
Brian Osman | f981066 | 2017-08-30 10:02:10 -0400 | [diff] [blame] | 154 | |
Chris Dalton | 040238b | 2017-12-18 14:22:34 -0700 | [diff] [blame] | 155 | #include "SkCommonFlagsGpu.h" |
| 156 | |
| 157 | DEFINE_int32(gpuThreads, 2, "Create this many extra threads to assist with GPU work, " |
| 158 | "including software path rendering. Defaults to two."); |
| 159 | |
| 160 | DEFINE_bool(cachePathMasks, true, "Allows path mask textures to be cached in GPU configs."); |
| 161 | |
| 162 | DEFINE_bool(noGS, false, "Disables support for geometry shaders."); |
| 163 | |
Chris Dalton | 9acfc6c | 2018-07-26 12:34:49 -0600 | [diff] [blame] | 164 | DEFINE_string(pr, "all", |
Chris Dalton | 040238b | 2017-12-18 14:22:34 -0700 | [diff] [blame] | 165 | "Set of enabled gpu path renderers. Defined as a list of: " |
Chris Dalton | 9acfc6c | 2018-07-26 12:34:49 -0600 | [diff] [blame] | 166 | "[~]none [~]dashline [~]nvpr [~]ccpr [~]aahairline [~]aaconvex [~]aalinearizing " |
| 167 | "[~]small [~]tess] [~]all"); |
Chris Dalton | 040238b | 2017-12-18 14:22:34 -0700 | [diff] [blame] | 168 | |
Robert Phillips | cb2275b | 2018-08-07 08:34:38 -0400 | [diff] [blame] | 169 | DEFINE_bool(disableExplicitAlloc, false, "Disable explicit allocation of GPU resources"); |
Robert Phillips | b7a98ef | 2018-10-10 09:26:00 -0400 | [diff] [blame] | 170 | DEFINE_bool(reduceOpListSplitting, false, "Improve opList sorting"); |
Robert Phillips | cb2275b | 2018-08-07 08:34:38 -0400 | [diff] [blame] | 171 | |
Chris Dalton | c70817a | 2017-12-20 09:10:26 -0700 | [diff] [blame] | 172 | void SetCtxOptionsFromCommonFlags(GrContextOptions* ctxOptions) { |
Brian Osman | f981066 | 2017-08-30 10:02:10 -0400 | [diff] [blame] | 173 | static std::unique_ptr<SkExecutor> gGpuExecutor = (0 != FLAGS_gpuThreads) |
Mike Klein | 022cfa2 | 2017-09-01 11:53:16 -0400 | [diff] [blame] | 174 | ? SkExecutor::MakeFIFOThreadPool(FLAGS_gpuThreads) : nullptr; |
Chris Dalton | c70817a | 2017-12-20 09:10:26 -0700 | [diff] [blame] | 175 | ctxOptions->fExecutor = gGpuExecutor.get(); |
Chris Dalton | 040238b | 2017-12-18 14:22:34 -0700 | [diff] [blame] | 176 | ctxOptions->fAllowPathMaskCaching = FLAGS_cachePathMasks; |
| 177 | ctxOptions->fSuppressGeometryShaders = FLAGS_noGS; |
Chris Dalton | c70817a | 2017-12-20 09:10:26 -0700 | [diff] [blame] | 178 | ctxOptions->fGpuPathRenderers = CollectGpuPathRenderersFromFlags(); |
Brian Salomon | 01b476a | 2018-01-23 11:06:41 -0500 | [diff] [blame] | 179 | ctxOptions->fDisableDriverCorrectnessWorkarounds = FLAGS_disableDriverCorrectnessWorkarounds; |
Robert Phillips | cb2275b | 2018-08-07 08:34:38 -0400 | [diff] [blame] | 180 | |
| 181 | if (FLAGS_disableExplicitAlloc) { |
| 182 | ctxOptions->fExplicitlyAllocateGPUResources = GrContextOptions::Enable::kNo; |
| 183 | // Can't have sorting enabled when explicit allocation is disabled. |
| 184 | ctxOptions->fSortRenderTargets = GrContextOptions::Enable::kNo; |
| 185 | } |
Robert Phillips | b7a98ef | 2018-10-10 09:26:00 -0400 | [diff] [blame] | 186 | |
| 187 | if (FLAGS_reduceOpListSplitting) { |
| 188 | ctxOptions->fReduceOpListSplitting = GrContextOptions::Enable::kYes; |
| 189 | } |
Chris Dalton | 040238b | 2017-12-18 14:22:34 -0700 | [diff] [blame] | 190 | } |