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