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

Side by Side Diff: gm/gmmain.cpp

Issue 12717002: Make GPU cache size cmd line configurable in GM. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
1037 " [--gpuCacheSize <bytes> <count>]: limits gpu cache to byte size or object c ount\n"
1038 " -1 for either value means use the default. 0 for either disables the ca che.\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
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
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 } else {
1270 SkDebugf("missing arg for --gpuCacheSize\n");
1271 usage(commandName);
1272 return -1;
1273 }
1274 #endif
1256 } else if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) { 1275 } else if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) {
1257 usage(commandName); 1276 usage(commandName);
1258 return -1; 1277 return -1;
1259 } else if (strcmp(*argv, "--hierarchy") == 0) { 1278 } else if (strcmp(*argv, "--hierarchy") == 0) {
1260 gmmain.fUseFileHierarchy = true; 1279 gmmain.fUseFileHierarchy = true;
1261 } else if (strcmp(*argv, "--nohierarchy") == 0) { 1280 } else if (strcmp(*argv, "--nohierarchy") == 0) {
1262 gmmain.fUseFileHierarchy = false; 1281 gmmain.fUseFileHierarchy = false;
1263 } else if (strcmp(*argv, "--match") == 0) { 1282 } else if (strcmp(*argv, "--match") == 0) {
1264 ++argv; 1283 ++argv;
1265 if (argv < stop && **argv) { 1284 if (argv < stop && **argv) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 } else if ((0 == strcmp(*argv, "--resourcePath")) || 1316 } else if ((0 == strcmp(*argv, "--resourcePath")) ||
1298 (0 == strcmp(*argv, "-i"))) { 1317 (0 == strcmp(*argv, "-i"))) {
1299 argv++; 1318 argv++;
1300 if (argv < stop && **argv) { 1319 if (argv < stop && **argv) {
1301 resourcePath = *argv; 1320 resourcePath = *argv;
1302 } 1321 }
1303 } else if (strcmp(*argv, "--serialize") == 0) { 1322 } else if (strcmp(*argv, "--serialize") == 0) {
1304 doSerialize = true; 1323 doSerialize = true;
1305 } else if (strcmp(*argv, "--noserialize") == 0) { 1324 } else if (strcmp(*argv, "--noserialize") == 0) {
1306 doSerialize = false; 1325 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) { 1326 } else if (strcmp(*argv, "--tiledPipe") == 0) {
1312 doTiledPipe = true; 1327 doTiledPipe = true;
1313 } else if (!strcmp(*argv, "--verbose") || !strcmp(*argv, "-v")) { 1328 } else if (!strcmp(*argv, "--verbose") || !strcmp(*argv, "-v")) {
1314 doVerbose = true; 1329 doVerbose = true;
1315 } else if ((0 == strcmp(*argv, "--writePath")) || 1330 } else if ((0 == strcmp(*argv, "--writePath")) ||
1316 (0 == strcmp(*argv, "-w"))) { 1331 (0 == strcmp(*argv, "-w"))) {
1317 argv++; 1332 argv++;
1318 if (argv < stop && **argv) { 1333 if (argv < stop && **argv) {
1319 writePath = *argv; 1334 writePath = *argv;
1320 } 1335 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 } 1416 }
1402 1417
1403 // Accumulate success of all tests. 1418 // Accumulate success of all tests.
1404 int testsRun = 0; 1419 int testsRun = 0;
1405 int testsPassed = 0; 1420 int testsPassed = 0;
1406 int testsFailed = 0; 1421 int testsFailed = 0;
1407 int testsMissingReferenceImages = 0; 1422 int testsMissingReferenceImages = 0;
1408 1423
1409 #if SK_SUPPORT_GPU 1424 #if SK_SUPPORT_GPU
1410 GrContextFactory* grFactory = new GrContextFactory; 1425 GrContextFactory* grFactory = new GrContextFactory;
1411 if (disableTextureCache) {
1412 skiagm::GetGr()->setTextureCacheLimits(0, 0);
1413 }
1414 #endif 1426 #endif
1415 1427
1416 int gmIndex = -1; 1428 int gmIndex = -1;
1417 SkString moduloStr; 1429 SkString moduloStr;
1418 1430
1419 // If we will be writing out files, prepare subdirectories. 1431 // If we will be writing out files, prepare subdirectories.
1420 if (writePath) { 1432 if (writePath) {
1421 if (!sk_mkdir(writePath)) { 1433 if (!sk_mkdir(writePath)) {
1422 return -1; 1434 return -1;
1423 } 1435 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 desc.fSampleCnt = config.fSampleCnt; 1511 desc.fSampleCnt = config.fSampleCnt;
1500 GrTexture* tex = gr->createUncachedTexture(desc, NULL, 0); 1512 GrTexture* tex = gr->createUncachedTexture(desc, NULL, 0);
1501 if (tex) { 1513 if (tex) {
1502 rt.reset(tex->asRenderTarget()); 1514 rt.reset(tex->asRenderTarget());
1503 rt.get()->ref(); 1515 rt.get()->ref();
1504 tex->unref(); 1516 tex->unref();
1505 autogr.set(gr); 1517 autogr.set(gr);
1506 renderTarget = rt.get(); 1518 renderTarget = rt.get();
1507 grSuccess = NULL != renderTarget; 1519 grSuccess = NULL != renderTarget;
1508 } 1520 }
1521 // Set the user specified cache limits if non-default.
1522 size_t bytes;
1523 int count;
1524 gr->getTextureCacheLimits(&count, &bytes);
1525 if (-1 != gpuCacheSize.fBytes) {
1526 bytes = gpuCacheSize.fBytes;
1527 }
1528 if (-1 != gpuCacheSize.fCount) {
1529 count = gpuCacheSize.fCount;
1530 }
1531 gr->setTextureCacheLimits(count, bytes);
1509 } 1532 }
1510 if (!grSuccess) { 1533 if (!grSuccess) {
1511 renderErrors |= kNoGpuContext_ErrorBitmask; 1534 renderErrors |= kNoGpuContext_ErrorBitmask;
1512 } 1535 }
1513 } 1536 }
1514 #endif 1537 #endif
1515 1538
1516 SkBitmap comparisonBitmap; 1539 SkBitmap comparisonBitmap;
1517 1540
1518 if (kEmptyErrorBitfield == renderErrors) { 1541 if (kEmptyErrorBitfield == renderErrors) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 SkGraphics::Term(); 1724 SkGraphics::Term();
1702 1725
1703 return (0 == testsFailed) ? 0 : -1; 1726 return (0 == testsFailed) ? 0 : -1;
1704 } 1727 }
1705 1728
1706 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 1729 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
1707 int main(int argc, char * const argv[]) { 1730 int main(int argc, char * const argv[]) {
1708 return tool_main(argc, (char**) argv); 1731 return tool_main(argc, (char**) argv);
1709 } 1732 }
1710 #endif 1733 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698