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

Side by Side Diff: gpu/command_buffer/service/program_manager.cc

Issue 10836344: GPU program cache - switched to high res timings, and time report binary cache miss without the cac… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/program_manager.h" 5 #include "gpu/command_buffer/service/program_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
18 #include "base/time.h" 18 #include "base/time.h"
19 #include "gpu/command_buffer/common/gles2_cmd_format.h" 19 #include "gpu/command_buffer/common/gles2_cmd_format.h"
20 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 20 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
21 #include "gpu/command_buffer/service/feature_info.h" 21 #include "gpu/command_buffer/service/feature_info.h"
22 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 22 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
23 #include "gpu/command_buffer/service/gpu_switches.h" 23 #include "gpu/command_buffer/service/gpu_switches.h"
24 #include "gpu/command_buffer/service/program_cache.h" 24 #include "gpu/command_buffer/service/program_cache.h"
25 25
26 using base::TimeDelta; 26 using base::TimeDelta;
27 using base::TimeTicks;
27 28
28 namespace gpu { 29 namespace gpu {
29 namespace gles2 { 30 namespace gles2 {
30 31
31 namespace { 32 namespace {
32 33
33 int ShaderTypeToIndex(GLenum shader_type) { 34 int ShaderTypeToIndex(GLenum shader_type) {
34 switch (shader_type) { 35 switch (shader_type) {
35 case GL_VERTEX_SHADER: 36 case GL_VERTEX_SHADER:
36 return 0; 37 return 0;
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 it != bind_attrib_location_map_.end(); ++it) { 379 it != bind_attrib_location_map_.end(); ++it) {
379 const std::string* mapped_name = GetAttribMappedName(it->first); 380 const std::string* mapped_name = GetAttribMappedName(it->first);
380 if (mapped_name && *mapped_name != it->first) 381 if (mapped_name && *mapped_name != it->first)
381 glBindAttribLocation(service_id_, it->second, mapped_name->c_str()); 382 glBindAttribLocation(service_id_, it->second, mapped_name->c_str());
382 } 383 }
383 } 384 }
384 385
385 void ProgramManager::DoCompileShader(ShaderManager::ShaderInfo* info, 386 void ProgramManager::DoCompileShader(ShaderManager::ShaderInfo* info,
386 ShaderTranslator* translator, 387 ShaderTranslator* translator,
387 FeatureInfo* feature_info) { 388 FeatureInfo* feature_info) {
388 base::Time before = base::Time::Now(); 389 TimeTicks before = TimeTicks::HighResNow();
389 if (program_cache_ && 390 if (program_cache_ &&
390 program_cache_->GetShaderCompilationStatus(info->source() ? 391 program_cache_->GetShaderCompilationStatus(info->source() ?
391 *info->source() : "") == 392 *info->source() : "") ==
392 ProgramCache::COMPILATION_SUCCEEDED) { 393 ProgramCache::COMPILATION_SUCCEEDED) {
393 info->SetStatus(true, "", translator); 394 info->SetStatus(true, "", translator);
394 info->FlagSourceAsCompiled(false); 395 info->FlagSourceAsCompiled(false);
395 UMA_HISTOGRAM_CUSTOM_COUNTS("GPU.ProgramCache.CompilationCacheHitTime", 396 UMA_HISTOGRAM_CUSTOM_COUNTS(
396 (base::Time::Now() - before).InMicroseconds(), 397 "GPU.ProgramCache.CompilationCacheHitTime",
397 0, 398 (TimeTicks::HighResNow() - before).InMicroseconds(),
398 TimeDelta::FromSeconds(1).InMicroseconds(), 399 0,
399 50); 400 TimeDelta::FromSeconds(1).InMicroseconds(),
401 50);
400 return; 402 return;
401 } 403 }
402 ForceCompileShader(info->source(), info, translator, feature_info); 404 ForceCompileShader(info->source(), info, translator, feature_info);
403 UMA_HISTOGRAM_CUSTOM_COUNTS("GPU.ProgramCache.CompilationCacheMissTime", 405 UMA_HISTOGRAM_CUSTOM_COUNTS(
404 (base::Time::Now() - before).InMicroseconds(), 406 "GPU.ProgramCache.CompilationCacheMissTime",
405 0, 407 (TimeTicks::HighResNow() - before).InMicroseconds(),
406 TimeDelta::FromSeconds(1).InMicroseconds(), 408 0,
407 50); 409 TimeDelta::FromSeconds(1).InMicroseconds(),
410 50);
408 } 411 }
409 412
410 void ProgramManager::ForceCompileShader(const std::string* source, 413 void ProgramManager::ForceCompileShader(const std::string* source,
411 ShaderManager::ShaderInfo* info, 414 ShaderManager::ShaderInfo* info,
412 ShaderTranslator* translator, 415 ShaderTranslator* translator,
413 FeatureInfo* feature_info) { 416 FeatureInfo* feature_info) {
414 info->FlagSourceAsCompiled(true); 417 info->FlagSourceAsCompiled(true);
415 418
416 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to 419 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to
417 // glShaderSource and then glCompileShader. 420 // glShaderSource and then glCompileShader.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 if (!CanLink()) { 482 if (!CanLink()) {
480 set_log_info("missing shaders"); 483 set_log_info("missing shaders");
481 return false; 484 return false;
482 } 485 }
483 if (DetectAttribLocationBindingConflicts()) { 486 if (DetectAttribLocationBindingConflicts()) {
484 set_log_info("glBindAttribLocation() conflicts"); 487 set_log_info("glBindAttribLocation() conflicts");
485 return false; 488 return false;
486 } 489 }
487 ExecuteBindAttribLocationCalls(); 490 ExecuteBindAttribLocationCalls();
488 491
489 base::Time before_time = base::Time::Now(); 492 TimeTicks before_time = TimeTicks::HighResNow();
490 bool link = true; 493 bool link = true;
491 ProgramCache* cache = manager_->program_cache_; 494 ProgramCache* cache = manager_->program_cache_;
492 if (cache) { 495 if (cache) {
493 ProgramCache::LinkedProgramStatus status = cache->GetLinkedProgramStatus( 496 ProgramCache::LinkedProgramStatus status = cache->GetLinkedProgramStatus(
494 *attached_shaders_[0]->deferred_compilation_source(), 497 *attached_shaders_[0]->deferred_compilation_source(),
495 *attached_shaders_[1]->deferred_compilation_source(), 498 *attached_shaders_[1]->deferred_compilation_source(),
496 &bind_attrib_location_map_); 499 &bind_attrib_location_map_);
497 500
498 if (status == ProgramCache::LINK_SUCCEEDED) { 501 if (status == ProgramCache::LINK_SUCCEEDED) {
499 ProgramCache::ProgramLoadResult success = cache->LoadLinkedProgram( 502 ProgramCache::ProgramLoadResult success = cache->LoadLinkedProgram(
(...skipping 20 matching lines...) Expand all
520 attached_shaders_[i], 523 attached_shaders_[i],
521 translator, 524 translator,
522 feature_info); 525 feature_info);
523 CHECK(info->IsValid()); 526 CHECK(info->IsValid());
524 } 527 }
525 } 528 }
526 } 529 }
527 } 530 }
528 531
529 if (link) { 532 if (link) {
530 before_time = base::Time::Now(); 533 before_time = TimeTicks::HighResNow();
531 if (cache && gfx::g_GL_ARB_get_program_binary) { 534 if (cache && gfx::g_GL_ARB_get_program_binary) {
532 glProgramParameteri(service_id(), 535 glProgramParameteri(service_id(),
533 PROGRAM_BINARY_RETRIEVABLE_HINT, 536 PROGRAM_BINARY_RETRIEVABLE_HINT,
534 GL_TRUE); 537 GL_TRUE);
535 } 538 }
536 glLinkProgram(service_id()); 539 glLinkProgram(service_id());
537 } 540 }
538 541
539 GLint success = 0; 542 GLint success = 0;
540 glGetProgramiv(service_id(), GL_LINK_STATUS, &success); 543 glGetProgramiv(service_id(), GL_LINK_STATUS, &success);
541 if (success == GL_TRUE) { 544 if (success == GL_TRUE) {
542 Update(); 545 Update();
543 if (cache && link) { 546 if (cache && link) {
544 cache->SaveLinkedProgram(service_id(), 547 cache->SaveLinkedProgram(service_id(),
545 attached_shaders_[0], 548 attached_shaders_[0],
546 attached_shaders_[1], 549 attached_shaders_[1],
547 &bind_attrib_location_map_); 550 &bind_attrib_location_map_);
548 UMA_HISTOGRAM_CUSTOM_COUNTS( 551 UMA_HISTOGRAM_CUSTOM_COUNTS(
549 "GPU.ProgramCache.BinaryCacheMissTime", 552 "GPU.ProgramCache.BinaryCacheMissTime",
550 (base::Time::Now() - before_time).InMicroseconds(), 553 (TimeTicks::HighResNow() - before_time).InMicroseconds(),
551 0, 554 0,
552 TimeDelta::FromSeconds(10).InMicroseconds(), 555 TimeDelta::FromSeconds(10).InMicroseconds(),
553 50); 556 50);
554 } else if (cache) {
555 UMA_HISTOGRAM_CUSTOM_COUNTS(
556 "GPU.ProgramCache.BinaryCacheHitTime",
557 (base::Time::Now() - before_time).InMicroseconds(),
558 0,
559 TimeDelta::FromSeconds(1).InMicroseconds(),
560 50);
561 } 557 }
558 UMA_HISTOGRAM_CUSTOM_COUNTS(
559 "GPU.ProgramCache.BinaryCacheHitTime",
560 (TimeTicks::HighResNow() - before_time).InMicroseconds(),
561 0,
562 TimeDelta::FromSeconds(1).InMicroseconds(),
563 50);
562 } else { 564 } else {
563 UpdateLogInfo(); 565 UpdateLogInfo();
564 } 566 }
565 return success == GL_TRUE; 567 return success == GL_TRUE;
566 } 568 }
567 569
568 void ProgramManager::ProgramInfo::Validate() { 570 void ProgramManager::ProgramInfo::Validate() {
569 if (!IsValid()) { 571 if (!IsValid()) {
570 set_log_info("program not linked"); 572 set_log_info("program not linked");
571 return; 573 return;
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 info->ClearUniforms(&zero_); 1151 info->ClearUniforms(&zero_);
1150 } 1152 }
1151 } 1153 }
1152 1154
1153 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { 1155 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) {
1154 return index + element * 0x10000; 1156 return index + element * 0x10000;
1155 } 1157 }
1156 1158
1157 } // namespace gles2 1159 } // namespace gles2
1158 } // namespace gpu 1160 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698