OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 <ctype.h> | 8 #include <ctype.h> |
9 | 9 |
10 #include "nanobench.h" | 10 #include "nanobench.h" |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 // Pretty much the same deal as the calibration: do some warmup to make | 378 // Pretty much the same deal as the calibration: do some warmup to make |
379 // sure we're timing steady-state pipelined frames. | 379 // sure we're timing steady-state pipelined frames. |
380 for (int i = 0; i < maxGpuFrameLag - 1; i++) { | 380 for (int i = 0; i < maxGpuFrameLag - 1; i++) { |
381 time(loops, bench, target); | 381 time(loops, bench, target); |
382 } | 382 } |
383 | 383 |
384 return loops; | 384 return loops; |
385 } | 385 } |
386 | 386 |
387 #if SK_SUPPORT_GPU | 387 #if SK_SUPPORT_GPU |
388 #define kBogusGLContextType GrContextFactory::kNative_GLContextType | 388 #define kBogusContextType GrContextFactory::kNativeGL_ContextType |
389 #define kBogusGLContextOptions GrContextFactory::kNone_GLContextOptions | 389 #define kBogusContextOptions GrContextFactory::kNone_ContextOptions |
390 #else | 390 #else |
391 #define kBogusGLContextType 0 | 391 #define kBogusContextType 0 |
392 #define kBogusGLContextOptions 0 | 392 #define kBogusContextOptions 0 |
393 #endif | 393 #endif |
394 | 394 |
395 static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
onfigs) { | 395 static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
onfigs) { |
396 | 396 |
397 #if SK_SUPPORT_GPU | 397 #if SK_SUPPORT_GPU |
398 if (const auto* gpuConfig = config->asConfigGpu()) { | 398 if (const auto* gpuConfig = config->asConfigGpu()) { |
399 if (!FLAGS_gpu) | 399 if (!FLAGS_gpu) |
400 return; | 400 return; |
401 | 401 |
402 const auto ctxOptions = gpuConfig->getUseNVPR() ? GrContextFactory::kEna
bleNVPR_GLContextOptions | 402 const auto ctxOptions = gpuConfig->getUseNVPR() ? GrContextFactory::kEna
bleNVPR_ContextOptions |
403 : GrContextFactory::kNon
e_GLContextOptions; | 403 : GrContextFactory::kNon
e_ContextOptions; |
404 const auto ctxType = gpuConfig->getContextType(); | 404 const auto ctxType = gpuConfig->getContextType(); |
405 const auto sampleCount = gpuConfig->getSamples(); | 405 const auto sampleCount = gpuConfig->getSamples(); |
406 | 406 |
407 if (const GrContext* ctx = gGrFactory->get(ctxType, ctxOptions)) { | 407 if (const GrContext* ctx = gGrFactory->get(ctxType, ctxOptions)) { |
408 const auto maxSampleCount = ctx->caps()->maxSampleCount(); | 408 const auto maxSampleCount = ctx->caps()->maxSampleCount(); |
409 if (sampleCount > ctx->caps()->maxSampleCount()) { | 409 if (sampleCount > ctx->caps()->maxSampleCount()) { |
410 SkDebugf("Configuration sample count %d exceeds maximum %d.\n", | 410 SkDebugf("Configuration sample count %d exceeds maximum %d.\n", |
411 sampleCount, maxSampleCount); | 411 sampleCount, maxSampleCount); |
412 return; | 412 return; |
413 } | 413 } |
(...skipping 16 matching lines...) Expand all Loading... |
430 | 430 |
431 configs->push_back(target); | 431 configs->push_back(target); |
432 return; | 432 return; |
433 } | 433 } |
434 #endif | 434 #endif |
435 | 435 |
436 #define CPU_CONFIG(name, backend, color, alpha, profile) \ | 436 #define CPU_CONFIG(name, backend, color, alpha, profile) \ |
437 if (config->getTag().equals(#name)) { \ | 437 if (config->getTag().equals(#name)) { \ |
438 Config config = { \ | 438 Config config = { \ |
439 SkString(#name), Benchmark::backend, color, alpha, profile, \ | 439 SkString(#name), Benchmark::backend, color, alpha, profile, \ |
440 0, kBogusGLContextType, kBogusGLContextOptions, false \ | 440 0, kBogusContextType, kBogusContextOptions, false \ |
441 }; \ | 441 }; \ |
442 configs->push_back(config); \ | 442 configs->push_back(config); \ |
443 return; \ | 443 return; \ |
444 } | 444 } |
445 | 445 |
446 if (FLAGS_cpu) { | 446 if (FLAGS_cpu) { |
447 CPU_CONFIG(nonrendering, kNonRendering_Backend, | 447 CPU_CONFIG(nonrendering, kNonRendering_Backend, |
448 kUnknown_SkColorType, kUnpremul_SkAlphaType, kLinear_SkColorP
rofileType); | 448 kUnknown_SkColorType, kUnpremul_SkAlphaType, kLinear_SkColorP
rofileType); |
449 | 449 |
450 CPU_CONFIG(8888, kRaster_Backend, | 450 CPU_CONFIG(8888, kRaster_Backend, |
451 kN32_SkColorType, kPremul_SkAlphaType, kLinear_SkColorProfile
Type) | 451 kN32_SkColorType, kPremul_SkAlphaType, kLinear_SkColorProfile
Type) |
452 CPU_CONFIG(565, kRaster_Backend, | 452 CPU_CONFIG(565, kRaster_Backend, |
453 kRGB_565_SkColorType, kOpaque_SkAlphaType, kLinear_SkColorPro
fileType) | 453 kRGB_565_SkColorType, kOpaque_SkAlphaType, kLinear_SkColorPro
fileType) |
454 CPU_CONFIG(srgb, kRaster_Backend, | 454 CPU_CONFIG(srgb, kRaster_Backend, |
455 kN32_SkColorType, kPremul_SkAlphaType, kSRGB_SkColorProfileT
ype) | 455 kN32_SkColorType, kPremul_SkAlphaType, kSRGB_SkColorProfileT
ype) |
456 CPU_CONFIG(f16, kRaster_Backend, | 456 CPU_CONFIG(f16, kRaster_Backend, |
457 kRGBA_F16_SkColorType, kPremul_SkAlphaType, kLinear_SkColorPr
ofileType) | 457 kRGBA_F16_SkColorType, kPremul_SkAlphaType, kLinear_SkColorPr
ofileType) |
458 } | 458 } |
459 | 459 |
460 #undef CPU_CONFIG | 460 #undef CPU_CONFIG |
461 | 461 |
462 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 462 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
463 if (config->getTag().equals("hwui")) { | 463 if (config->getTag().equals("hwui")) { |
464 Config config = { SkString("hwui"), Benchmark::kHWUI_Backend, | 464 Config config = { SkString("hwui"), Benchmark::kHWUI_Backend, |
465 kRGBA_8888_SkColorType, kPremul_SkAlphaType, kLinear_S
kColorProfileType, | 465 kRGBA_8888_SkColorType, kPremul_SkAlphaType, kLinear_S
kColorProfileType, |
466 0, kBogusGLContextType, kBogusGLContextOptions, false
}; | 466 0, kBogusContextType, kBogusContextOptions, false }; |
467 configs->push_back(config); | 467 configs->push_back(config); |
468 } | 468 } |
469 #endif | 469 #endif |
470 } | 470 } |
471 | 471 |
472 // Append all configs that are enabled and supported. | 472 // Append all configs that are enabled and supported. |
473 void create_configs(SkTArray<Config>* configs) { | 473 void create_configs(SkTArray<Config>* configs) { |
474 SkCommandLineConfigArray array; | 474 SkCommandLineConfigArray array; |
475 ParseConfigs(FLAGS_config, &array); | 475 ParseConfigs(FLAGS_config, &array); |
476 for (int i = 0; i < array.count(); ++i) { | 476 for (int i = 0; i < array.count(); ++i) { |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 | 1283 |
1284 return 0; | 1284 return 0; |
1285 } | 1285 } |
1286 | 1286 |
1287 #if !defined SK_BUILD_FOR_IOS | 1287 #if !defined SK_BUILD_FOR_IOS |
1288 int main(int argc, char** argv) { | 1288 int main(int argc, char** argv) { |
1289 SkCommandLineFlags::Parse(argc, argv); | 1289 SkCommandLineFlags::Parse(argc, argv); |
1290 return nanobench_main(); | 1290 return nanobench_main(); |
1291 } | 1291 } |
1292 #endif | 1292 #endif |
OLD | NEW |