Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/config/gpu_util.h" | 5 #include "gpu/config/gpu_util.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "gpu/config/gpu_blacklist.h" | |
| 15 #include "gpu/config/gpu_control_list_jsons.h" | 16 #include "gpu/config/gpu_control_list_jsons.h" |
| 16 #include "gpu/config/gpu_driver_bug_list.h" | 17 #include "gpu/config/gpu_driver_bug_list.h" |
| 18 #include "gpu/config/gpu_feature_type.h" | |
| 19 #include "gpu/config/gpu_features.h" | |
| 17 #include "gpu/config/gpu_info_collector.h" | 20 #include "gpu/config/gpu_info_collector.h" |
| 18 #include "gpu/config/gpu_switches.h" | 21 #include "gpu/config/gpu_switches.h" |
| 19 #include "ui/gl/gl_switches.h" | 22 #include "ui/gl/gl_switches.h" |
| 20 #include "ui/gl/gpu_switching_manager.h" | 23 #include "ui/gl/gpu_switching_manager.h" |
| 21 | 24 |
| 22 namespace gpu { | 25 namespace gpu { |
| 23 | 26 |
| 24 namespace { | 27 namespace { |
| 25 | 28 |
| 26 // Combine the integers into a string, seperated by ','. | 29 // Combine the integers into a string, seperated by ','. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 52 DCHECK(list); | 55 DCHECK(list); |
| 53 for (const base::StringPiece& piece : base::SplitStringPiece( | 56 for (const base::StringPiece& piece : base::SplitStringPiece( |
| 54 str, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { | 57 str, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
| 55 uint32_t id = 0; | 58 uint32_t id = 0; |
| 56 bool succeed = base::HexStringToUInt(piece, &id); | 59 bool succeed = base::HexStringToUInt(piece, &id); |
| 57 DCHECK(succeed); | 60 DCHECK(succeed); |
| 58 list->push_back(id); | 61 list->push_back(id); |
| 59 } | 62 } |
| 60 } | 63 } |
| 61 | 64 |
| 65 GpuFeatureStatus GetGpuRasterizationFeatureStatus( | |
| 66 const std::set<int>& blacklisted_features, | |
| 67 const base::CommandLine& command_line) { | |
| 68 if (command_line.HasSwitch(switches::kDisableGpuRasterization)) | |
| 69 return kGpuFeatureStatusDisabled; | |
| 70 else if (command_line.HasSwitch(switches::kEnableGpuRasterization)) | |
| 71 return kGpuFeatureStatusEnabled; | |
| 72 | |
| 73 if (blacklisted_features.count(GPU_FEATURE_TYPE_GPU_RASTERIZATION)) | |
| 74 return kGpuFeatureStatusBlacklisted; | |
| 75 | |
| 76 // Gpu Rasterization on platforms that are not fully enabled is controlled by | |
| 77 // a finch experiment. | |
| 78 if (!base::FeatureList::IsEnabled(features::kDefaultEnableGpuRasterization)) | |
| 79 return kGpuFeatureStatusDisabled; | |
| 80 | |
| 81 return kGpuFeatureStatusEnabled; | |
| 82 } | |
| 83 | |
| 62 } // namespace anonymous | 84 } // namespace anonymous |
| 63 | 85 |
| 64 void ApplyGpuDriverBugWorkarounds(const GPUInfo& gpu_info, | 86 void ApplyGpuDriverBugWorkarounds(const GPUInfo& gpu_info, |
| 65 base::CommandLine* command_line) { | 87 base::CommandLine* command_line) { |
| 66 std::unique_ptr<GpuDriverBugList> list(GpuDriverBugList::Create()); | 88 std::unique_ptr<GpuDriverBugList> list(GpuDriverBugList::Create()); |
| 67 list->LoadList(kGpuDriverBugListJson, | 89 list->LoadList(kGpuDriverBugListJson, |
| 68 GpuControlList::kCurrentOsOnly); | 90 GpuControlList::kCurrentOsOnly); |
| 69 std::set<int> workarounds = list->MakeDecision( | 91 std::set<int> workarounds = list->MakeDecision( |
| 70 GpuControlList::kOsAny, std::string(), gpu_info); | 92 GpuControlList::kOsAny, std::string(), gpu_info); |
| 71 GpuDriverBugList::AppendWorkaroundsFromCommandLine( | 93 GpuDriverBugList::AppendWorkaroundsFromCommandLine( |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 ui::GpuSwitchingManager* switching_manager = | 166 ui::GpuSwitchingManager* switching_manager = |
| 145 ui::GpuSwitchingManager::GetInstance(); | 167 ui::GpuSwitchingManager::GetInstance(); |
| 146 if (!switching_manager->SupportsDualGpus()) | 168 if (!switching_manager->SupportsDualGpus()) |
| 147 return; | 169 return; |
| 148 if (driver_bug_workarounds.count(gpu::FORCE_DISCRETE_GPU) == 1) | 170 if (driver_bug_workarounds.count(gpu::FORCE_DISCRETE_GPU) == 1) |
| 149 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); | 171 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); |
| 150 else if (driver_bug_workarounds.count(gpu::FORCE_INTEGRATED_GPU) == 1) | 172 else if (driver_bug_workarounds.count(gpu::FORCE_INTEGRATED_GPU) == 1) |
| 151 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); | 173 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); |
| 152 } | 174 } |
| 153 | 175 |
| 176 GpuFeatureInfo GetGpuFeatureInfo(const GPUInfo& gpu_info, | |
| 177 const base::CommandLine& command_line) { | |
|
Zhenyao Mo
2017/02/03 23:57:32
Can we DCHECK it's either in-process gpu mode or i
ericrk
2017/02/06 19:51:38
I did a bit of searching and I couldn't find a goo
| |
| 178 GpuFeatureInfo gpu_feature_info; | |
| 179 std::set<int> blacklisted_features; | |
| 180 if (!command_line.HasSwitch(switches::kIgnoreGpuBlacklist)) { | |
| 181 std::unique_ptr<GpuBlacklist> list(GpuBlacklist::Create()); | |
| 182 list->LoadList(kSoftwareRenderingListJson, GpuControlList::kCurrentOsOnly); | |
| 183 blacklisted_features = | |
| 184 list->MakeDecision(GpuControlList::kOsAny, std::string(), gpu_info); | |
| 185 } | |
| 186 | |
| 187 // Currently only used for GPU rasterization. | |
| 188 gpu_feature_info.status_values[GPU_FEATURE_TYPE_GPU_RASTERIZATION] = | |
| 189 GetGpuRasterizationFeatureStatus(blacklisted_features, command_line); | |
| 190 | |
| 191 return gpu_feature_info; | |
| 192 } | |
| 193 | |
| 154 } // namespace gpu | 194 } // namespace gpu |
| OLD | NEW |