Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: bench/nanobench.cpp

Issue 1511613004: Revert of Make NVPR a GL context option instead of a GL context (Closed) Base URL: https://skia.googlesource.com/skia.git@commandbuffer-as-api-02-other-tests-refactor
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « bench/nanobench.h ('k') | dm/DM.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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),
176 SkSurface::kNo_Budgeted , info, 174 SkSurface::kNo_Budgeted , info,
177 this->config.samples, & props)); 175 this->config.samples, & props));
178 this->gl = gGrFactory->getContextInfo(this->config.ctxType, kNone_GrGLSt andard, 176 this->gl = gGrFactory->getContextInfo(this->config.ctxType)->fGLContext;
179 this->config.ctxOptions)->fGLConte xt;
180 if (!this->surface.get()) { 177 if (!this->surface.get()) {
181 return false; 178 return false;
182 } 179 }
183 if (!this->gl->fenceSyncSupport()) { 180 if (!this->gl->fenceSyncSupport()) {
184 SkDebugf("WARNING: GL context for config \"%s\" does not support fen ce sync. " 181 SkDebugf("WARNING: GL context for config \"%s\" does not support fen ce sync. "
185 "Timings might not be accurate.\n", this->config.name); 182 "Timings might not be accurate.\n", this->config.name);
186 } 183 }
187 return true; 184 return true;
188 } 185 }
189 void fillOptions(ResultsWriter* log) override { 186 void fillOptions(ResultsWriter* log) override {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 for (int i = 0; i < FLAGS_config.count(); i++) { 378 for (int i = 0; i < FLAGS_config.count(); i++) {
382 if (to_lower(FLAGS_config[i]).equals(name)) { 379 if (to_lower(FLAGS_config[i]).equals(name)) {
383 return true; 380 return true;
384 } 381 }
385 } 382 }
386 return false; 383 return false;
387 } 384 }
388 385
389 #if SK_SUPPORT_GPU 386 #if SK_SUPPORT_GPU
390 static bool is_gpu_config_allowed(const char* name, GrContextFactory::GLContextT ype ctxType, 387 static bool is_gpu_config_allowed(const char* name, GrContextFactory::GLContextT ype ctxType,
391 GrContextFactory::GLContextOptions ctxOptions,
392 int sampleCnt) { 388 int sampleCnt) {
393 if (!is_cpu_config_allowed(name)) { 389 if (!is_cpu_config_allowed(name)) {
394 return false; 390 return false;
395 } 391 }
396 if (const GrContext* ctx = gGrFactory->get(ctxType, kNone_GrGLStandard, ctxO ptions)) { 392 if (const GrContext* ctx = gGrFactory->get(ctxType)) {
397 return sampleCnt <= ctx->caps()->maxSampleCount(); 393 return sampleCnt <= ctx->caps()->maxSampleCount();
398 } 394 }
399 return false; 395 return false;
400 } 396 }
401 #endif 397 #endif
402 398
403 #if SK_SUPPORT_GPU 399 #if SK_SUPPORT_GPU
404 #define kBogusGLContextType GrContextFactory::kNative_GLContextType 400 #define kBogusGLContextType GrContextFactory::kNative_GLContextType
405 #define kBogusGLContextOptions GrContextFactory::kNone_GLContextOptions
406 #else 401 #else
407 #define kBogusGLContextType 0 402 #define kBogusGLContextType 0
408 #define kBogusGLContextOptions 0
409 #endif 403 #endif
410 404
411 // Append all configs that are enabled and supported. 405 // Append all configs that are enabled and supported.
412 static void create_configs(SkTDArray<Config>* configs) { 406 static void create_configs(SkTDArray<Config>* configs) {
413 #define CPU_CONFIG(name, backend, color, alpha) \ 407 #define CPU_CONFIG(name, backend, color, alpha) \
414 if (is_cpu_config_allowed(#name)) { \ 408 if (is_cpu_config_allowed(#name)) { \
415 Config config = { #name, Benchmark::backend, color, alpha, 0, \ 409 Config config = { #name, Benchmark::backend, color, alpha, 0, \
416 kBogusGLContextType, kBogusGLContextOptions, \ 410 kBogusGLContextType, false }; \
417 false }; \ 411 configs->push(config); \
418 configs->push(config); \
419 } 412 }
420 413
421 if (FLAGS_cpu) { 414 if (FLAGS_cpu) {
422 CPU_CONFIG(nonrendering, kNonRendering_Backend, kUnknown_SkColorType, kU npremul_SkAlphaType) 415 CPU_CONFIG(nonrendering, kNonRendering_Backend, kUnknown_SkColorType, kU npremul_SkAlphaType)
423 CPU_CONFIG(8888, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType) 416 CPU_CONFIG(8888, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType)
424 CPU_CONFIG(565, kRaster_Backend, kRGB_565_SkColorType, kOpaque_SkAlphaTy pe) 417 CPU_CONFIG(565, kRaster_Backend, kRGB_565_SkColorType, kOpaque_SkAlphaTy pe)
425 } 418 }
426 419
427 #if SK_SUPPORT_GPU 420 #if SK_SUPPORT_GPU
428 #define GPU_CONFIG(name, ctxType, ctxOptions, samples, useDFText) \ 421 #define GPU_CONFIG(name, ctxType, samples, useDFText) \
429 if (is_gpu_config_allowed(#name, GrContextFactory::ctxType, \ 422 if (is_gpu_config_allowed(#name, GrContextFactory::ctxType, samples)) { \
430 GrContextFactory::ctxOptions, samples)) { \
431 Config config = { \ 423 Config config = { \
432 #name, \ 424 #name, \
433 Benchmark::kGPU_Backend, \ 425 Benchmark::kGPU_Backend, \
434 kN32_SkColorType, \ 426 kN32_SkColorType, \
435 kPremul_SkAlphaType, \ 427 kPremul_SkAlphaType, \
436 samples, \ 428 samples, \
437 GrContextFactory::ctxType, \ 429 GrContextFactory::ctxType, \
438 GrContextFactory::ctxOptions, \
439 useDFText }; \ 430 useDFText }; \
440 configs->push(config); \ 431 configs->push(config); \
441 } 432 }
442 433
443 if (FLAGS_gpu) { 434 if (FLAGS_gpu) {
444 GPU_CONFIG(gpu, kNative_GLContextType, kNone_GLContextOptions, 0, false) 435 GPU_CONFIG(gpu, kNative_GLContextType, 0, false)
445 GPU_CONFIG(msaa4, kNative_GLContextType, kNone_GLContextOptions, 4, fals e) 436 GPU_CONFIG(msaa4, kNative_GLContextType, 4, false)
446 GPU_CONFIG(msaa16, kNative_GLContextType, kNone_GLContextOptions, 16, fa lse) 437 GPU_CONFIG(msaa16, kNative_GLContextType, 16, false)
447 GPU_CONFIG(nvprmsaa4, kNative_GLContextType, kEnableNVPR_GLContextOption s, 4, false) 438 GPU_CONFIG(nvprmsaa4, kNVPR_GLContextType, 4, false)
448 GPU_CONFIG(nvprmsaa16, kNative_GLContextType, kEnableNVPR_GLContextOptio ns, 16, false) 439 GPU_CONFIG(nvprmsaa16, kNVPR_GLContextType, 16, false)
449 GPU_CONFIG(gpudft, kNative_GLContextType, kNone_GLContextOptions, 0, tru e) 440 GPU_CONFIG(gpudft, kNative_GLContextType, 0, true)
450 GPU_CONFIG(debug, kDebug_GLContextType, kNone_GLContextOptions, 0, false ) 441 GPU_CONFIG(debug, kDebug_GLContextType, 0, false)
451 GPU_CONFIG(nullgpu, kNull_GLContextType, kNone_GLContextOptions, 0, fals e) 442 GPU_CONFIG(nullgpu, kNull_GLContextType, 0, false)
452 #ifdef SK_ANGLE 443 #ifdef SK_ANGLE
453 GPU_CONFIG(angle, kANGLE_GLContextType, kNone_GLContextOptions, 0, false ) 444 GPU_CONFIG(angle, kANGLE_GLContextType, 0, false)
454 GPU_CONFIG(angle-gl, kANGLE_GL_GLContextType, kNone_GLContextOptions, 0, false) 445 GPU_CONFIG(angle-gl, kANGLE_GL_GLContextType, 0, false)
455 #endif 446 #endif
456 #ifdef SK_COMMAND_BUFFER 447 #ifdef SK_COMMAND_BUFFER
457 GPU_CONFIG(commandbuffer, kCommandBuffer_GLContextType, kNone_GLContextO ptions, 0, false) 448 GPU_CONFIG(commandbuffer, kCommandBuffer_GLContextType, 0, false)
458 #endif 449 #endif
459 #if SK_MESA 450 #if SK_MESA
460 GPU_CONFIG(mesa, kMESA_GLContextType, kNone_GLContextOptions, 0, false) 451 GPU_CONFIG(mesa, kMESA_GLContextType, 0, false)
461 #endif 452 #endif
462 } 453 }
463 #endif 454 #endif
464 455
465 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 456 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
466 if (is_cpu_config_allowed("hwui")) { 457 if (is_cpu_config_allowed("hwui")) {
467 Config config = { "hwui", Benchmark::kHWUI_Backend, kRGBA_8888_SkColorTy pe, 458 Config config = { "hwui", Benchmark::kHWUI_Backend, kRGBA_8888_SkColorTy pe,
468 kPremul_SkAlphaType, 0, kBogusGLContextType, kBogusGLC ontextOptions, 459 kPremul_SkAlphaType, 0, kBogusGLContextType, false };
469 false };
470 configs->push(config); 460 configs->push(config);
471 } 461 }
472 #endif 462 #endif
473 } 463 }
474 464
475 // If bench is enabled for config, returns a Target* for it, otherwise nullptr. 465 // If bench is enabled for config, returns a Target* for it, otherwise nullptr.
476 static Target* is_enabled(Benchmark* bench, const Config& config) { 466 static Target* is_enabled(Benchmark* bench, const Config& config) {
477 if (!bench->isSuitableFor(config.backend)) { 467 if (!bench->isSuitableFor(config.backend)) {
478 return nullptr; 468 return nullptr;
479 } 469 }
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 , HUMANIZE(stats.max) 1261 , HUMANIZE(stats.max)
1272 , stddev_percent 1262 , stddev_percent
1273 , FLAGS_ms ? to_string(samples.count()).c_str() : stats. plot.c_str() 1263 , FLAGS_ms ? to_string(samples.count()).c_str() : stats. plot.c_str()
1274 , config 1264 , config
1275 , bench->getUniqueName() 1265 , bench->getUniqueName()
1276 ); 1266 );
1277 } 1267 }
1278 1268
1279 #if SK_SUPPORT_GPU 1269 #if SK_SUPPORT_GPU
1280 if (FLAGS_gpuStats && Benchmark::kGPU_Backend == configs[i].backend) { 1270 if (FLAGS_gpuStats && Benchmark::kGPU_Backend == configs[i].backend) {
1281 GrContext* context = gGrFactory->get(configs[i].ctxType, 1271 gGrFactory->get(configs[i].ctxType)->printCacheStats();
1282 kNone_GrGLStandard, configs [i].ctxOptions); 1272 gGrFactory->get(configs[i].ctxType)->printGpuStats();
1283 context->printCacheStats();
1284 context->printGpuStats();
1285 } 1273 }
1286 #endif 1274 #endif
1287 1275
1288 if (FLAGS_verbose) { 1276 if (FLAGS_verbose) {
1289 SkDebugf("Samples: "); 1277 SkDebugf("Samples: ");
1290 for (int i = 0; i < samples.count(); i++) { 1278 for (int i = 0; i < samples.count(); i++) {
1291 SkDebugf("%s ", HUMANIZE(samples[i])); 1279 SkDebugf("%s ", HUMANIZE(samples[i]));
1292 } 1280 }
1293 SkDebugf("%s\n", bench->getUniqueName()); 1281 SkDebugf("%s\n", bench->getUniqueName());
1294 } 1282 }
(...skipping 13 matching lines...) Expand all
1308 1296
1309 return 0; 1297 return 0;
1310 } 1298 }
1311 1299
1312 #if !defined SK_BUILD_FOR_IOS 1300 #if !defined SK_BUILD_FOR_IOS
1313 int main(int argc, char** argv) { 1301 int main(int argc, char** argv) {
1314 SkCommandLineFlags::Parse(argc, argv); 1302 SkCommandLineFlags::Parse(argc, argv);
1315 return nanobench_main(); 1303 return nanobench_main();
1316 } 1304 }
1317 #endif 1305 #endif
OLDNEW
« no previous file with comments | « bench/nanobench.h ('k') | dm/DM.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698