| 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 #include "BenchTimer.h" | 8 #include "BenchTimer.h" |
| 9 #include "ResultsWriter.h" | 9 #include "ResultsWriter.h" |
| 10 #include "SkBenchLogger.h" | 10 #include "SkBenchLogger.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 kDeferredSilent_BenchMode, | 42 kDeferredSilent_BenchMode, |
| 43 kRecord_BenchMode, | 43 kRecord_BenchMode, |
| 44 kPictureRecord_BenchMode | 44 kPictureRecord_BenchMode |
| 45 }; | 45 }; |
| 46 const char* BenchMode_Name[] = { | 46 const char* BenchMode_Name[] = { |
| 47 "normal", "deferred", "deferredSilent", "record", "picturerecord" | 47 "normal", "deferred", "deferredSilent", "record", "picturerecord" |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 static const char kDefaultsConfigStr[] = "defaults"; | 50 static const char kDefaultsConfigStr[] = "defaults"; |
| 51 | 51 |
| 52 #if SK_SUPPORT_GPU |
| 53 static const char kGpuApiNameGL[] = "gl"; |
| 54 static const char kGpuApiNameGLES[] = "gles"; |
| 55 #endif |
| 56 |
| 52 /////////////////////////////////////////////////////////////////////////////// | 57 /////////////////////////////////////////////////////////////////////////////// |
| 53 | 58 |
| 54 class Iter { | 59 class Iter { |
| 55 public: | 60 public: |
| 56 Iter() : fBenches(BenchRegistry::Head()), fGMs(skiagm::GMRegistry::Head()) {
} | 61 Iter() : fBenches(BenchRegistry::Head()), fGMs(skiagm::GMRegistry::Head()) {
} |
| 57 | 62 |
| 58 SkBenchmark* next() { | 63 SkBenchmark* next() { |
| 59 if (fBenches) { | 64 if (fBenches) { |
| 60 BenchRegistry::Factory f = fBenches->factory(); | 65 BenchRegistry::Factory f = fBenches->factory(); |
| 61 fBenches = fBenches->next(); | 66 fBenches = fBenches->next(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 236 |
| 232 DEFINE_bool(rotate, false, "Rotate canvas before bench run?"); | 237 DEFINE_bool(rotate, false, "Rotate canvas before bench run?"); |
| 233 DEFINE_bool(scale, false, "Scale canvas before bench run?"); | 238 DEFINE_bool(scale, false, "Scale canvas before bench run?"); |
| 234 DEFINE_bool(clip, false, "Clip canvas before bench run?"); | 239 DEFINE_bool(clip, false, "Clip canvas before bench run?"); |
| 235 | 240 |
| 236 DEFINE_bool(forceAA, true, "Force anti-aliasing?"); | 241 DEFINE_bool(forceAA, true, "Force anti-aliasing?"); |
| 237 DEFINE_bool(forceFilter, false, "Force bitmap filtering?"); | 242 DEFINE_bool(forceFilter, false, "Force bitmap filtering?"); |
| 238 DEFINE_string(forceDither, "default", "Force dithering: true, false, or default?
"); | 243 DEFINE_string(forceDither, "default", "Force dithering: true, false, or default?
"); |
| 239 DEFINE_bool(forceBlend, false, "Force alpha blending?"); | 244 DEFINE_bool(forceBlend, false, "Force alpha blending?"); |
| 240 | 245 |
| 246 DEFINE_string(forceGpuApi, "", "Force use of specific gpu API. Using \"gl\" " |
| 247 "forces OpenGL API. Using \"gles\" forces OpenGL ES API. " |
| 248 "Defaults to empty string, which selects the API native to the " |
| 249 "system."); |
| 241 DEFINE_int32(gpuCacheBytes, -1, "GPU cache size limit in bytes. 0 to disable ca
che."); | 250 DEFINE_int32(gpuCacheBytes, -1, "GPU cache size limit in bytes. 0 to disable ca
che."); |
| 242 DEFINE_int32(gpuCacheCount, -1, "GPU cache size limit in object count. 0 to dis
able cache."); | 251 DEFINE_int32(gpuCacheCount, -1, "GPU cache size limit in object count. 0 to dis
able cache."); |
| 243 | 252 |
| 244 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); | 253 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); |
| 245 DEFINE_string(match, "", "[~][^]substring[$] [...] of test name to run.\n" | 254 DEFINE_string(match, "", "[~][^]substring[$] [...] of test name to run.\n" |
| 246 "Multiple matches may be separated by spaces.\n" | 255 "Multiple matches may be separated by spaces.\n" |
| 247 "~ causes a matching test to always be skipped\n" | 256 "~ causes a matching test to always be skipped\n" |
| 248 "^ requires the start of the test to match\n" | 257 "^ requires the start of the test to match\n" |
| 249 "$ requires the end of the test to match\n" | 258 "$ requires the end of the test to match\n" |
| 250 "^ and $ requires an exact match\n" | 259 "^ and $ requires an exact match\n" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 --i; | 369 --i; |
| 361 } | 370 } |
| 362 } | 371 } |
| 363 } | 372 } |
| 364 // Set the resource path. | 373 // Set the resource path. |
| 365 if (!FLAGS_resourcePath.isEmpty()) { | 374 if (!FLAGS_resourcePath.isEmpty()) { |
| 366 SkBenchmark::SetResourcePath(FLAGS_resourcePath[0]); | 375 SkBenchmark::SetResourcePath(FLAGS_resourcePath[0]); |
| 367 } | 376 } |
| 368 | 377 |
| 369 #if SK_SUPPORT_GPU | 378 #if SK_SUPPORT_GPU |
| 379 GrGLStandard forcedGpuApi = kNone_GrGLStandard; |
| 380 if (1 == FLAGS_forceGpuApi.count()) { |
| 381 if (strcmp(FLAGS_forceGpuApi[0], kGpuApiNameGL) == 0) { |
| 382 forcedGpuApi = kGL_GrGLStandard; |
| 383 } else if (strcmp(FLAGS_forceGpuApi[0], kGpuApiNameGLES) == 0) { |
| 384 forcedGpuApi = kGLES_GrGLStandard; |
| 385 } |
| 386 } |
| 387 |
| 370 for (int i = 0; i < configs.count(); ++i) { | 388 for (int i = 0; i < configs.count(); ++i) { |
| 371 const Config& config = gConfigs[configs[i]]; | 389 const Config& config = gConfigs[configs[i]]; |
| 372 | 390 |
| 373 if (SkBenchmark::kGPU_Backend == config.backend) { | 391 if (SkBenchmark::kGPU_Backend == config.backend) { |
| 374 GrContext* context = gContextFactory.get(config.contextType); | 392 GrContext* context = gContextFactory.get(config.contextType, forcedG
puApi); |
| 375 if (NULL == context) { | 393 if (NULL == context) { |
| 376 SkDebugf("GrContext could not be created for config %s. Config w
ill be skipped.\n", | 394 SkDebugf("GrContext could not be created for config %s. Config w
ill be skipped.\n", |
| 377 config.name); | 395 config.name); |
| 378 configs.remove(i); | 396 configs.remove(i); |
| 379 --i; | 397 --i; |
| 380 continue; | 398 continue; |
| 381 } | 399 } |
| 382 if (config.sampleCount > context->getMaxSampleCount()){ | 400 if (config.sampleCount > context->getMaxSampleCount()){ |
| 383 SkDebugf( | 401 SkDebugf( |
| 384 "Sample count (%d) for config %s is not supported. Config wi
ll be skipped.\n", | 402 "Sample count (%d) for config %s is not supported. Config wi
ll be skipped.\n", |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 writer.option("build", "RELEASE"); | 442 writer.option("build", "RELEASE"); |
| 425 #endif | 443 #endif |
| 426 | 444 |
| 427 // Set texture cache limits if non-default. | 445 // Set texture cache limits if non-default. |
| 428 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) { | 446 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) { |
| 429 #if SK_SUPPORT_GPU | 447 #if SK_SUPPORT_GPU |
| 430 const Config& config = gConfigs[i]; | 448 const Config& config = gConfigs[i]; |
| 431 if (SkBenchmark::kGPU_Backend != config.backend) { | 449 if (SkBenchmark::kGPU_Backend != config.backend) { |
| 432 continue; | 450 continue; |
| 433 } | 451 } |
| 434 GrContext* context = gContextFactory.get(config.contextType); | 452 GrContext* context = gContextFactory.get(config.contextType, forcedGpuAp
i); |
| 435 if (NULL == context) { | 453 if (NULL == context) { |
| 436 continue; | 454 continue; |
| 437 } | 455 } |
| 438 | 456 |
| 439 size_t bytes; | 457 size_t bytes; |
| 440 int count; | 458 int count; |
| 441 context->getResourceCacheLimits(&count, &bytes); | 459 context->getResourceCacheLimits(&count, &bytes); |
| 442 if (-1 != FLAGS_gpuCacheBytes) { | 460 if (-1 != FLAGS_gpuCacheBytes) { |
| 443 bytes = static_cast<size_t>(FLAGS_gpuCacheBytes); | 461 bytes = static_cast<size_t>(FLAGS_gpuCacheBytes); |
| 444 } | 462 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 470 const Config& config = gConfigs[configIndex]; | 488 const Config& config = gConfigs[configIndex]; |
| 471 | 489 |
| 472 if (!bench->isSuitableFor(config.backend)) { | 490 if (!bench->isSuitableFor(config.backend)) { |
| 473 continue; | 491 continue; |
| 474 } | 492 } |
| 475 | 493 |
| 476 GrContext* context = NULL; | 494 GrContext* context = NULL; |
| 477 #if SK_SUPPORT_GPU | 495 #if SK_SUPPORT_GPU |
| 478 SkGLContextHelper* glContext = NULL; | 496 SkGLContextHelper* glContext = NULL; |
| 479 if (SkBenchmark::kGPU_Backend == config.backend) { | 497 if (SkBenchmark::kGPU_Backend == config.backend) { |
| 480 context = gContextFactory.get(config.contextType); | 498 context = gContextFactory.get(config.contextType, forcedGpuApi); |
| 481 if (NULL == context) { | 499 if (NULL == context) { |
| 482 continue; | 500 continue; |
| 483 } | 501 } |
| 484 glContext = gContextFactory.getGLContext(config.contextType); | 502 glContext = gContextFactory.getGLContext(config.contextType); |
| 485 } | 503 } |
| 486 #endif | 504 #endif |
| 487 | 505 |
| 488 SkAutoTUnref<SkCanvas> canvas; | 506 SkAutoTUnref<SkCanvas> canvas; |
| 489 SkAutoTUnref<SkPicture> recordFrom; | 507 SkAutoTUnref<SkPicture> recordFrom; |
| 490 SkPictureRecorder recorderTo; | 508 SkPictureRecorder recorderTo; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 gContextFactory.destroyContexts(); | 721 gContextFactory.destroyContexts(); |
| 704 #endif | 722 #endif |
| 705 return 0; | 723 return 0; |
| 706 } | 724 } |
| 707 | 725 |
| 708 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 726 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 709 int main(int argc, char * const argv[]) { | 727 int main(int argc, char * const argv[]) { |
| 710 return tool_main(argc, (char**) argv); | 728 return tool_main(argc, (char**) argv); |
| 711 } | 729 } |
| 712 #endif | 730 #endif |
| OLD | NEW |