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

Side by Side Diff: bench/benchmain.cpp

Issue 319043005: Support using OpenGL ES context on desktop (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add docs Created 6 years, 5 months 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 | « no previous file | dm/DM.cpp » ('j') | src/gpu/gl/android/SkNativeGLContext_android.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 kDeferredSilent_BenchMode, 41 kDeferredSilent_BenchMode,
42 kRecord_BenchMode, 42 kRecord_BenchMode,
43 kPictureRecord_BenchMode 43 kPictureRecord_BenchMode
44 }; 44 };
45 const char* BenchMode_Name[] = { 45 const char* BenchMode_Name[] = {
46 "normal", "deferred", "deferredSilent", "record", "picturerecord" 46 "normal", "deferred", "deferredSilent", "record", "picturerecord"
47 }; 47 };
48 48
49 static const char kDefaultsConfigStr[] = "defaults"; 49 static const char kDefaultsConfigStr[] = "defaults";
50 50
51 #if SK_SUPPORT_GPU
52 static const char kGpuAPINameGL[] = "gl";
53 static const char kGpuAPINameGLES[] = "gles";
54 #endif
55
51 /////////////////////////////////////////////////////////////////////////////// 56 ///////////////////////////////////////////////////////////////////////////////
52 57
53 class Iter { 58 class Iter {
54 public: 59 public:
55 Iter() : fBenches(BenchRegistry::Head()), fGMs(skiagm::GMRegistry::Head()) { } 60 Iter() : fBenches(BenchRegistry::Head()), fGMs(skiagm::GMRegistry::Head()) { }
56 61
57 Benchmark* next() { 62 Benchmark* next() {
58 if (fBenches) { 63 if (fBenches) {
59 BenchRegistry::Factory f = fBenches->factory(); 64 BenchRegistry::Factory f = fBenches->factory();
60 fBenches = fBenches->next(); 65 fBenches = fBenches->next();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 223
219 DEFINE_bool(rotate, false, "Rotate canvas before bench run?"); 224 DEFINE_bool(rotate, false, "Rotate canvas before bench run?");
220 DEFINE_bool(scale, false, "Scale canvas before bench run?"); 225 DEFINE_bool(scale, false, "Scale canvas before bench run?");
221 DEFINE_bool(clip, false, "Clip canvas before bench run?"); 226 DEFINE_bool(clip, false, "Clip canvas before bench run?");
222 227
223 DEFINE_bool(forceAA, true, "Force anti-aliasing?"); 228 DEFINE_bool(forceAA, true, "Force anti-aliasing?");
224 DEFINE_bool(forceFilter, false, "Force bitmap filtering?"); 229 DEFINE_bool(forceFilter, false, "Force bitmap filtering?");
225 DEFINE_string(forceDither, "default", "Force dithering: true, false, or default? "); 230 DEFINE_string(forceDither, "default", "Force dithering: true, false, or default? ");
226 DEFINE_bool(forceBlend, false, "Force alpha blending?"); 231 DEFINE_bool(forceBlend, false, "Force alpha blending?");
227 232
233 DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" "
234 "forces OpenGL API. Using \"gles\" forces OpenGL ES API. "
235 "Defaults to empty string, which selects the API native to the "
236 "system.");
228 DEFINE_int32(gpuCacheBytes, -1, "GPU cache size limit in bytes. 0 to disable ca che."); 237 DEFINE_int32(gpuCacheBytes, -1, "GPU cache size limit in bytes. 0 to disable ca che.");
229 DEFINE_int32(gpuCacheCount, -1, "GPU cache size limit in object count. 0 to dis able cache."); 238 DEFINE_int32(gpuCacheCount, -1, "GPU cache size limit in object count. 0 to dis able cache.");
230 239
231 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); 240 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects.");
232 DEFINE_string(match, "", "[~][^]substring[$] [...] of test name to run.\n" 241 DEFINE_string(match, "", "[~][^]substring[$] [...] of test name to run.\n"
233 "Multiple matches may be separated by spaces.\n" 242 "Multiple matches may be separated by spaces.\n"
234 "~ causes a matching test to always be skipped\n" 243 "~ causes a matching test to always be skipped\n"
235 "^ requires the start of the test to match\n" 244 "^ requires the start of the test to match\n"
236 "$ requires the end of the test to match\n" 245 "$ requires the end of the test to match\n"
237 "^ and $ requires an exact match\n" 246 "^ and $ requires an exact match\n"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 for (int i = 0; i < configs.count(); ++i) { 348 for (int i = 0; i < configs.count(); ++i) {
340 const Config& config = gConfigs[configs[i]]; 349 const Config& config = gConfigs[configs[i]];
341 if (Benchmark::kNonRendering_Backend == config.backend) { 350 if (Benchmark::kNonRendering_Backend == config.backend) {
342 configs.remove(i, 1); 351 configs.remove(i, 1);
343 --i; 352 --i;
344 } 353 }
345 } 354 }
346 } 355 }
347 356
348 #if SK_SUPPORT_GPU 357 #if SK_SUPPORT_GPU
358 GrGLStandard gpuAPI = kNone_GrGLStandard;
359 if (1 == FLAGS_gpuAPI.count()) {
360 if (FLAGS_gpuAPI.contains(kGpuAPINameGL)) {
361 gpuAPI = kGL_GrGLStandard;
362 } else if (FLAGS_gpuAPI.contains(kGpuAPINameGLES)) {
363 gpuAPI = kGLES_GrGLStandard;
364 } else {
365 SkDebugf("Selected gpu API could not be used. Using the default.\n") ;
366 }
367 } else if (FLAGS_gpuAPI.count() > 1) {
368 SkDebugf("Selected gpu API could not be used. Using the default.\n");
369 }
370
349 for (int i = 0; i < configs.count(); ++i) { 371 for (int i = 0; i < configs.count(); ++i) {
350 const Config& config = gConfigs[configs[i]]; 372 const Config& config = gConfigs[configs[i]];
351 373
352 if (Benchmark::kGPU_Backend == config.backend) { 374 if (Benchmark::kGPU_Backend == config.backend) {
353 GrContext* context = gContextFactory.get(config.contextType); 375 GrContext* context = gContextFactory.get(config.contextType, gpuAPI) ;
354 if (NULL == context) { 376 if (NULL == context) {
355 SkDebugf("GrContext could not be created for config %s. Config w ill be skipped.\n", 377 SkDebugf("GrContext could not be created for config %s. Config w ill be skipped.\n",
356 config.name); 378 config.name);
357 configs.remove(i); 379 configs.remove(i);
358 --i; 380 --i;
359 continue; 381 continue;
360 } 382 }
361 if (config.sampleCount > context->getMaxSampleCount()){ 383 if (config.sampleCount > context->getMaxSampleCount()){
362 SkDebugf( 384 SkDebugf(
363 "Sample count (%d) for config %s is not supported. Config wi ll be skipped.\n", 385 "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
403 writer.option("build", "RELEASE"); 425 writer.option("build", "RELEASE");
404 #endif 426 #endif
405 427
406 // Set texture cache limits if non-default. 428 // Set texture cache limits if non-default.
407 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) { 429 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) {
408 #if SK_SUPPORT_GPU 430 #if SK_SUPPORT_GPU
409 const Config& config = gConfigs[i]; 431 const Config& config = gConfigs[i];
410 if (Benchmark::kGPU_Backend != config.backend) { 432 if (Benchmark::kGPU_Backend != config.backend) {
411 continue; 433 continue;
412 } 434 }
413 GrContext* context = gContextFactory.get(config.contextType); 435 GrContext* context = gContextFactory.get(config.contextType, gpuAPI);
414 if (NULL == context) { 436 if (NULL == context) {
415 continue; 437 continue;
416 } 438 }
417 439
418 size_t bytes; 440 size_t bytes;
419 int count; 441 int count;
420 context->getResourceCacheLimits(&count, &bytes); 442 context->getResourceCacheLimits(&count, &bytes);
421 if (-1 != FLAGS_gpuCacheBytes) { 443 if (-1 != FLAGS_gpuCacheBytes) {
422 bytes = static_cast<size_t>(FLAGS_gpuCacheBytes); 444 bytes = static_cast<size_t>(FLAGS_gpuCacheBytes);
423 } 445 }
(...skipping 25 matching lines...) Expand all
449 const Config& config = gConfigs[configIndex]; 471 const Config& config = gConfigs[configIndex];
450 472
451 if (!bench->isSuitableFor(config.backend)) { 473 if (!bench->isSuitableFor(config.backend)) {
452 continue; 474 continue;
453 } 475 }
454 476
455 GrContext* context = NULL; 477 GrContext* context = NULL;
456 #if SK_SUPPORT_GPU 478 #if SK_SUPPORT_GPU
457 SkGLContextHelper* glContext = NULL; 479 SkGLContextHelper* glContext = NULL;
458 if (Benchmark::kGPU_Backend == config.backend) { 480 if (Benchmark::kGPU_Backend == config.backend) {
459 context = gContextFactory.get(config.contextType); 481 context = gContextFactory.get(config.contextType, gpuAPI);
460 if (NULL == context) { 482 if (NULL == context) {
461 continue; 483 continue;
462 } 484 }
463 glContext = gContextFactory.getGLContext(config.contextType); 485 glContext = gContextFactory.getGLContext(config.contextType);
464 } 486 }
465 #endif 487 #endif
466 488
467 SkAutoTUnref<SkCanvas> canvas; 489 SkAutoTUnref<SkCanvas> canvas;
468 SkAutoTUnref<SkPicture> recordFrom; 490 SkAutoTUnref<SkPicture> recordFrom;
469 SkPictureRecorder recorderTo; 491 SkPictureRecorder recorderTo;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 gContextFactory.destroyContexts(); 697 gContextFactory.destroyContexts();
676 #endif 698 #endif
677 return 0; 699 return 0;
678 } 700 }
679 701
680 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 702 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
681 int main(int argc, char * const argv[]) { 703 int main(int argc, char * const argv[]) {
682 return tool_main(argc, (char**) argv); 704 return tool_main(argc, (char**) argv);
683 } 705 }
684 #endif 706 #endif
OLDNEW
« no previous file with comments | « no previous file | dm/DM.cpp » ('j') | src/gpu/gl/android/SkNativeGLContext_android.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698