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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 if (!this->gl->getMaxGpuFrameLag(maxFrameLag)) { | 163 if (!this->gl->getMaxGpuFrameLag(maxFrameLag)) { |
164 // Frame lag is unknown. | 164 // Frame lag is unknown. |
165 *maxFrameLag = FLAGS_gpuFrameLag; | 165 *maxFrameLag = FLAGS_gpuFrameLag; |
166 } | 166 } |
167 return true; | 167 return true; |
168 } | 168 } |
169 bool init(SkImageInfo info, Benchmark* bench) override { | 169 bool init(SkImageInfo info, Benchmark* bench) override { |
170 uint32_t flags = this->config.useDFText ? SkSurfaceProps::kUseDeviceInde
pendentFonts_Flag : | 170 uint32_t flags = this->config.useDFText ? SkSurfaceProps::kUseDeviceInde
pendentFonts_Flag : |
171 0; | 171 0; |
172 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); | 172 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); |
173 this->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(this->con
fig.ctxType), | 173 this->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(this->con
fig.ctxType, |
| 174 kNone_GrG
LStandard, |
| 175 this->con
fig.ctxOptions), |
174 SkSurface::kNo_Budgeted
, info, | 176 SkSurface::kNo_Budgeted
, info, |
175 this->config.samples, &
props)); | 177 this->config.samples, &
props)); |
176 this->gl = gGrFactory->getContextInfo(this->config.ctxType)->fGLContext; | 178 this->gl = gGrFactory->getContextInfo(this->config.ctxType, kNone_GrGLSt
andard, |
| 179 this->config.ctxOptions)->fGLConte
xt; |
177 if (!this->surface.get()) { | 180 if (!this->surface.get()) { |
178 return false; | 181 return false; |
179 } | 182 } |
180 if (!this->gl->fenceSyncSupport()) { | 183 if (!this->gl->fenceSyncSupport()) { |
181 SkDebugf("WARNING: GL context for config \"%s\" does not support fen
ce sync. " | 184 SkDebugf("WARNING: GL context for config \"%s\" does not support fen
ce sync. " |
182 "Timings might not be accurate.\n", this->config.name); | 185 "Timings might not be accurate.\n", this->config.name); |
183 } | 186 } |
184 return true; | 187 return true; |
185 } | 188 } |
186 void fillOptions(ResultsWriter* log) override { | 189 void fillOptions(ResultsWriter* log) override { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 for (int i = 0; i < FLAGS_config.count(); i++) { | 381 for (int i = 0; i < FLAGS_config.count(); i++) { |
379 if (to_lower(FLAGS_config[i]).equals(name)) { | 382 if (to_lower(FLAGS_config[i]).equals(name)) { |
380 return true; | 383 return true; |
381 } | 384 } |
382 } | 385 } |
383 return false; | 386 return false; |
384 } | 387 } |
385 | 388 |
386 #if SK_SUPPORT_GPU | 389 #if SK_SUPPORT_GPU |
387 static bool is_gpu_config_allowed(const char* name, GrContextFactory::GLContextT
ype ctxType, | 390 static bool is_gpu_config_allowed(const char* name, GrContextFactory::GLContextT
ype ctxType, |
| 391 GrContextFactory::GLContextOptions ctxOptions, |
388 int sampleCnt) { | 392 int sampleCnt) { |
389 if (!is_cpu_config_allowed(name)) { | 393 if (!is_cpu_config_allowed(name)) { |
390 return false; | 394 return false; |
391 } | 395 } |
392 if (const GrContext* ctx = gGrFactory->get(ctxType)) { | 396 if (const GrContext* ctx = gGrFactory->get(ctxType, kNone_GrGLStandard, ctxO
ptions)) { |
393 return sampleCnt <= ctx->caps()->maxSampleCount(); | 397 return sampleCnt <= ctx->caps()->maxSampleCount(); |
394 } | 398 } |
395 return false; | 399 return false; |
396 } | 400 } |
397 #endif | 401 #endif |
398 | 402 |
399 #if SK_SUPPORT_GPU | 403 #if SK_SUPPORT_GPU |
400 #define kBogusGLContextType GrContextFactory::kNative_GLContextType | 404 #define kBogusGLContextType GrContextFactory::kNative_GLContextType |
| 405 #define kBogusGLContextOptions GrContextFactory::kNone_GLContextOptions |
401 #else | 406 #else |
402 #define kBogusGLContextType 0 | 407 #define kBogusGLContextType 0 |
| 408 #define kBogusGLContextOptions 0 |
403 #endif | 409 #endif |
404 | 410 |
405 // Append all configs that are enabled and supported. | 411 // Append all configs that are enabled and supported. |
406 static void create_configs(SkTDArray<Config>* configs) { | 412 static void create_configs(SkTDArray<Config>* configs) { |
407 #define CPU_CONFIG(name, backend, color, alpha) \ | 413 #define CPU_CONFIG(name, backend, color, alpha) \ |
408 if (is_cpu_config_allowed(#name)) { \ | 414 if (is_cpu_config_allowed(#name)) { \ |
409 Config config = { #name, Benchmark::backend, color, alpha, 0, \ | 415 Config config = { #name, Benchmark::backend, color, alpha, 0, \ |
410 kBogusGLContextType, false }; \ | 416 kBogusGLContextType, kBogusGLContextOptions, \ |
411 configs->push(config); \ | 417 false }; \ |
| 418 configs->push(config); \ |
412 } | 419 } |
413 | 420 |
414 if (FLAGS_cpu) { | 421 if (FLAGS_cpu) { |
415 CPU_CONFIG(nonrendering, kNonRendering_Backend, kUnknown_SkColorType, kU
npremul_SkAlphaType) | 422 CPU_CONFIG(nonrendering, kNonRendering_Backend, kUnknown_SkColorType, kU
npremul_SkAlphaType) |
416 CPU_CONFIG(8888, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType) | 423 CPU_CONFIG(8888, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType) |
417 CPU_CONFIG(565, kRaster_Backend, kRGB_565_SkColorType, kOpaque_SkAlphaTy
pe) | 424 CPU_CONFIG(565, kRaster_Backend, kRGB_565_SkColorType, kOpaque_SkAlphaTy
pe) |
418 } | 425 } |
419 | 426 |
420 #if SK_SUPPORT_GPU | 427 #if SK_SUPPORT_GPU |
421 #define GPU_CONFIG(name, ctxType, samples, useDFText)
\ | 428 #define GPU_CONFIG(name, ctxType, ctxOptions, samples, useDFText)
\ |
422 if (is_gpu_config_allowed(#name, GrContextFactory::ctxType, samples)) {
\ | 429 if (is_gpu_config_allowed(#name, GrContextFactory::ctxType,
\ |
| 430 GrContextFactory::ctxOptions, samples)) {
\ |
423 Config config = {
\ | 431 Config config = {
\ |
424 #name,
\ | 432 #name,
\ |
425 Benchmark::kGPU_Backend,
\ | 433 Benchmark::kGPU_Backend,
\ |
426 kN32_SkColorType,
\ | 434 kN32_SkColorType,
\ |
427 kPremul_SkAlphaType,
\ | 435 kPremul_SkAlphaType,
\ |
428 samples,
\ | 436 samples,
\ |
429 GrContextFactory::ctxType,
\ | 437 GrContextFactory::ctxType,
\ |
| 438 GrContextFactory::ctxOptions,
\ |
430 useDFText };
\ | 439 useDFText };
\ |
431 configs->push(config);
\ | 440 configs->push(config);
\ |
432 } | 441 } |
433 | 442 |
434 if (FLAGS_gpu) { | 443 if (FLAGS_gpu) { |
435 GPU_CONFIG(gpu, kNative_GLContextType, 0, false) | 444 GPU_CONFIG(gpu, kNative_GLContextType, kNone_GLContextOptions, 0, false) |
436 GPU_CONFIG(msaa4, kNative_GLContextType, 4, false) | 445 GPU_CONFIG(msaa4, kNative_GLContextType, kNone_GLContextOptions, 4, fals
e) |
437 GPU_CONFIG(msaa16, kNative_GLContextType, 16, false) | 446 GPU_CONFIG(msaa16, kNative_GLContextType, kNone_GLContextOptions, 16, fa
lse) |
438 GPU_CONFIG(nvprmsaa4, kNVPR_GLContextType, 4, false) | 447 GPU_CONFIG(nvprmsaa4, kNative_GLContextType, kEnableNVPR_GLContextOption
s, 4, false) |
439 GPU_CONFIG(nvprmsaa16, kNVPR_GLContextType, 16, false) | 448 GPU_CONFIG(nvprmsaa16, kNative_GLContextType, kEnableNVPR_GLContextOptio
ns, 16, false) |
440 GPU_CONFIG(gpudft, kNative_GLContextType, 0, true) | 449 GPU_CONFIG(gpudft, kNative_GLContextType, kNone_GLContextOptions, 0, tru
e) |
441 GPU_CONFIG(debug, kDebug_GLContextType, 0, false) | 450 GPU_CONFIG(debug, kDebug_GLContextType, kNone_GLContextOptions, 0, false
) |
442 GPU_CONFIG(nullgpu, kNull_GLContextType, 0, false) | 451 GPU_CONFIG(nullgpu, kNull_GLContextType, kNone_GLContextOptions, 0, fals
e) |
443 #ifdef SK_ANGLE | 452 #ifdef SK_ANGLE |
444 GPU_CONFIG(angle, kANGLE_GLContextType, 0, false) | 453 GPU_CONFIG(angle, kANGLE_GLContextType, kNone_GLContextOptions, 0, false
) |
445 GPU_CONFIG(angle-gl, kANGLE_GL_GLContextType, 0, false) | 454 GPU_CONFIG(angle-gl, kANGLE_GL_GLContextType, kNone_GLContextOptions, 0,
false) |
446 #endif | 455 #endif |
447 #ifdef SK_COMMAND_BUFFER | 456 #ifdef SK_COMMAND_BUFFER |
448 GPU_CONFIG(commandbuffer, kCommandBuffer_GLContextType, 0, false) | 457 GPU_CONFIG(commandbuffer, kCommandBuffer_GLContextType, kNone_GLContextO
ptions, 0, false) |
449 #endif | 458 #endif |
450 #if SK_MESA | 459 #if SK_MESA |
451 GPU_CONFIG(mesa, kMESA_GLContextType, 0, false) | 460 GPU_CONFIG(mesa, kMESA_GLContextType, kNone_GLContextOptions, 0, false) |
452 #endif | 461 #endif |
453 } | 462 } |
454 #endif | 463 #endif |
455 | 464 |
456 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 465 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
457 if (is_cpu_config_allowed("hwui")) { | 466 if (is_cpu_config_allowed("hwui")) { |
458 Config config = { "hwui", Benchmark::kHWUI_Backend, kRGBA_8888_SkColorTy
pe, | 467 Config config = { "hwui", Benchmark::kHWUI_Backend, kRGBA_8888_SkColorTy
pe, |
459 kPremul_SkAlphaType, 0, kBogusGLContextType, false }; | 468 kPremul_SkAlphaType, 0, kBogusGLContextType, kBogusGLC
ontextOptions, |
| 469 false }; |
460 configs->push(config); | 470 configs->push(config); |
461 } | 471 } |
462 #endif | 472 #endif |
463 } | 473 } |
464 | 474 |
465 // If bench is enabled for config, returns a Target* for it, otherwise nullptr. | 475 // If bench is enabled for config, returns a Target* for it, otherwise nullptr. |
466 static Target* is_enabled(Benchmark* bench, const Config& config) { | 476 static Target* is_enabled(Benchmark* bench, const Config& config) { |
467 if (!bench->isSuitableFor(config.backend)) { | 477 if (!bench->isSuitableFor(config.backend)) { |
468 return nullptr; | 478 return nullptr; |
469 } | 479 } |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 , HUMANIZE(stats.max) | 1271 , HUMANIZE(stats.max) |
1262 , stddev_percent | 1272 , stddev_percent |
1263 , FLAGS_ms ? to_string(samples.count()).c_str() : stats.
plot.c_str() | 1273 , FLAGS_ms ? to_string(samples.count()).c_str() : stats.
plot.c_str() |
1264 , config | 1274 , config |
1265 , bench->getUniqueName() | 1275 , bench->getUniqueName() |
1266 ); | 1276 ); |
1267 } | 1277 } |
1268 | 1278 |
1269 #if SK_SUPPORT_GPU | 1279 #if SK_SUPPORT_GPU |
1270 if (FLAGS_gpuStats && Benchmark::kGPU_Backend == configs[i].backend)
{ | 1280 if (FLAGS_gpuStats && Benchmark::kGPU_Backend == configs[i].backend)
{ |
1271 gGrFactory->get(configs[i].ctxType)->printCacheStats(); | 1281 GrContext* context = gGrFactory->get(configs[i].ctxType, |
1272 gGrFactory->get(configs[i].ctxType)->printGpuStats(); | 1282 kNone_GrGLStandard, configs
[i].ctxOptions); |
| 1283 context->printCacheStats(); |
| 1284 context->printGpuStats(); |
1273 } | 1285 } |
1274 #endif | 1286 #endif |
1275 | 1287 |
1276 if (FLAGS_verbose) { | 1288 if (FLAGS_verbose) { |
1277 SkDebugf("Samples: "); | 1289 SkDebugf("Samples: "); |
1278 for (int i = 0; i < samples.count(); i++) { | 1290 for (int i = 0; i < samples.count(); i++) { |
1279 SkDebugf("%s ", HUMANIZE(samples[i])); | 1291 SkDebugf("%s ", HUMANIZE(samples[i])); |
1280 } | 1292 } |
1281 SkDebugf("%s\n", bench->getUniqueName()); | 1293 SkDebugf("%s\n", bench->getUniqueName()); |
1282 } | 1294 } |
(...skipping 13 matching lines...) Expand all Loading... |
1296 | 1308 |
1297 return 0; | 1309 return 0; |
1298 } | 1310 } |
1299 | 1311 |
1300 #if !defined SK_BUILD_FOR_IOS | 1312 #if !defined SK_BUILD_FOR_IOS |
1301 int main(int argc, char** argv) { | 1313 int main(int argc, char** argv) { |
1302 SkCommandLineFlags::Parse(argc, argv); | 1314 SkCommandLineFlags::Parse(argc, argv); |
1303 return nanobench_main(); | 1315 return nanobench_main(); |
1304 } | 1316 } |
1305 #endif | 1317 #endif |
OLD | NEW |