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 "base/sys_info.h" |
| 16 #include "gpu/config/gpu_blacklist.h" |
15 #include "gpu/config/gpu_control_list_jsons.h" | 17 #include "gpu/config/gpu_control_list_jsons.h" |
16 #include "gpu/config/gpu_driver_bug_list.h" | 18 #include "gpu/config/gpu_driver_bug_list.h" |
| 19 #include "gpu/config/gpu_feature_type.h" |
| 20 #include "gpu/config/gpu_finch_features.h" |
17 #include "gpu/config/gpu_info_collector.h" | 21 #include "gpu/config/gpu_info_collector.h" |
18 #include "gpu/config/gpu_switches.h" | 22 #include "gpu/config/gpu_switches.h" |
19 #include "ui/gl/gl_switches.h" | 23 #include "ui/gl/gl_switches.h" |
20 #include "ui/gl/gpu_switching_manager.h" | 24 #include "ui/gl/gpu_switching_manager.h" |
21 | 25 |
22 namespace gpu { | 26 namespace gpu { |
23 | 27 |
24 namespace { | 28 namespace { |
25 | 29 |
26 // Combine the integers into a string, seperated by ','. | 30 // Combine the integers into a string, seperated by ','. |
(...skipping 25 matching lines...) Expand all Loading... |
52 DCHECK(list); | 56 DCHECK(list); |
53 for (const base::StringPiece& piece : base::SplitStringPiece( | 57 for (const base::StringPiece& piece : base::SplitStringPiece( |
54 str, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { | 58 str, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
55 uint32_t id = 0; | 59 uint32_t id = 0; |
56 bool succeed = base::HexStringToUInt(piece, &id); | 60 bool succeed = base::HexStringToUInt(piece, &id); |
57 DCHECK(succeed); | 61 DCHECK(succeed); |
58 list->push_back(id); | 62 list->push_back(id); |
59 } | 63 } |
60 } | 64 } |
61 | 65 |
| 66 GpuFeatureStatus GetGpuRasterizationFeatureStatus( |
| 67 const std::set<int>& blacklisted_features, |
| 68 const base::CommandLine& command_line) { |
| 69 if (command_line.HasSwitch(switches::kDisableGpuRasterization)) |
| 70 return kGpuFeatureStatusDisabled; |
| 71 else if (command_line.HasSwitch(switches::kEnableGpuRasterization)) |
| 72 return kGpuFeatureStatusEnabled; |
| 73 |
| 74 if (blacklisted_features.count(GPU_FEATURE_TYPE_GPU_RASTERIZATION)) |
| 75 return kGpuFeatureStatusBlacklisted; |
| 76 |
| 77 #if defined(OS_ANDROID) |
| 78 // We can't use GPU rasterization on low-end devices, because the Ganesh |
| 79 // cache would consume too much memory. |
| 80 if (base::SysInfo::IsLowEndDevice()) |
| 81 return kGpuFeatureStatusBlacklisted; |
| 82 #endif // defined(OS_ANDROID) |
| 83 |
| 84 // Gpu Rasterization on platforms that are not fully enabled is controlled by |
| 85 // a finch experiment. |
| 86 if (!base::FeatureList::IsEnabled(features::kDefaultEnableGpuRasterization)) |
| 87 return kGpuFeatureStatusDisabled; |
| 88 |
| 89 return kGpuFeatureStatusEnabled; |
| 90 } |
| 91 |
62 } // namespace anonymous | 92 } // namespace anonymous |
63 | 93 |
64 void ApplyGpuDriverBugWorkarounds(const GPUInfo& gpu_info, | 94 void ApplyGpuDriverBugWorkarounds(const GPUInfo& gpu_info, |
65 base::CommandLine* command_line) { | 95 base::CommandLine* command_line) { |
66 std::unique_ptr<GpuDriverBugList> list(GpuDriverBugList::Create()); | 96 std::unique_ptr<GpuDriverBugList> list(GpuDriverBugList::Create()); |
67 list->LoadList(kGpuDriverBugListJson, | 97 list->LoadList(kGpuDriverBugListJson, |
68 GpuControlList::kCurrentOsOnly); | 98 GpuControlList::kCurrentOsOnly); |
69 std::set<int> workarounds = list->MakeDecision( | 99 std::set<int> workarounds = list->MakeDecision( |
70 GpuControlList::kOsAny, std::string(), gpu_info); | 100 GpuControlList::kOsAny, std::string(), gpu_info); |
71 GpuDriverBugList::AppendWorkaroundsFromCommandLine( | 101 GpuDriverBugList::AppendWorkaroundsFromCommandLine( |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 ui::GpuSwitchingManager* switching_manager = | 174 ui::GpuSwitchingManager* switching_manager = |
145 ui::GpuSwitchingManager::GetInstance(); | 175 ui::GpuSwitchingManager::GetInstance(); |
146 if (!switching_manager->SupportsDualGpus()) | 176 if (!switching_manager->SupportsDualGpus()) |
147 return; | 177 return; |
148 if (driver_bug_workarounds.count(gpu::FORCE_DISCRETE_GPU) == 1) | 178 if (driver_bug_workarounds.count(gpu::FORCE_DISCRETE_GPU) == 1) |
149 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); | 179 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); |
150 else if (driver_bug_workarounds.count(gpu::FORCE_INTEGRATED_GPU) == 1) | 180 else if (driver_bug_workarounds.count(gpu::FORCE_INTEGRATED_GPU) == 1) |
151 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); | 181 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); |
152 } | 182 } |
153 | 183 |
| 184 GpuFeatureInfo GetGpuFeatureInfo(const GPUInfo& gpu_info, |
| 185 const base::CommandLine& command_line) { |
| 186 GpuFeatureInfo gpu_feature_info; |
| 187 std::set<int> blacklisted_features; |
| 188 if (!command_line.HasSwitch(switches::kIgnoreGpuBlacklist)) { |
| 189 std::unique_ptr<GpuBlacklist> list(GpuBlacklist::Create()); |
| 190 list->LoadList(kSoftwareRenderingListJson, GpuControlList::kCurrentOsOnly); |
| 191 blacklisted_features = |
| 192 list->MakeDecision(GpuControlList::kOsAny, std::string(), gpu_info); |
| 193 } |
| 194 |
| 195 // Currently only used for GPU rasterization. |
| 196 gpu_feature_info.status_values[GPU_FEATURE_TYPE_GPU_RASTERIZATION] = |
| 197 GetGpuRasterizationFeatureStatus(blacklisted_features, command_line); |
| 198 |
| 199 return gpu_feature_info; |
| 200 } |
| 201 |
154 } // namespace gpu | 202 } // namespace gpu |
OLD | NEW |