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

Side by Side Diff: bench/benchmain.cpp

Issue 12635009: Add --gpucache size to bench. (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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "BenchTimer.h" 10 #include "BenchTimer.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return false; 274 return false;
275 } 275 }
276 } 276 }
277 return true; 277 return true;
278 } 278 }
279 279
280 static void help() { 280 static void help() {
281 SkDebugf("Usage: bench [-o outDir] [--repeat nr] [--logPerIter] " 281 SkDebugf("Usage: bench [-o outDir] [--repeat nr] [--logPerIter] "
282 "[--timers [wcgWC]*] [--rotate]\n" 282 "[--timers [wcgWC]*] [--rotate]\n"
283 " [--scale] [--clip] [--min] [--forceAA 1|0] [--forceFilter 1|0] \n" 283 " [--scale] [--clip] [--min] [--forceAA 1|0] [--forceFilter 1|0] \n"
284 " [--forceDither 1|0] [--forceBlend 1|0] [--strokeWidth width]\n " 284 " [--forceDither 1|0] [--forceBlend 1|0]"
285 " [--match name] [--mode normal|deferred|deferredSilent|record|p icturerecord]\n" 285 #if SK_SUPPORT_GPU
286 " [--gpuCacheSize <bytes> <count>]"
287 #endif
288 "\n"
289 " [--strokeWidth width] [--match name]\n"
290 " [--mode normal|deferred|deferredSilent|record|picturerecord]\n "
286 " [--config 8888|565|GPU|ANGLE|NULLGPU] [-Dfoo bar] [--logFile f ilename]\n" 291 " [--config 8888|565|GPU|ANGLE|NULLGPU] [-Dfoo bar] [--logFile f ilename]\n"
287 " [-h|--help]"); 292 " [-h|--help]");
288 SkDebugf("\n\n"); 293 SkDebugf("\n\n");
289 SkDebugf(" -o outDir : Image of each bench will be put in outDir.\n"); 294 SkDebugf(" -o outDir : Image of each bench will be put in outDir.\n");
290 SkDebugf(" --repeat nr : Each bench repeats for nr times.\n"); 295 SkDebugf(" --repeat nr : Each bench repeats for nr times.\n");
291 SkDebugf(" --logPerIter : " 296 SkDebugf(" --logPerIter : "
292 "Log each repeat timer instead of mean, default is disabled.\n"); 297 "Log each repeat timer instead of mean, default is disabled.\n");
293 SkDebugf(" --timers [wcgWC]* : " 298 SkDebugf(" --timers [wcgWC]* : "
294 "Display wall, cpu, gpu, truncated wall or truncated cpu time for e ach bench.\n"); 299 "Display wall, cpu, gpu, truncated wall or truncated cpu time for e ach bench.\n");
295 SkDebugf(" --rotate : Rotate before each bench runs.\n"); 300 SkDebugf(" --rotate : Rotate before each bench runs.\n");
296 SkDebugf(" --scale : Scale before each bench runs.\n"); 301 SkDebugf(" --scale : Scale before each bench runs.\n");
297 SkDebugf(" --clip : Clip before each bench runs.\n"); 302 SkDebugf(" --clip : Clip before each bench runs.\n");
298 SkDebugf(" --min : Print the minimum times (instead of average).\n"); 303 SkDebugf(" --min : Print the minimum times (instead of average).\n");
299 SkDebugf(" --forceAA 1|0 : " 304 SkDebugf(" --forceAA 1|0 : "
300 "Enable/disable anti-aliased, default is enabled.\n"); 305 "Enable/disable anti-aliased, default is enabled.\n");
301 SkDebugf(" --forceFilter 1|0 : " 306 SkDebugf(" --forceFilter 1|0 : "
302 "Enable/disable bitmap filtering, default is disabled.\n"); 307 "Enable/disable bitmap filtering, default is disabled.\n");
303 SkDebugf(" --forceDither 1|0 : " 308 SkDebugf(" --forceDither 1|0 : "
304 "Enable/disable dithering, default is disabled.\n"); 309 "Enable/disable dithering, default is disabled.\n");
305 SkDebugf(" --forceBlend 1|0 : " 310 SkDebugf(" --forceBlend 1|0 : "
306 "Enable/disable dithering, default is disabled.\n"); 311 "Enable/disable dithering, default is disabled.\n");
312 #if SK_SUPPORT_GPU
313 SkDebugf(" --gpuCacheSize <bytes> <count>: "
314 "limits gpu cache to bytes size or object count.\n");
315 SkDebugf(" -1 for either value means use the default. 0 for either disa bles the cache.\n");
316 #endif
307 SkDebugf(" --strokeWidth width : The width for path stroke.\n"); 317 SkDebugf(" --strokeWidth width : The width for path stroke.\n");
308 SkDebugf(" --match name : Only run bench whose name is matched.\n"); 318 SkDebugf(" --match name : Only run bench whose name is matched.\n");
309 SkDebugf(" --mode normal|deferred|deferredSilent|record|picturerecord :\n " 319 SkDebugf(" --mode normal|deferred|deferredSilent|record|picturerecord :\n "
310 " Run in the corresponding mode\n" 320 " Run in the corresponding mode\n"
311 " normal, Use a normal canvas to draw to;\n" 321 " normal, Use a normal canvas to draw to;\n"
312 " deferred, Use a deferrred canvas when drawing;\n" 322 " deferred, Use a deferrred canvas when drawing;\n"
313 " deferredSilent, deferred with silent playback;\n" 323 " deferredSilent, deferred with silent playback;\n"
314 " record, Benchmark the time to record to an SkPict ure;\n" 324 " record, Benchmark the time to record to an SkPict ure;\n"
315 " picturerecord, Benchmark the time to do record fr om a \n" 325 " picturerecord, Benchmark the time to do record fr om a \n"
316 " SkPicture to a SkPicture.\n"); 326 " SkPicture to a SkPicture.\n");
(...skipping 26 matching lines...) Expand all
343 bool timerWall = false; 353 bool timerWall = false;
344 bool truncatedTimerWall = false; 354 bool truncatedTimerWall = false;
345 bool timerCpu = true; 355 bool timerCpu = true;
346 bool truncatedTimerCpu = false; 356 bool truncatedTimerCpu = false;
347 bool timerGpu = true; 357 bool timerGpu = true;
348 bool doScale = false; 358 bool doScale = false;
349 bool doRotate = false; 359 bool doRotate = false;
350 bool doClip = false; 360 bool doClip = false;
351 bool printMin = false; 361 bool printMin = false;
352 bool hasStrokeWidth = false; 362 bool hasStrokeWidth = false;
363
364 #if SK_SUPPORT_GPU
365 struct {
366 size_t fBytes;
367 int fCount;
368 } gpuCacheSize = { -1, -1 }; // -1s mean use the default
369 #endif
370
353 float strokeWidth; 371 float strokeWidth;
354 SkTDArray<const char*> fMatches; 372 SkTDArray<const char*> fMatches;
355 benchModes benchMode = kNormal_benchModes; 373 benchModes benchMode = kNormal_benchModes;
356 SkString perIterTimeformat("%.2f"); 374 SkString perIterTimeformat("%.2f");
357 SkString normalTimeFormat("%6.2f"); 375 SkString normalTimeFormat("%6.2f");
358 376
359 SkString outDir; 377 SkString outDir;
360 SkBitmap::Config outConfig = SkBitmap::kNo_Config; 378 SkBitmap::Config outConfig = SkBitmap::kNo_Config;
361 const char* configName = ""; 379 const char* configName = "";
362 Backend backend = kRaster_Backend; // for warning 380 Backend backend = kRaster_Backend; // for warning
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 458 }
441 forceDither = tmp ? SkTriState::kTrue : SkTriState::kFalse; 459 forceDither = tmp ? SkTriState::kTrue : SkTriState::kFalse;
442 } else if (strcmp(*argv, "--forceBlend") == 0) { 460 } else if (strcmp(*argv, "--forceBlend") == 0) {
443 bool wantAlpha = false; 461 bool wantAlpha = false;
444 if (!parse_bool_arg(++argv, stop, &wantAlpha)) { 462 if (!parse_bool_arg(++argv, stop, &wantAlpha)) {
445 logger.logError("missing arg for --forceBlend\n"); 463 logger.logError("missing arg for --forceBlend\n");
446 help(); 464 help();
447 return -1; 465 return -1;
448 } 466 }
449 forceAlpha = wantAlpha ? 0x80 : 0xFF; 467 forceAlpha = wantAlpha ? 0x80 : 0xFF;
468 #if SK_SUPPORT_GPU
469 } else if (strcmp(*argv, "--gpuCacheSize") == 0) {
470 if (stop - argv > 2) {
471 gpuCacheSize.fBytes = atoi(*++argv);
472 gpuCacheSize.fCount = atoi(*++argv);
473 } else {
474 SkDebugf("missing arg for --gpuCacheSize\n");
475 help();
476 return -1;
477 }
478 #endif
450 } else if (strcmp(*argv, "--mode") == 0) { 479 } else if (strcmp(*argv, "--mode") == 0) {
451 argv++; 480 argv++;
452 if (argv < stop) { 481 if (argv < stop) {
453 if (strcmp(*argv, "normal") == 0) { 482 if (strcmp(*argv, "normal") == 0) {
454 benchMode = kNormal_benchModes; 483 benchMode = kNormal_benchModes;
455 } else if (strcmp(*argv, "deferred") == 0) { 484 } else if (strcmp(*argv, "deferred") == 0) {
456 benchMode = kDeferred_benchModes; 485 benchMode = kDeferred_benchModes;
457 } else if (strcmp(*argv, "deferredSilent") == 0) { 486 } else if (strcmp(*argv, "deferredSilent") == 0) {
458 benchMode = kDeferredSilent_benchModes; 487 benchMode = kDeferredSilent_benchModes;
459 } else if (strcmp(*argv, "record") == 0) { 488 } else if (strcmp(*argv, "record") == 0) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 #if defined(SK_DEBUG) 643 #if defined(SK_DEBUG)
615 str.append(" DEBUG"); 644 str.append(" DEBUG");
616 #endif 645 #endif
617 str.append("\n"); 646 str.append("\n");
618 logger.logProgress(str); 647 logger.logProgress(str);
619 } 648 }
620 649
621 SkTArray<BenchTimer*> timers(SK_ARRAY_COUNT(gConfigs)); 650 SkTArray<BenchTimer*> timers(SK_ARRAY_COUNT(gConfigs));
622 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) { 651 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) {
623 #if SK_SUPPORT_GPU 652 #if SK_SUPPORT_GPU
624 SkGLContextHelper* ctx = NULL; 653 SkGLContextHelper* glCtx = NULL;
625 if (kGPU_Backend == gConfigs[i].fBackend) { 654 if (kGPU_Backend == gConfigs[i].fBackend) {
626 ctx = gContextFactory.getGLContext(gConfigs[i].fContextType); 655 GrContext* context = gContextFactory.get(gConfigs[i].fContextType);
656 if (NULL != context) {
657 // Set the user specified cache limits if non-default.
658 size_t bytes;
659 int count;
660 context->getTextureCacheLimits(&count, &bytes);
661 if (-1 != gpuCacheSize.fBytes) {
662 bytes = gpuCacheSize.fBytes;
663 }
664 if (-1 != gpuCacheSize.fCount) {
665 count = gpuCacheSize.fCount;
666 }
667 context->setTextureCacheLimits(count, bytes);
668 }
669 glCtx = gContextFactory.getGLContext(gConfigs[i].fContextType);
627 } 670 }
628 timers.push_back(SkNEW_ARGS(BenchTimer, (ctx))); 671 timers.push_back(SkNEW_ARGS(BenchTimer, (glCtx)));
629 #else 672 #else
630 timers.push_back(SkNEW(BenchTimer)); 673 timers.push_back(SkNEW(BenchTimer));
631 #endif 674 #endif
632 } 675 }
633 676
634 Iter iter(&defineDict); 677 Iter iter(&defineDict);
635 SkBenchmark* bench; 678 SkBenchmark* bench;
636 while ((bench = iter.next()) != NULL) { 679 while ((bench = iter.next()) != NULL) {
637 SkAutoTUnref<SkBenchmark> benchUnref(bench); 680 SkAutoTUnref<SkBenchmark> benchUnref(bench);
638 681
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 } 883 }
841 884
842 return 0; 885 return 0;
843 } 886 }
844 887
845 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 888 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
846 int main(int argc, char * const argv[]) { 889 int main(int argc, char * const argv[]) {
847 return tool_main(argc, (char**) argv); 890 return tool_main(argc, (char**) argv);
848 } 891 }
849 #endif 892 #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