| 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 "BenchLogger.h" | 8 #include "BenchLogger.h" |
| 9 #include "Benchmark.h" | 9 #include "Benchmark.h" |
| 10 #include "CrashHandler.h" | 10 #include "CrashHandler.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 kDeferredSilent_BenchMode, | 43 kDeferredSilent_BenchMode, |
| 44 kRecord_BenchMode, | 44 kRecord_BenchMode, |
| 45 kPictureRecord_BenchMode | 45 kPictureRecord_BenchMode |
| 46 }; | 46 }; |
| 47 const char* BenchMode_Name[] = { | 47 const char* BenchMode_Name[] = { |
| 48 "normal", "deferred", "deferredSilent", "record", "picturerecord" | 48 "normal", "deferred", "deferredSilent", "record", "picturerecord" |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 static const char kDefaultsConfigStr[] = "defaults"; | 51 static const char kDefaultsConfigStr[] = "defaults"; |
| 52 | 52 |
| 53 #if SK_SUPPORT_GPU | |
| 54 static const char kGpuAPINameGL[] = "gl"; | |
| 55 static const char kGpuAPINameGLES[] = "gles"; | |
| 56 #endif | |
| 57 | |
| 58 /////////////////////////////////////////////////////////////////////////////// | 53 /////////////////////////////////////////////////////////////////////////////// |
| 59 | 54 |
| 60 class Iter { | 55 class Iter { |
| 61 public: | 56 public: |
| 62 Iter() : fBenches(BenchRegistry::Head()), fGMs(skiagm::GMRegistry::Head()) {
} | 57 Iter() : fBenches(BenchRegistry::Head()), fGMs(skiagm::GMRegistry::Head()) {
} |
| 63 | 58 |
| 64 Benchmark* next() { | 59 Benchmark* next() { |
| 65 if (fBenches) { | 60 if (fBenches) { |
| 66 BenchRegistry::Factory f = fBenches->factory(); | 61 BenchRegistry::Factory f = fBenches->factory(); |
| 67 fBenches = fBenches->next(); | 62 fBenches = fBenches->next(); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 220 |
| 226 DEFINE_bool(rotate, false, "Rotate canvas before bench run?"); | 221 DEFINE_bool(rotate, false, "Rotate canvas before bench run?"); |
| 227 DEFINE_bool(scale, false, "Scale canvas before bench run?"); | 222 DEFINE_bool(scale, false, "Scale canvas before bench run?"); |
| 228 DEFINE_bool(clip, false, "Clip canvas before bench run?"); | 223 DEFINE_bool(clip, false, "Clip canvas before bench run?"); |
| 229 | 224 |
| 230 DEFINE_bool(forceAA, true, "Force anti-aliasing?"); | 225 DEFINE_bool(forceAA, true, "Force anti-aliasing?"); |
| 231 DEFINE_bool(forceFilter, false, "Force bitmap filtering?"); | 226 DEFINE_bool(forceFilter, false, "Force bitmap filtering?"); |
| 232 DEFINE_string(forceDither, "default", "Force dithering: true, false, or default?
"); | 227 DEFINE_string(forceDither, "default", "Force dithering: true, false, or default?
"); |
| 233 DEFINE_bool(forceBlend, false, "Force alpha blending?"); | 228 DEFINE_bool(forceBlend, false, "Force alpha blending?"); |
| 234 | 229 |
| 235 DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" " | |
| 236 "forces OpenGL API. Using \"gles\" forces OpenGL ES API. " | |
| 237 "Defaults to empty string, which selects the API native to the " | |
| 238 "system."); | |
| 239 DEFINE_int32(gpuCacheBytes, -1, "GPU cache size limit in bytes. 0 to disable ca
che."); | 230 DEFINE_int32(gpuCacheBytes, -1, "GPU cache size limit in bytes. 0 to disable ca
che."); |
| 240 DEFINE_int32(gpuCacheCount, -1, "GPU cache size limit in object count. 0 to dis
able cache."); | 231 DEFINE_int32(gpuCacheCount, -1, "GPU cache size limit in object count. 0 to dis
able cache."); |
| 241 | 232 |
| 242 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); | 233 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); |
| 243 DEFINE_string(match, "", "[~][^]substring[$] [...] of test name to run.\n" | 234 DEFINE_string(match, "", "[~][^]substring[$] [...] of test name to run.\n" |
| 244 "Multiple matches may be separated by spaces.\n" | 235 "Multiple matches may be separated by spaces.\n" |
| 245 "~ causes a matching test to always be skipped\n" | 236 "~ causes a matching test to always be skipped\n" |
| 246 "^ requires the start of the test to match\n" | 237 "^ requires the start of the test to match\n" |
| 247 "$ requires the end of the test to match\n" | 238 "$ requires the end of the test to match\n" |
| 248 "^ and $ requires an exact match\n" | 239 "^ and $ requires an exact match\n" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 for (int i = 0; i < configs.count(); ++i) { | 341 for (int i = 0; i < configs.count(); ++i) { |
| 351 const Config& config = gConfigs[configs[i]]; | 342 const Config& config = gConfigs[configs[i]]; |
| 352 if (Benchmark::kNonRendering_Backend == config.backend) { | 343 if (Benchmark::kNonRendering_Backend == config.backend) { |
| 353 configs.remove(i, 1); | 344 configs.remove(i, 1); |
| 354 --i; | 345 --i; |
| 355 } | 346 } |
| 356 } | 347 } |
| 357 } | 348 } |
| 358 | 349 |
| 359 #if SK_SUPPORT_GPU | 350 #if SK_SUPPORT_GPU |
| 360 GrGLStandard gpuAPI = kNone_GrGLStandard; | |
| 361 if (1 == FLAGS_gpuAPI.count()) { | |
| 362 if (FLAGS_gpuAPI.contains(kGpuAPINameGL)) { | |
| 363 gpuAPI = kGL_GrGLStandard; | |
| 364 } else if (FLAGS_gpuAPI.contains(kGpuAPINameGLES)) { | |
| 365 gpuAPI = kGLES_GrGLStandard; | |
| 366 } else { | |
| 367 SkDebugf("Selected gpu API could not be used. Using the default.\n")
; | |
| 368 } | |
| 369 } else if (FLAGS_gpuAPI.count() > 1) { | |
| 370 SkDebugf("Selected gpu API could not be used. Using the default.\n"); | |
| 371 } | |
| 372 | |
| 373 for (int i = 0; i < configs.count(); ++i) { | 351 for (int i = 0; i < configs.count(); ++i) { |
| 374 const Config& config = gConfigs[configs[i]]; | 352 const Config& config = gConfigs[configs[i]]; |
| 375 | 353 |
| 376 if (Benchmark::kGPU_Backend == config.backend) { | 354 if (Benchmark::kGPU_Backend == config.backend) { |
| 377 GrContext* context = gContextFactory.get(config.contextType, gpuAPI)
; | 355 GrContext* context = gContextFactory.get(config.contextType); |
| 378 if (NULL == context) { | 356 if (NULL == context) { |
| 379 SkDebugf("GrContext could not be created for config %s. Config w
ill be skipped.\n", | 357 SkDebugf("GrContext could not be created for config %s. Config w
ill be skipped.\n", |
| 380 config.name); | 358 config.name); |
| 381 configs.remove(i); | 359 configs.remove(i); |
| 382 --i; | 360 --i; |
| 383 continue; | 361 continue; |
| 384 } | 362 } |
| 385 if (config.sampleCount > context->getMaxSampleCount()){ | 363 if (config.sampleCount > context->getMaxSampleCount()){ |
| 386 SkDebugf( | 364 SkDebugf( |
| 387 "Sample count (%d) for config %s is not supported. Config wi
ll be skipped.\n", | 365 "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... |
| 427 writer.option("build", "RELEASE"); | 405 writer.option("build", "RELEASE"); |
| 428 #endif | 406 #endif |
| 429 | 407 |
| 430 // Set texture cache limits if non-default. | 408 // Set texture cache limits if non-default. |
| 431 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) { | 409 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) { |
| 432 #if SK_SUPPORT_GPU | 410 #if SK_SUPPORT_GPU |
| 433 const Config& config = gConfigs[i]; | 411 const Config& config = gConfigs[i]; |
| 434 if (Benchmark::kGPU_Backend != config.backend) { | 412 if (Benchmark::kGPU_Backend != config.backend) { |
| 435 continue; | 413 continue; |
| 436 } | 414 } |
| 437 GrContext* context = gContextFactory.get(config.contextType, gpuAPI); | 415 GrContext* context = gContextFactory.get(config.contextType); |
| 438 if (NULL == context) { | 416 if (NULL == context) { |
| 439 continue; | 417 continue; |
| 440 } | 418 } |
| 441 | 419 |
| 442 size_t bytes; | 420 size_t bytes; |
| 443 int count; | 421 int count; |
| 444 context->getResourceCacheLimits(&count, &bytes); | 422 context->getResourceCacheLimits(&count, &bytes); |
| 445 if (-1 != FLAGS_gpuCacheBytes) { | 423 if (-1 != FLAGS_gpuCacheBytes) { |
| 446 bytes = static_cast<size_t>(FLAGS_gpuCacheBytes); | 424 bytes = static_cast<size_t>(FLAGS_gpuCacheBytes); |
| 447 } | 425 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 473 const Config& config = gConfigs[configIndex]; | 451 const Config& config = gConfigs[configIndex]; |
| 474 | 452 |
| 475 if (!bench->isSuitableFor(config.backend)) { | 453 if (!bench->isSuitableFor(config.backend)) { |
| 476 continue; | 454 continue; |
| 477 } | 455 } |
| 478 | 456 |
| 479 GrContext* context = NULL; | 457 GrContext* context = NULL; |
| 480 #if SK_SUPPORT_GPU | 458 #if SK_SUPPORT_GPU |
| 481 SkGLContextHelper* glContext = NULL; | 459 SkGLContextHelper* glContext = NULL; |
| 482 if (Benchmark::kGPU_Backend == config.backend) { | 460 if (Benchmark::kGPU_Backend == config.backend) { |
| 483 context = gContextFactory.get(config.contextType, gpuAPI); | 461 context = gContextFactory.get(config.contextType); |
| 484 if (NULL == context) { | 462 if (NULL == context) { |
| 485 continue; | 463 continue; |
| 486 } | 464 } |
| 487 glContext = gContextFactory.getGLContext(config.contextType); | 465 glContext = gContextFactory.getGLContext(config.contextType); |
| 488 } | 466 } |
| 489 #endif | 467 #endif |
| 490 | 468 |
| 491 SkAutoTUnref<SkCanvas> canvas; | 469 SkAutoTUnref<SkCanvas> canvas; |
| 492 SkAutoTUnref<SkPicture> recordFrom; | 470 SkAutoTUnref<SkPicture> recordFrom; |
| 493 SkPictureRecorder recorderTo; | 471 SkPictureRecorder recorderTo; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 gContextFactory.destroyContexts(); | 677 gContextFactory.destroyContexts(); |
| 700 #endif | 678 #endif |
| 701 return 0; | 679 return 0; |
| 702 } | 680 } |
| 703 | 681 |
| 704 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 682 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 705 int main(int argc, char * const argv[]) { | 683 int main(int argc, char * const argv[]) { |
| 706 return tool_main(argc, (char**) argv); | 684 return tool_main(argc, (char**) argv); |
| 707 } | 685 } |
| 708 #endif | 686 #endif |
| OLD | NEW |