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; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 gpu_info.gpu.vendor_id = 0xffff; | 527 gpu_info.gpu.vendor_id = 0xffff; |
517 gpu_info.gpu.device_id = 0xffff; | 528 gpu_info.gpu.device_id = 0xffff; |
518 | 529 |
519 // Also declare the driver_vendor to be osmesa to be able to specify | 530 // Also declare the driver_vendor to be osmesa to be able to specify |
520 // exceptions based on driver_vendor==osmesa for some blacklist rules. | 531 // exceptions based on driver_vendor==osmesa for some blacklist rules. |
521 gpu_info.driver_vendor = gfx::kGLImplementationOSMesaName; | 532 gpu_info.driver_vendor = gfx::kGLImplementationOSMesaName; |
522 } else { | 533 } else { |
523 TRACE_EVENT0("startup", | 534 TRACE_EVENT0("startup", |
524 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); | 535 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); |
525 gpu::CollectBasicGraphicsInfo(&gpu_info); | 536 gpu::CollectBasicGraphicsInfo(&gpu_info); |
| 537 |
| 538 if (command_line->HasSwitch(switches::kGpuTestingVendorId) && |
| 539 command_line->HasSwitch(switches::kGpuTestingDeviceId)) { |
| 540 base::HexStringToUInt( |
| 541 command_line->GetSwitchValueASCII(switches::kGpuTestingVendorId), |
| 542 &gpu_info.gpu.vendor_id); |
| 543 base::HexStringToUInt( |
| 544 command_line->GetSwitchValueASCII(switches::kGpuTestingDeviceId), |
| 545 &gpu_info.gpu.device_id); |
| 546 gpu_info.gpu.active = true; |
| 547 gpu_info.secondary_gpus.clear(); |
| 548 } |
526 } | 549 } |
527 #if defined(ARCH_CPU_X86_FAMILY) | 550 #if defined(ARCH_CPU_X86_FAMILY) |
528 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) { | 551 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) { |
529 gpu_info.context_info_state = gpu::kCollectInfoNonFatalFailure; | 552 gpu_info.context_info_state = gpu::kCollectInfoNonFatalFailure; |
530 #if defined(OS_WIN) | 553 #if defined(OS_WIN) |
531 gpu_info.dx_diagnostics_info_state = gpu::kCollectInfoNonFatalFailure; | 554 gpu_info.dx_diagnostics_info_state = gpu::kCollectInfoNonFatalFailure; |
532 #endif // OS_WIN | 555 #endif // OS_WIN |
533 } | 556 } |
534 #endif // ARCH_CPU_X86_FAMILY | 557 #endif // ARCH_CPU_X86_FAMILY |
535 | 558 |
(...skipping 13 matching lines...) Expand all Loading... |
549 if (command_line->HasSwitch(switches::kSingleProcess) || | 572 if (command_line->HasSwitch(switches::kSingleProcess) || |
550 command_line->HasSwitch(switches::kInProcessGPU)) { | 573 command_line->HasSwitch(switches::kInProcessGPU)) { |
551 command_line->AppendSwitch(switches::kDisableGpuWatchdog); | 574 command_line->AppendSwitch(switches::kDisableGpuWatchdog); |
552 AppendGpuCommandLine(command_line); | 575 AppendGpuCommandLine(command_line); |
553 } | 576 } |
554 } | 577 } |
555 | 578 |
556 void GpuDataManagerImplPrivate::UpdateGpuInfoHelper() { | 579 void GpuDataManagerImplPrivate::UpdateGpuInfoHelper() { |
557 GetContentClient()->SetGpuInfo(gpu_info_); | 580 GetContentClient()->SetGpuInfo(gpu_info_); |
558 | 581 |
| 582 const base::CommandLine* command_line = |
| 583 base::CommandLine::ForCurrentProcess(); |
| 584 |
| 585 std::string os_version; |
| 586 if (command_line->HasSwitch(switches::kGpuTestingOsVersion)) |
| 587 os_version = |
| 588 command_line->GetSwitchValueASCII(switches::kGpuTestingOsVersion); |
| 589 |
559 if (gpu_blacklist_) { | 590 if (gpu_blacklist_) { |
560 std::set<int> features = gpu_blacklist_->MakeDecision( | 591 std::set<int> features = gpu_blacklist_->MakeDecision( |
561 gpu::GpuControlList::kOsAny, std::string(), gpu_info_); | 592 gpu::GpuControlList::kOsAny, os_version, gpu_info_); |
562 if (update_histograms_) | 593 if (update_histograms_) |
563 UpdateStats(gpu_info_, gpu_blacklist_.get(), features); | 594 UpdateStats(gpu_info_, gpu_blacklist_.get(), features); |
564 | 595 |
565 UpdateBlacklistedFeatures(features); | 596 UpdateBlacklistedFeatures(features); |
566 } | 597 } |
567 if (gpu_driver_bug_list_) { | 598 if (gpu_driver_bug_list_) { |
568 gpu_driver_bugs_ = gpu_driver_bug_list_->MakeDecision( | 599 gpu_driver_bugs_ = gpu_driver_bug_list_->MakeDecision( |
569 gpu::GpuControlList::kOsAny, std::string(), gpu_info_); | 600 gpu::GpuControlList::kOsAny, os_version, gpu_info_); |
570 | 601 |
571 std::set<std::string> disabled_ext_set; | 602 std::set<std::string> disabled_ext_set; |
572 | 603 |
573 // Merge disabled extensions from the command line with gpu driver bug list. | 604 // 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) { | 605 if (command_line) { |
577 const std::vector<std::string>& disabled_command_line_exts = | 606 const std::vector<std::string>& disabled_command_line_exts = |
578 base::SplitString( | 607 base::SplitString( |
579 command_line->GetSwitchValueASCII(switches::kDisableGLExtensions), | 608 command_line->GetSwitchValueASCII(switches::kDisableGLExtensions), |
580 ", ;", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 609 ", ;", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
581 disabled_ext_set.insert(disabled_command_line_exts.begin(), | 610 disabled_ext_set.insert(disabled_command_line_exts.begin(), |
582 disabled_command_line_exts.end()); | 611 disabled_command_line_exts.end()); |
583 } | 612 } |
584 const std::vector<std::string>& disabled_driver_bug_exts = | 613 const std::vector<std::string>& disabled_driver_bug_exts = |
585 gpu_driver_bug_list_->GetDisabledExtensions(); | 614 gpu_driver_bug_list_->GetDisabledExtensions(); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 | 792 |
764 const base::CommandLine* command_line = | 793 const base::CommandLine* command_line = |
765 base::CommandLine::ForCurrentProcess(); | 794 base::CommandLine::ForCurrentProcess(); |
766 if (!ShouldDisableAcceleratedVideoDecode(command_line) && | 795 if (!ShouldDisableAcceleratedVideoDecode(command_line) && |
767 !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { | 796 !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { |
768 prefs->pepper_accelerated_video_decode_enabled = true; | 797 prefs->pepper_accelerated_video_decode_enabled = true; |
769 } | 798 } |
770 } | 799 } |
771 | 800 |
772 void GpuDataManagerImplPrivate::DisableHardwareAcceleration() { | 801 void GpuDataManagerImplPrivate::DisableHardwareAcceleration() { |
| 802 if (!is_initialized_) { |
| 803 post_init_tasks_.push_back( |
| 804 base::Bind(&GpuDataManagerImplPrivate::DisableHardwareAcceleration, |
| 805 base::Unretained(this))); |
| 806 return; |
| 807 } |
| 808 |
773 card_blacklisted_ = true; | 809 card_blacklisted_ = true; |
774 | 810 |
775 for (int i = 0; i < gpu::NUMBER_OF_GPU_FEATURE_TYPES; ++i) | 811 for (int i = 0; i < gpu::NUMBER_OF_GPU_FEATURE_TYPES; ++i) |
776 blacklisted_features_.insert(i); | 812 blacklisted_features_.insert(i); |
777 | 813 |
778 EnableSwiftShaderIfNecessary(); | 814 EnableSwiftShaderIfNecessary(); |
779 NotifyGpuInfoUpdate(); | 815 NotifyGpuInfoUpdate(); |
780 } | 816 } |
781 | 817 |
782 std::string GpuDataManagerImplPrivate::GetBlacklistVersion() const { | 818 std::string GpuDataManagerImplPrivate::GetBlacklistVersion() const { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 void GpuDataManagerImplPrivate::DisableDomainBlockingFor3DAPIsForTesting() { | 990 void GpuDataManagerImplPrivate::DisableDomainBlockingFor3DAPIsForTesting() { |
955 domain_blocking_enabled_ = false; | 991 domain_blocking_enabled_ = false; |
956 } | 992 } |
957 | 993 |
958 // static | 994 // static |
959 GpuDataManagerImplPrivate* GpuDataManagerImplPrivate::Create( | 995 GpuDataManagerImplPrivate* GpuDataManagerImplPrivate::Create( |
960 GpuDataManagerImpl* owner) { | 996 GpuDataManagerImpl* owner) { |
961 return new GpuDataManagerImplPrivate(owner); | 997 return new GpuDataManagerImplPrivate(owner); |
962 } | 998 } |
963 | 999 |
964 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate( | 1000 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(GpuDataManagerImpl* owner) |
965 GpuDataManagerImpl* owner) | |
966 : complete_gpu_info_already_requested_(false), | 1001 : complete_gpu_info_already_requested_(false), |
967 observer_list_(new GpuDataManagerObserverList), | 1002 observer_list_(new GpuDataManagerObserverList), |
968 use_swiftshader_(false), | 1003 use_swiftshader_(false), |
969 card_blacklisted_(false), | 1004 card_blacklisted_(false), |
970 update_histograms_(true), | 1005 update_histograms_(true), |
971 window_count_(0), | 1006 window_count_(0), |
972 domain_blocking_enabled_(true), | 1007 domain_blocking_enabled_(true), |
973 owner_(owner), | 1008 owner_(owner), |
974 display_count_(0), | 1009 display_count_(0), |
975 gpu_process_accessible_(true), | 1010 gpu_process_accessible_(true), |
| 1011 is_initialized_(false), |
976 finalized_(false) { | 1012 finalized_(false) { |
977 DCHECK(owner_); | 1013 DCHECK(owner_); |
978 const base::CommandLine* command_line = | 1014 const base::CommandLine* command_line = |
979 base::CommandLine::ForCurrentProcess(); | 1015 base::CommandLine::ForCurrentProcess(); |
980 swiftshader_path_ = | 1016 swiftshader_path_ = |
981 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 1017 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
982 switches::kSwiftShaderPath); | 1018 switches::kSwiftShaderPath); |
983 if (command_line->HasSwitch(switches::kDisableGpu)) | 1019 if (command_line->HasSwitch(switches::kDisableGpu)) |
984 DisableHardwareAcceleration(); | 1020 DisableHardwareAcceleration(); |
985 | 1021 |
(...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"); | 1058 gpu_driver_bug_list_->enable_control_list_logging("gpu_driver_bug_list"); |
1023 bool success = gpu_driver_bug_list_->LoadList( | 1059 bool success = gpu_driver_bug_list_->LoadList( |
1024 gpu_driver_bug_list_json, gpu::GpuControlList::kCurrentOsOnly); | 1060 gpu_driver_bug_list_json, gpu::GpuControlList::kCurrentOsOnly); |
1025 DCHECK(success); | 1061 DCHECK(success); |
1026 } | 1062 } |
1027 | 1063 |
1028 gpu_info_ = gpu_info; | 1064 gpu_info_ = gpu_info; |
1029 UpdateGpuInfo(gpu_info); | 1065 UpdateGpuInfo(gpu_info); |
1030 UpdateGpuSwitchingManager(gpu_info); | 1066 UpdateGpuSwitchingManager(gpu_info); |
1031 UpdatePreliminaryBlacklistedFeatures(); | 1067 UpdatePreliminaryBlacklistedFeatures(); |
| 1068 |
| 1069 // Set initialized before running callbacks. |
| 1070 is_initialized_ = true; |
| 1071 |
| 1072 for (const auto& callback : post_init_tasks_) |
| 1073 callback.Run(); |
| 1074 post_init_tasks_.clear(); |
1032 } | 1075 } |
1033 | 1076 |
1034 void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures( | 1077 void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures( |
1035 const std::set<int>& features) { | 1078 const std::set<int>& features) { |
1036 blacklisted_features_ = features; | 1079 blacklisted_features_ = features; |
1037 | 1080 |
1038 // Force disable using the GPU for these features, even if they would | 1081 // Force disable using the GPU for these features, even if they would |
1039 // otherwise be allowed. | 1082 // otherwise be allowed. |
1040 if (card_blacklisted_) { | 1083 if (card_blacklisted_) { |
1041 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING); | 1084 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; | 1236 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
1194 #if defined(OS_WIN) | 1237 #if defined(OS_WIN) |
1195 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | 1238 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; |
1196 #endif | 1239 #endif |
1197 complete_gpu_info_already_requested_ = true; | 1240 complete_gpu_info_already_requested_ = true; |
1198 // Some observers might be waiting. | 1241 // Some observers might be waiting. |
1199 NotifyGpuInfoUpdate(); | 1242 NotifyGpuInfoUpdate(); |
1200 } | 1243 } |
1201 | 1244 |
1202 } // namespace content | 1245 } // namespace content |
OLD | NEW |