OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 /* | 8 /* |
9 * Code for the "gm" (Golden Master) rendering comparison tool. | 9 * Code for the "gm" (Golden Master) rendering comparison tool. |
10 * | 10 * |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1026 // It would probably be better if we allowed both yes-and-no settings for each | 1026 // It would probably be better if we allowed both yes-and-no settings for each |
1027 // one, e.g.: | 1027 // one, e.g.: |
1028 // [--replay|--noreplay]: whether to exercise SkPicture replay; default is yes | 1028 // [--replay|--noreplay]: whether to exercise SkPicture replay; default is yes |
1029 " [--nodeferred]: skip the deferred rendering test pass\n" | 1029 " [--nodeferred]: skip the deferred rendering test pass\n" |
1030 " [--disable-missing-warning]: don't print a message to stderr if\n" | 1030 " [--disable-missing-warning]: don't print a message to stderr if\n" |
1031 " unable to read a reference image for any tests (NOT default behavior)\n " | 1031 " unable to read a reference image for any tests (NOT default behavior)\n " |
1032 " [--enable-missing-warning]: print message to stderr (but don't fail) if\n" | 1032 " [--enable-missing-warning]: print message to stderr (but don't fail) if\n" |
1033 " unable to read a reference image for any tests (default behavior)\n" | 1033 " unable to read a reference image for any tests (default behavior)\n" |
1034 " [--exclude-config]: disable this config (may be used multiple times)\n" | 1034 " [--exclude-config]: disable this config (may be used multiple times)\n" |
1035 " [--forceBWtext]: disable text anti-aliasing\n" | 1035 " [--forceBWtext]: disable text anti-aliasing\n" |
1036 #if SK_SUPPORT_GPU | |
robertphillips
2013/03/08 19:51:51
0 for both will disable the cache?
bsalomon
2013/03/08 20:01:05
Done.
| |
1037 " [--gpucachesize <size> <count>]: limits gpu cache to size bytes or count ob jects\n" | |
1038 " -1 for either value means use the default\n" | |
1039 #endif | |
1036 " [--help|-h]: show this help message\n" | 1040 " [--help|-h]: show this help message\n" |
1037 " [--hierarchy|--nohierarchy]: whether to use multilevel directory structure\ n" | 1041 " [--hierarchy|--nohierarchy]: whether to use multilevel directory structure\ n" |
1038 " when reading/writing files; default is no\n" | 1042 " when reading/writing files; default is no\n" |
1039 " [--match <substring>]: only run tests whose name includes this substring\n" | 1043 " [--match <substring>]: only run tests whose name includes this substring\n" |
1040 " [--mismatchPath <path>]: write images for tests that failed due to\n" | 1044 " [--mismatchPath <path>]: write images for tests that failed due to\n" |
1041 " pixel mismatched into this directory" | 1045 " pixel mismatched into this directory" |
1042 " [--modulo <remainder> <divisor>]: only run tests for which \n" | 1046 " [--modulo <remainder> <divisor>]: only run tests for which \n" |
1043 " testIndex %% divisor == remainder\n" | 1047 " testIndex %% divisor == remainder\n" |
1044 " [--nopdf]: skip the pdf rendering test pass\n" | 1048 " [--nopdf]: skip the pdf rendering test pass\n" |
1045 " [--nopipe]: Skip SkGPipe replay\n" | 1049 " [--nopipe]: Skip SkGPipe replay\n" |
1046 " [--readPath|-r <path>]: read reference images from this dir, and report\n" | 1050 " [--readPath|-r <path>]: read reference images from this dir, and report\n" |
1047 " any differences between those and the newly generated ones\n" | 1051 " any differences between those and the newly generated ones\n" |
1048 " [--noreplay]: do not exercise SkPicture replay\n" | 1052 " [--noreplay]: do not exercise SkPicture replay\n" |
1049 " [--resourcePath|-i <path>]: directory that stores image resources\n" | 1053 " [--resourcePath|-i <path>]: directory that stores image resources\n" |
1050 " [--nortree]: Do not exercise the R-Tree variant of SkPicture\n" | 1054 " [--nortree]: Do not exercise the R-Tree variant of SkPicture\n" |
1051 " [--noserialize]: do not exercise SkPicture serialization & deserialization\ n" | 1055 " [--noserialize]: do not exercise SkPicture serialization & deserialization\ n" |
1052 " [--notexturecache]: disable the gpu texture cache\n" | |
1053 " [--tiledPipe]: Exercise tiled SkGPipe replay\n" | 1056 " [--tiledPipe]: Exercise tiled SkGPipe replay\n" |
1054 " [--notileGrid]: Do not exercise the tile grid variant of SkPicture\n" | 1057 " [--notileGrid]: Do not exercise the tile grid variant of SkPicture\n" |
1055 " [--tileGridReplayScales <scales>]: Comma separated list of floating-point s cale\n" | 1058 " [--tileGridReplayScales <scales>]: Comma separated list of floating-point s cale\n" |
1056 " factors to be used for tileGrid playback testing. Default value: 1.0\n" | 1059 " factors to be used for tileGrid playback testing. Default value: 1.0\n" |
1057 " [--writeJsonSummary <path>]: write a JSON-formatted result summary to this file\n" | 1060 " [--writeJsonSummary <path>]: write a JSON-formatted result summary to this file\n" |
1058 " [--verbose] print diagnostics (e.g. list each config to be tested)\n" | 1061 " [--verbose] print diagnostics (e.g. list each config to be tested)\n" |
1059 " [--writePath|-w <path>]: write rendered images into this directory\n" | 1062 " [--writePath|-w <path>]: write rendered images into this directory\n" |
1060 " [--writePicturePath|-wp <path>]: write .skp files into this directory\n" | 1063 " [--writePicturePath|-wp <path>]: write .skp files into this directory\n" |
1061 ); | 1064 ); |
1062 } | 1065 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1159 | 1162 |
1160 bool doPDF = true; | 1163 bool doPDF = true; |
1161 bool doReplay = true; | 1164 bool doReplay = true; |
1162 bool doPipe = true; | 1165 bool doPipe = true; |
1163 bool doTiledPipe = false; | 1166 bool doTiledPipe = false; |
1164 bool doSerialize = true; | 1167 bool doSerialize = true; |
1165 bool doDeferred = true; | 1168 bool doDeferred = true; |
1166 bool doRTree = true; | 1169 bool doRTree = true; |
1167 bool doTileGrid = true; | 1170 bool doTileGrid = true; |
1168 bool doVerbose = false; | 1171 bool doVerbose = false; |
1169 #if SK_SUPPORT_GPU | 1172 |
1170 bool disableTextureCache = false; | |
1171 #endif | |
1172 SkTDArray<size_t> configs; | 1173 SkTDArray<size_t> configs; |
1173 SkTDArray<size_t> excludeConfigs; | 1174 SkTDArray<size_t> excludeConfigs; |
1174 SkTDArray<SkScalar> tileGridReplayScales; | 1175 SkTDArray<SkScalar> tileGridReplayScales; |
1175 *tileGridReplayScales.append() = SK_Scalar1; // By default only test at scal e 1.0 | 1176 *tileGridReplayScales.append() = SK_Scalar1; // By default only test at scal e 1.0 |
1176 bool userConfig = false; | 1177 bool userConfig = false; |
1177 | 1178 |
1178 int moduloRemainder = -1; | 1179 int moduloRemainder = -1; |
1179 int moduloDivisor = -1; | 1180 int moduloDivisor = -1; |
1180 | 1181 |
1182 #if SK_SUPPORT_GPU | |
1183 struct { | |
1184 size_t fBytes; | |
1185 int fCount; | |
1186 } gpuCacheSize = { -1, -1 }; // -1s mean use the default | |
1187 #endif | |
1188 | |
1181 const char* const commandName = argv[0]; | 1189 const char* const commandName = argv[0]; |
1182 char* const* stop = argv + argc; | 1190 char* const* stop = argv + argc; |
1183 for (++argv; argv < stop; ++argv) { | 1191 for (++argv; argv < stop; ++argv) { |
1184 if (strcmp(*argv, "--config") == 0) { | 1192 if (strcmp(*argv, "--config") == 0) { |
1185 argv++; | 1193 argv++; |
1186 if (argv < stop) { | 1194 if (argv < stop) { |
1187 int index = findConfig(*argv); | 1195 int index = findConfig(*argv); |
1188 if (index >= 0) { | 1196 if (index >= 0) { |
1189 appendUnique<size_t>(&configs, index); | 1197 appendUnique<size_t>(&configs, index); |
1190 userConfig = true; | 1198 userConfig = true; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1246 } | 1254 } |
1247 if (0 == tileGridReplayScales.count()) { | 1255 if (0 == tileGridReplayScales.count()) { |
1248 // Should have at least one scale | 1256 // Should have at least one scale |
1249 usage(commandName); | 1257 usage(commandName); |
1250 return -1; | 1258 return -1; |
1251 } | 1259 } |
1252 } else if (strcmp(*argv, "--enable-missing-warning") == 0) { | 1260 } else if (strcmp(*argv, "--enable-missing-warning") == 0) { |
1253 notifyMissingReadReference = true; | 1261 notifyMissingReadReference = true; |
1254 } else if (strcmp(*argv, "--forceBWtext") == 0) { | 1262 } else if (strcmp(*argv, "--forceBWtext") == 0) { |
1255 gForceBWtext = true; | 1263 gForceBWtext = true; |
1264 #if SK_SUPPORT_GPU | |
1265 } else if (strcmp(*argv, "--gpucachesize") == 0) { | |
1266 if (stop - argv > 2) { | |
1267 gpuCacheSize.fBytes = atoi(*++argv); | |
1268 gpuCacheSize.fCount = atoi(*++argv); | |
1269 } | |
robertphillips
2013/03/08 19:51:51
else {
SkDebugf("missing arg for --gpucachesiz
bsalomon
2013/03/08 20:00:12
Done.
| |
1270 #endif | |
1256 } else if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) { | 1271 } else if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) { |
1257 usage(commandName); | 1272 usage(commandName); |
1258 return -1; | 1273 return -1; |
1259 } else if (strcmp(*argv, "--hierarchy") == 0) { | 1274 } else if (strcmp(*argv, "--hierarchy") == 0) { |
1260 gmmain.fUseFileHierarchy = true; | 1275 gmmain.fUseFileHierarchy = true; |
1261 } else if (strcmp(*argv, "--nohierarchy") == 0) { | 1276 } else if (strcmp(*argv, "--nohierarchy") == 0) { |
1262 gmmain.fUseFileHierarchy = false; | 1277 gmmain.fUseFileHierarchy = false; |
1263 } else if (strcmp(*argv, "--match") == 0) { | 1278 } else if (strcmp(*argv, "--match") == 0) { |
1264 ++argv; | 1279 ++argv; |
1265 if (argv < stop && **argv) { | 1280 if (argv < stop && **argv) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1297 } else if ((0 == strcmp(*argv, "--resourcePath")) || | 1312 } else if ((0 == strcmp(*argv, "--resourcePath")) || |
1298 (0 == strcmp(*argv, "-i"))) { | 1313 (0 == strcmp(*argv, "-i"))) { |
1299 argv++; | 1314 argv++; |
1300 if (argv < stop && **argv) { | 1315 if (argv < stop && **argv) { |
1301 resourcePath = *argv; | 1316 resourcePath = *argv; |
1302 } | 1317 } |
1303 } else if (strcmp(*argv, "--serialize") == 0) { | 1318 } else if (strcmp(*argv, "--serialize") == 0) { |
1304 doSerialize = true; | 1319 doSerialize = true; |
1305 } else if (strcmp(*argv, "--noserialize") == 0) { | 1320 } else if (strcmp(*argv, "--noserialize") == 0) { |
1306 doSerialize = false; | 1321 doSerialize = false; |
1307 } else if (strcmp(*argv, "--notexturecache") == 0) { | |
1308 #if SK_SUPPORT_GPU | |
1309 disableTextureCache = true; | |
1310 #endif | |
1311 } else if (strcmp(*argv, "--tiledPipe") == 0) { | 1322 } else if (strcmp(*argv, "--tiledPipe") == 0) { |
1312 doTiledPipe = true; | 1323 doTiledPipe = true; |
1313 } else if (!strcmp(*argv, "--verbose") || !strcmp(*argv, "-v")) { | 1324 } else if (!strcmp(*argv, "--verbose") || !strcmp(*argv, "-v")) { |
1314 doVerbose = true; | 1325 doVerbose = true; |
1315 } else if ((0 == strcmp(*argv, "--writePath")) || | 1326 } else if ((0 == strcmp(*argv, "--writePath")) || |
1316 (0 == strcmp(*argv, "-w"))) { | 1327 (0 == strcmp(*argv, "-w"))) { |
1317 argv++; | 1328 argv++; |
1318 if (argv < stop && **argv) { | 1329 if (argv < stop && **argv) { |
1319 writePath = *argv; | 1330 writePath = *argv; |
1320 } | 1331 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1401 } | 1412 } |
1402 | 1413 |
1403 // Accumulate success of all tests. | 1414 // Accumulate success of all tests. |
1404 int testsRun = 0; | 1415 int testsRun = 0; |
1405 int testsPassed = 0; | 1416 int testsPassed = 0; |
1406 int testsFailed = 0; | 1417 int testsFailed = 0; |
1407 int testsMissingReferenceImages = 0; | 1418 int testsMissingReferenceImages = 0; |
1408 | 1419 |
1409 #if SK_SUPPORT_GPU | 1420 #if SK_SUPPORT_GPU |
1410 GrContextFactory* grFactory = new GrContextFactory; | 1421 GrContextFactory* grFactory = new GrContextFactory; |
1411 if (disableTextureCache) { | |
1412 skiagm::GetGr()->setTextureCacheLimits(0, 0); | |
1413 } | |
1414 #endif | 1422 #endif |
1415 | 1423 |
1416 int gmIndex = -1; | 1424 int gmIndex = -1; |
1417 SkString moduloStr; | 1425 SkString moduloStr; |
1418 | 1426 |
1419 // If we will be writing out files, prepare subdirectories. | 1427 // If we will be writing out files, prepare subdirectories. |
1420 if (writePath) { | 1428 if (writePath) { |
1421 if (!sk_mkdir(writePath)) { | 1429 if (!sk_mkdir(writePath)) { |
1422 return -1; | 1430 return -1; |
1423 } | 1431 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1498 desc.fHeight = gm->getISize().height(); | 1506 desc.fHeight = gm->getISize().height(); |
1499 desc.fSampleCnt = config.fSampleCnt; | 1507 desc.fSampleCnt = config.fSampleCnt; |
1500 GrTexture* tex = gr->createUncachedTexture(desc, NULL, 0); | 1508 GrTexture* tex = gr->createUncachedTexture(desc, NULL, 0); |
1501 if (tex) { | 1509 if (tex) { |
1502 rt.reset(tex->asRenderTarget()); | 1510 rt.reset(tex->asRenderTarget()); |
1503 rt.get()->ref(); | 1511 rt.get()->ref(); |
1504 tex->unref(); | 1512 tex->unref(); |
1505 autogr.set(gr); | 1513 autogr.set(gr); |
1506 renderTarget = rt.get(); | 1514 renderTarget = rt.get(); |
1507 grSuccess = NULL != renderTarget; | 1515 grSuccess = NULL != renderTarget; |
1508 } | 1516 } |
robertphillips
2013/03/08 19:51:51
// Set the passed in texture cache limits?
bsalomon
2013/03/08 20:00:12
Done.
| |
1517 size_t bytes; | |
1518 int count; | |
1519 gr->getTextureCacheLimits(&count, &bytes); | |
1520 if (-1 != gpuCacheSize.fBytes) { | |
1521 bytes = gpuCacheSize.fBytes; | |
1522 } | |
1523 if (-1 != gpuCacheSize.fCount) { | |
1524 count = gpuCacheSize.fCount; | |
1525 } | |
1526 gr->setTextureCacheLimits(count, bytes); | |
1509 } | 1527 } |
1510 if (!grSuccess) { | 1528 if (!grSuccess) { |
1511 renderErrors |= kNoGpuContext_ErrorBitmask; | 1529 renderErrors |= kNoGpuContext_ErrorBitmask; |
1512 } | 1530 } |
1513 } | 1531 } |
1514 #endif | 1532 #endif |
1515 | 1533 |
1516 SkBitmap comparisonBitmap; | 1534 SkBitmap comparisonBitmap; |
1517 | 1535 |
1518 if (kEmptyErrorBitfield == renderErrors) { | 1536 if (kEmptyErrorBitfield == renderErrors) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1701 SkGraphics::Term(); | 1719 SkGraphics::Term(); |
1702 | 1720 |
1703 return (0 == testsFailed) ? 0 : -1; | 1721 return (0 == testsFailed) ? 0 : -1; |
1704 } | 1722 } |
1705 | 1723 |
1706 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1724 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
1707 int main(int argc, char * const argv[]) { | 1725 int main(int argc, char * const argv[]) { |
1708 return tool_main(argc, (char**) argv); | 1726 return tool_main(argc, (char**) argv); |
1709 } | 1727 } |
1710 #endif | 1728 #endif |
OLD | NEW |