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