| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/gpu/gpu_data_manager_impl_private.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl_private.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 *reason = "All GPU features are blacklisted."; | 366 *reason = "All GPU features are blacklisted."; |
| 367 } | 367 } |
| 368 return false; | 368 return false; |
| 369 #endif | 369 #endif |
| 370 } | 370 } |
| 371 | 371 |
| 372 return true; | 372 return true; |
| 373 } | 373 } |
| 374 | 374 |
| 375 void GpuDataManagerImplPrivate::RequestCompleteGpuInfoIfNeeded() { | 375 void GpuDataManagerImplPrivate::RequestCompleteGpuInfoIfNeeded() { |
| 376 if (complete_gpu_info_already_requested_ || IsCompleteGpuInfoAvailable()) | 376 if (complete_gpu_info_already_requested_ || IsCompleteGpuInfoAvailable() || |
| 377 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 378 switches::kGpuTestingNoCompleteInfoCollection)) { |
| 377 return; | 379 return; |
| 380 } |
| 381 |
| 378 complete_gpu_info_already_requested_ = true; | 382 complete_gpu_info_already_requested_ = true; |
| 379 | 383 |
| 380 GpuProcessHost::SendOnIO( | 384 GpuProcessHost::SendOnIO( |
| 381 #if defined(OS_WIN) | 385 #if defined(OS_WIN) |
| 382 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, | 386 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, |
| 383 #else | 387 #else |
| 384 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 388 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 385 #endif | 389 #endif |
| 386 CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDED, | 390 CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDED, |
| 387 new GpuMsg_CollectGraphicsInfo()); | 391 new GpuMsg_CollectGraphicsInfo()); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, | 460 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, |
| 457 new GpuMsg_DisableWatchdog); | 461 new GpuMsg_DisableWatchdog); |
| 458 } | 462 } |
| 459 | 463 |
| 460 void GpuDataManagerImplPrivate::SetGLStrings(const std::string& gl_vendor, | 464 void GpuDataManagerImplPrivate::SetGLStrings(const std::string& gl_vendor, |
| 461 const std::string& gl_renderer, | 465 const std::string& gl_renderer, |
| 462 const std::string& gl_version) { | 466 const std::string& gl_version) { |
| 463 if (gl_vendor.empty() && gl_renderer.empty() && gl_version.empty()) | 467 if (gl_vendor.empty() && gl_renderer.empty() && gl_version.empty()) |
| 464 return; | 468 return; |
| 465 | 469 |
| 470 if (!is_initialized) { |
| 471 post_init_tasks_.push_back( |
| 472 base::Bind(&GpuDataManagerImplPrivate::SetGLStrings, |
| 473 base::Unretained(this), gl_vendor, gl_renderer, gl_version)); |
| 474 return; |
| 475 } |
| 476 |
| 466 // If GPUInfo already got GL strings, do nothing. This is for the rare | 477 // If GPUInfo already got GL strings, do nothing. This is for the rare |
| 467 // situation where GPU process collected GL strings before this call. | 478 // situation where GPU process collected GL strings before this call. |
| 468 if (!gpu_info_.gl_vendor.empty() || | 479 if (!gpu_info_.gl_vendor.empty() || |
| 469 !gpu_info_.gl_renderer.empty() || | 480 !gpu_info_.gl_renderer.empty() || |
| 470 !gpu_info_.gl_version.empty()) | 481 !gpu_info_.gl_version.empty()) |
| 471 return; | 482 return; |
| 472 | 483 |
| 473 gpu::GPUInfo gpu_info = gpu_info_; | 484 gpu::GPUInfo gpu_info = gpu_info_; |
| 474 | 485 |
| 475 gpu_info.gl_vendor = gl_vendor; | 486 gpu_info.gl_vendor = gl_vendor; |
| 476 gpu_info.gl_renderer = gl_renderer; | 487 gpu_info.gl_renderer = gl_renderer; |
| 477 gpu_info.gl_version = gl_version; | 488 gpu_info.gl_version = gl_version; |
| 478 | 489 |
| 479 gpu::IdentifyActiveGPU(&gpu_info); | 490 gpu::IdentifyActiveGPU(&gpu_info); |
| 491 |
| 480 gpu::CollectDriverInfoGL(&gpu_info); | 492 gpu::CollectDriverInfoGL(&gpu_info); |
| 481 | 493 |
| 482 UpdateGpuInfo(gpu_info); | 494 UpdateGpuInfo(gpu_info); |
| 483 UpdateGpuSwitchingManager(gpu_info); | 495 UpdateGpuSwitchingManager(gpu_info); |
| 484 UpdatePreliminaryBlacklistedFeatures(); | 496 UpdatePreliminaryBlacklistedFeatures(); |
| 485 } | 497 } |
| 486 | 498 |
| 487 void GpuDataManagerImplPrivate::GetGLStrings(std::string* gl_vendor, | 499 void GpuDataManagerImplPrivate::GetGLStrings(std::string* gl_vendor, |
| 488 std::string* gl_renderer, | 500 std::string* gl_renderer, |
| 489 std::string* gl_version) { | 501 std::string* gl_version) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 516 gpu_info.gpu.vendor_id = 0xffff; | 528 gpu_info.gpu.vendor_id = 0xffff; |
| 517 gpu_info.gpu.device_id = 0xffff; | 529 gpu_info.gpu.device_id = 0xffff; |
| 518 | 530 |
| 519 // Also declare the driver_vendor to be osmesa to be able to specify | 531 // Also declare the driver_vendor to be osmesa to be able to specify |
| 520 // exceptions based on driver_vendor==osmesa for some blacklist rules. | 532 // exceptions based on driver_vendor==osmesa for some blacklist rules. |
| 521 gpu_info.driver_vendor = gfx::kGLImplementationOSMesaName; | 533 gpu_info.driver_vendor = gfx::kGLImplementationOSMesaName; |
| 522 } else { | 534 } else { |
| 523 TRACE_EVENT0("startup", | 535 TRACE_EVENT0("startup", |
| 524 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); | 536 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); |
| 525 gpu::CollectBasicGraphicsInfo(&gpu_info); | 537 gpu::CollectBasicGraphicsInfo(&gpu_info); |
| 538 |
| 539 if (command_line->HasSwitch(switches::kGpuTestingVendorId) && |
| 540 command_line->HasSwitch(switches::kGpuTestingDeviceId)) { |
| 541 base::HexStringToUInt( |
| 542 command_line->GetSwitchValueASCII(switches::kGpuTestingVendorId), |
| 543 &gpu_info.gpu.vendor_id); |
| 544 base::HexStringToUInt( |
| 545 command_line->GetSwitchValueASCII(switches::kGpuTestingDeviceId), |
| 546 &gpu_info.gpu.device_id); |
| 547 gpu_info.gpu.active = true; |
| 548 gpu_info.secondary_gpus.clear(); |
| 549 } |
| 526 } | 550 } |
| 527 #if defined(ARCH_CPU_X86_FAMILY) | 551 #if defined(ARCH_CPU_X86_FAMILY) |
| 528 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) { | 552 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) { |
| 529 gpu_info.context_info_state = gpu::kCollectInfoNonFatalFailure; | 553 gpu_info.context_info_state = gpu::kCollectInfoNonFatalFailure; |
| 530 #if defined(OS_WIN) | 554 #if defined(OS_WIN) |
| 531 gpu_info.dx_diagnostics_info_state = gpu::kCollectInfoNonFatalFailure; | 555 gpu_info.dx_diagnostics_info_state = gpu::kCollectInfoNonFatalFailure; |
| 532 #endif // OS_WIN | 556 #endif // OS_WIN |
| 533 } | 557 } |
| 534 #endif // ARCH_CPU_X86_FAMILY | 558 #endif // ARCH_CPU_X86_FAMILY |
| 535 | 559 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 549 if (command_line->HasSwitch(switches::kSingleProcess) || | 573 if (command_line->HasSwitch(switches::kSingleProcess) || |
| 550 command_line->HasSwitch(switches::kInProcessGPU)) { | 574 command_line->HasSwitch(switches::kInProcessGPU)) { |
| 551 command_line->AppendSwitch(switches::kDisableGpuWatchdog); | 575 command_line->AppendSwitch(switches::kDisableGpuWatchdog); |
| 552 AppendGpuCommandLine(command_line); | 576 AppendGpuCommandLine(command_line); |
| 553 } | 577 } |
| 554 } | 578 } |
| 555 | 579 |
| 556 void GpuDataManagerImplPrivate::UpdateGpuInfoHelper() { | 580 void GpuDataManagerImplPrivate::UpdateGpuInfoHelper() { |
| 557 GetContentClient()->SetGpuInfo(gpu_info_); | 581 GetContentClient()->SetGpuInfo(gpu_info_); |
| 558 | 582 |
| 583 const base::CommandLine* command_line = |
| 584 base::CommandLine::ForCurrentProcess(); |
| 585 |
| 586 std::string os_version; |
| 587 if (command_line->HasSwitch(switches::kGpuTestingOsVersion)) |
| 588 os_version = |
| 589 command_line->GetSwitchValueASCII(switches::kGpuTestingOsVersion); |
| 590 |
| 559 if (gpu_blacklist_) { | 591 if (gpu_blacklist_) { |
| 560 std::set<int> features = gpu_blacklist_->MakeDecision( | 592 std::set<int> features = gpu_blacklist_->MakeDecision( |
| 561 gpu::GpuControlList::kOsAny, std::string(), gpu_info_); | 593 gpu::GpuControlList::kOsAny, os_version, gpu_info_); |
| 562 if (update_histograms_) | 594 if (update_histograms_) |
| 563 UpdateStats(gpu_info_, gpu_blacklist_.get(), features); | 595 UpdateStats(gpu_info_, gpu_blacklist_.get(), features); |
| 564 | 596 |
| 565 UpdateBlacklistedFeatures(features); | 597 UpdateBlacklistedFeatures(features); |
| 566 } | 598 } |
| 567 if (gpu_driver_bug_list_) { | 599 if (gpu_driver_bug_list_) { |
| 568 gpu_driver_bugs_ = gpu_driver_bug_list_->MakeDecision( | 600 gpu_driver_bugs_ = gpu_driver_bug_list_->MakeDecision( |
| 569 gpu::GpuControlList::kOsAny, std::string(), gpu_info_); | 601 gpu::GpuControlList::kOsAny, os_version, gpu_info_); |
| 570 | 602 |
| 571 std::set<std::string> disabled_ext_set; | 603 std::set<std::string> disabled_ext_set; |
| 572 | 604 |
| 573 // Merge disabled extensions from the command line with gpu driver bug list. | 605 // Merge disabled extensions from the command line with gpu driver bug list. |
| 574 const base::CommandLine* command_line = | |
| 575 base::CommandLine::ForCurrentProcess(); | |
| 576 if (command_line) { | 606 if (command_line) { |
| 577 const std::vector<std::string>& disabled_command_line_exts = | 607 const std::vector<std::string>& disabled_command_line_exts = |
| 578 base::SplitString( | 608 base::SplitString( |
| 579 command_line->GetSwitchValueASCII(switches::kDisableGLExtensions), | 609 command_line->GetSwitchValueASCII(switches::kDisableGLExtensions), |
| 580 ", ;", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 610 ", ;", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 581 disabled_ext_set.insert(disabled_command_line_exts.begin(), | 611 disabled_ext_set.insert(disabled_command_line_exts.begin(), |
| 582 disabled_command_line_exts.end()); | 612 disabled_command_line_exts.end()); |
| 583 } | 613 } |
| 584 const std::vector<std::string>& disabled_driver_bug_exts = | 614 const std::vector<std::string>& disabled_driver_bug_exts = |
| 585 gpu_driver_bug_list_->GetDisabledExtensions(); | 615 gpu_driver_bug_list_->GetDisabledExtensions(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 | 793 |
| 764 const base::CommandLine* command_line = | 794 const base::CommandLine* command_line = |
| 765 base::CommandLine::ForCurrentProcess(); | 795 base::CommandLine::ForCurrentProcess(); |
| 766 if (!ShouldDisableAcceleratedVideoDecode(command_line) && | 796 if (!ShouldDisableAcceleratedVideoDecode(command_line) && |
| 767 !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { | 797 !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { |
| 768 prefs->pepper_accelerated_video_decode_enabled = true; | 798 prefs->pepper_accelerated_video_decode_enabled = true; |
| 769 } | 799 } |
| 770 } | 800 } |
| 771 | 801 |
| 772 void GpuDataManagerImplPrivate::DisableHardwareAcceleration() { | 802 void GpuDataManagerImplPrivate::DisableHardwareAcceleration() { |
| 803 if (!is_initialized) { |
| 804 post_init_tasks_.push_back( |
| 805 base::Bind(&GpuDataManagerImplPrivate::DisableHardwareAcceleration, |
| 806 base::Unretained(this))); |
| 807 return; |
| 808 } |
| 809 |
| 773 card_blacklisted_ = true; | 810 card_blacklisted_ = true; |
| 774 | 811 |
| 775 for (int i = 0; i < gpu::NUMBER_OF_GPU_FEATURE_TYPES; ++i) | 812 for (int i = 0; i < gpu::NUMBER_OF_GPU_FEATURE_TYPES; ++i) |
| 776 blacklisted_features_.insert(i); | 813 blacklisted_features_.insert(i); |
| 777 | 814 |
| 778 EnableSwiftShaderIfNecessary(); | 815 EnableSwiftShaderIfNecessary(); |
| 779 NotifyGpuInfoUpdate(); | 816 NotifyGpuInfoUpdate(); |
| 780 } | 817 } |
| 781 | 818 |
| 782 std::string GpuDataManagerImplPrivate::GetBlacklistVersion() const { | 819 std::string GpuDataManagerImplPrivate::GetBlacklistVersion() const { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 void GpuDataManagerImplPrivate::DisableDomainBlockingFor3DAPIsForTesting() { | 991 void GpuDataManagerImplPrivate::DisableDomainBlockingFor3DAPIsForTesting() { |
| 955 domain_blocking_enabled_ = false; | 992 domain_blocking_enabled_ = false; |
| 956 } | 993 } |
| 957 | 994 |
| 958 // static | 995 // static |
| 959 GpuDataManagerImplPrivate* GpuDataManagerImplPrivate::Create( | 996 GpuDataManagerImplPrivate* GpuDataManagerImplPrivate::Create( |
| 960 GpuDataManagerImpl* owner) { | 997 GpuDataManagerImpl* owner) { |
| 961 return new GpuDataManagerImplPrivate(owner); | 998 return new GpuDataManagerImplPrivate(owner); |
| 962 } | 999 } |
| 963 | 1000 |
| 964 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate( | 1001 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(GpuDataManagerImpl* owner) |
| 965 GpuDataManagerImpl* owner) | |
| 966 : complete_gpu_info_already_requested_(false), | 1002 : complete_gpu_info_already_requested_(false), |
| 967 observer_list_(new GpuDataManagerObserverList), | 1003 observer_list_(new GpuDataManagerObserverList), |
| 968 use_swiftshader_(false), | 1004 use_swiftshader_(false), |
| 969 card_blacklisted_(false), | 1005 card_blacklisted_(false), |
| 970 update_histograms_(true), | 1006 update_histograms_(true), |
| 971 window_count_(0), | 1007 window_count_(0), |
| 972 domain_blocking_enabled_(true), | 1008 domain_blocking_enabled_(true), |
| 973 owner_(owner), | 1009 owner_(owner), |
| 974 display_count_(0), | 1010 display_count_(0), |
| 975 gpu_process_accessible_(true), | 1011 gpu_process_accessible_(true), |
| 1012 is_initialized(false), |
| 976 finalized_(false) { | 1013 finalized_(false) { |
| 977 DCHECK(owner_); | 1014 DCHECK(owner_); |
| 978 const base::CommandLine* command_line = | 1015 const base::CommandLine* command_line = |
| 979 base::CommandLine::ForCurrentProcess(); | 1016 base::CommandLine::ForCurrentProcess(); |
| 980 swiftshader_path_ = | 1017 swiftshader_path_ = |
| 981 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 1018 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 982 switches::kSwiftShaderPath); | 1019 switches::kSwiftShaderPath); |
| 983 if (command_line->HasSwitch(switches::kDisableGpu)) | 1020 if (command_line->HasSwitch(switches::kDisableGpu)) |
| 984 DisableHardwareAcceleration(); | 1021 DisableHardwareAcceleration(); |
| 985 | 1022 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 gpu_driver_bug_list_->enable_control_list_logging("gpu_driver_bug_list"); | 1059 gpu_driver_bug_list_->enable_control_list_logging("gpu_driver_bug_list"); |
| 1023 bool success = gpu_driver_bug_list_->LoadList( | 1060 bool success = gpu_driver_bug_list_->LoadList( |
| 1024 gpu_driver_bug_list_json, gpu::GpuControlList::kCurrentOsOnly); | 1061 gpu_driver_bug_list_json, gpu::GpuControlList::kCurrentOsOnly); |
| 1025 DCHECK(success); | 1062 DCHECK(success); |
| 1026 } | 1063 } |
| 1027 | 1064 |
| 1028 gpu_info_ = gpu_info; | 1065 gpu_info_ = gpu_info; |
| 1029 UpdateGpuInfo(gpu_info); | 1066 UpdateGpuInfo(gpu_info); |
| 1030 UpdateGpuSwitchingManager(gpu_info); | 1067 UpdateGpuSwitchingManager(gpu_info); |
| 1031 UpdatePreliminaryBlacklistedFeatures(); | 1068 UpdatePreliminaryBlacklistedFeatures(); |
| 1069 |
| 1070 // Set initialized before running callbacks. |
| 1071 is_initialized = true; |
| 1072 |
| 1073 for (const auto& callback : post_init_tasks_) |
| 1074 callback.Run(); |
| 1075 post_init_tasks_.clear(); |
| 1032 } | 1076 } |
| 1033 | 1077 |
| 1034 void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures( | 1078 void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures( |
| 1035 const std::set<int>& features) { | 1079 const std::set<int>& features) { |
| 1036 blacklisted_features_ = features; | 1080 blacklisted_features_ = features; |
| 1037 | 1081 |
| 1038 // Force disable using the GPU for these features, even if they would | 1082 // Force disable using the GPU for these features, even if they would |
| 1039 // otherwise be allowed. | 1083 // otherwise be allowed. |
| 1040 if (card_blacklisted_) { | 1084 if (card_blacklisted_) { |
| 1041 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING); | 1085 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; | 1237 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
| 1194 #if defined(OS_WIN) | 1238 #if defined(OS_WIN) |
| 1195 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | 1239 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; |
| 1196 #endif | 1240 #endif |
| 1197 complete_gpu_info_already_requested_ = true; | 1241 complete_gpu_info_already_requested_ = true; |
| 1198 // Some observers might be waiting. | 1242 // Some observers might be waiting. |
| 1199 NotifyGpuInfoUpdate(); | 1243 NotifyGpuInfoUpdate(); |
| 1200 } | 1244 } |
| 1201 | 1245 |
| 1202 } // namespace content | 1246 } // namespace content |
| OLD | NEW |