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

Side by Side Diff: bench/nanobench.cpp

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

Powered by Google App Engine
This is Rietveld 408576698