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

Side by Side Diff: content/browser/gpu/gpu_util.cc

Issue 10915219: Add capability for GPU blacklist to manage GPU switching. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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 "content/browser/gpu/gpu_util.h" 5 #include "content/browser/gpu/gpu_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/sys_info.h" 12 #include "base/sys_info.h"
13 #include "base/version.h" 13 #include "base/version.h"
14 #include "content/browser/gpu/gpu_blacklist.h" 14 #include "content/browser/gpu/gpu_blacklist.h"
15 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
16 16
17 using content::GpuFeatureType; 17 using content::GpuFeatureType;
18 using content::GpuSwitchingOption;
18 19
19 namespace { 20 namespace {
20 21
21 const char kGpuFeatureNameAccelerated2dCanvas[] = "accelerated_2d_canvas"; 22 const char kGpuFeatureNameAccelerated2dCanvas[] = "accelerated_2d_canvas";
22 const char kGpuFeatureNameAcceleratedCompositing[] = "accelerated_compositing"; 23 const char kGpuFeatureNameAcceleratedCompositing[] = "accelerated_compositing";
23 const char kGpuFeatureNameWebgl[] = "webgl"; 24 const char kGpuFeatureNameWebgl[] = "webgl";
24 const char kGpuFeatureNameMultisampling[] = "multisampling"; 25 const char kGpuFeatureNameMultisampling[] = "multisampling";
25 const char kGpuFeatureNameFlash3d[] = "flash_3d"; 26 const char kGpuFeatureNameFlash3d[] = "flash_3d";
26 const char kGpuFeatureNameFlashStage3d[] = "flash_stage3d"; 27 const char kGpuFeatureNameFlashStage3d[] = "flash_stage3d";
27 const char kGpuFeatureNameTextureSharing[] = "texture_sharing"; 28 const char kGpuFeatureNameTextureSharing[] = "texture_sharing";
28 const char kGpuFeatureNameAcceleratedVideoDecode[] = "accelerated_video_decode"; 29 const char kGpuFeatureNameAcceleratedVideoDecode[] = "accelerated_video_decode";
29 const char kGpuFeatureNameAll[] = "all"; 30 const char kGpuFeatureNameAll[] = "all";
30 const char kGpuFeatureNameUnknown[] = "unknown"; 31 const char kGpuFeatureNameUnknown[] = "unknown";
31 32
33 const char kGpuSwitchingNameAutomatic[] = "automatic";
34 const char kGpuSwitchingNameForceIntegrated[] = "force_integrated";
35 const char kGpuSwitchingNameForceDiscrete[] = "force_discrete";
36 const char kGpuSwitchingNameUnknown[] = "unknown";
37
32 enum GpuFeatureStatus { 38 enum GpuFeatureStatus {
33 kGpuFeatureEnabled = 0, 39 kGpuFeatureEnabled = 0,
34 kGpuFeatureBlacklisted = 1, 40 kGpuFeatureBlacklisted = 1,
35 kGpuFeatureDisabled = 2, // disabled by user but not blacklisted 41 kGpuFeatureDisabled = 2, // disabled by user but not blacklisted
36 kGpuFeatureNumStatus 42 kGpuFeatureNumStatus
37 }; 43 };
38 44
39 #if defined(OS_WIN) 45 #if defined(OS_WIN)
40 46
41 enum WinSubVersion { 47 enum WinSubVersion {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 86 }
81 #endif // OS_WIN 87 #endif // OS_WIN
82 88
83 } // namespace 89 } // namespace
84 90
85 namespace gpu_util { 91 namespace gpu_util {
86 92
87 GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) { 93 GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) {
88 if (feature_string == kGpuFeatureNameAccelerated2dCanvas) 94 if (feature_string == kGpuFeatureNameAccelerated2dCanvas)
89 return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; 95 return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS;
90 else if (feature_string == kGpuFeatureNameAcceleratedCompositing) 96 if (feature_string == kGpuFeatureNameAcceleratedCompositing)
91 return content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING; 97 return content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING;
92 else if (feature_string == kGpuFeatureNameWebgl) 98 if (feature_string == kGpuFeatureNameWebgl)
93 return content::GPU_FEATURE_TYPE_WEBGL; 99 return content::GPU_FEATURE_TYPE_WEBGL;
94 else if (feature_string == kGpuFeatureNameMultisampling) 100 if (feature_string == kGpuFeatureNameMultisampling)
95 return content::GPU_FEATURE_TYPE_MULTISAMPLING; 101 return content::GPU_FEATURE_TYPE_MULTISAMPLING;
96 else if (feature_string == kGpuFeatureNameFlash3d) 102 if (feature_string == kGpuFeatureNameFlash3d)
97 return content::GPU_FEATURE_TYPE_FLASH3D; 103 return content::GPU_FEATURE_TYPE_FLASH3D;
98 else if (feature_string == kGpuFeatureNameFlashStage3d) 104 if (feature_string == kGpuFeatureNameFlashStage3d)
99 return content::GPU_FEATURE_TYPE_FLASH_STAGE3D; 105 return content::GPU_FEATURE_TYPE_FLASH_STAGE3D;
100 else if (feature_string == kGpuFeatureNameTextureSharing) 106 if (feature_string == kGpuFeatureNameTextureSharing)
101 return content::GPU_FEATURE_TYPE_TEXTURE_SHARING; 107 return content::GPU_FEATURE_TYPE_TEXTURE_SHARING;
102 else if (feature_string == kGpuFeatureNameAcceleratedVideoDecode) 108 if (feature_string == kGpuFeatureNameAcceleratedVideoDecode)
103 return content::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE; 109 return content::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE;
104 else if (feature_string == kGpuFeatureNameAll) 110 if (feature_string == kGpuFeatureNameAll)
105 return content::GPU_FEATURE_TYPE_ALL; 111 return content::GPU_FEATURE_TYPE_ALL;
106 return content::GPU_FEATURE_TYPE_UNKNOWN; 112 return content::GPU_FEATURE_TYPE_UNKNOWN;
107 } 113 }
108 114
109 std::string GpuFeatureTypeToString(GpuFeatureType type) { 115 std::string GpuFeatureTypeToString(GpuFeatureType type) {
110 std::vector<std::string> matches; 116 std::vector<std::string> matches;
111 if (type == content::GPU_FEATURE_TYPE_ALL) { 117 if (type == content::GPU_FEATURE_TYPE_ALL) {
112 matches.push_back(kGpuFeatureNameAll); 118 matches.push_back(kGpuFeatureNameAll);
113 } else { 119 } else {
114 if (type & content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) 120 if (type & content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)
(...skipping 11 matching lines...) Expand all
126 if (type & content::GPU_FEATURE_TYPE_TEXTURE_SHARING) 132 if (type & content::GPU_FEATURE_TYPE_TEXTURE_SHARING)
127 matches.push_back(kGpuFeatureNameTextureSharing); 133 matches.push_back(kGpuFeatureNameTextureSharing);
128 if (type & content::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) 134 if (type & content::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE)
129 matches.push_back(kGpuFeatureNameAcceleratedVideoDecode); 135 matches.push_back(kGpuFeatureNameAcceleratedVideoDecode);
130 if (!matches.size()) 136 if (!matches.size())
131 matches.push_back(kGpuFeatureNameUnknown); 137 matches.push_back(kGpuFeatureNameUnknown);
132 } 138 }
133 return JoinString(matches, ','); 139 return JoinString(matches, ',');
134 } 140 }
135 141
142 GpuSwitchingOption StringToGpuSwitchingOption(
143 const std::string& switching_string) {
144 if (switching_string == kGpuSwitchingNameAutomatic)
145 return content::GPU_SWITCHING_AUTOMATIC;
146 if (switching_string == kGpuSwitchingNameForceIntegrated)
147 return content::GPU_SWITCHING_FORCE_INTEGRATED;
148 if (switching_string == kGpuSwitchingNameForceDiscrete)
149 return content::GPU_SWITCHING_FORCE_DISCRETE;
150 return content::GPU_SWITCHING_UNKNOWN;
151 }
152
136 void UpdateStats(const GpuBlacklist* blacklist, 153 void UpdateStats(const GpuBlacklist* blacklist,
137 uint32 blacklisted_features) { 154 uint32 blacklisted_features) {
138 uint32 max_entry_id = blacklist->max_entry_id(); 155 uint32 max_entry_id = blacklist->max_entry_id();
139 if (max_entry_id == 0) { 156 if (max_entry_id == 0) {
140 // GPU Blacklist was not loaded. No need to go further. 157 // GPU Blacklist was not loaded. No need to go further.
141 return; 158 return;
142 } 159 }
143 160
144 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 161 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
145 bool disabled = false; 162 bool disabled = false;
146 if (blacklisted_features == 0) { 163 if (blacklisted_features == 0) {
147 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", 164 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry",
148 0, max_entry_id + 1); 165 0, max_entry_id + 1);
149 } else { 166 } else {
150 std::vector<uint32> flag_entries; 167 std::vector<uint32> flag_entries;
151 blacklist->GetGpuFeatureTypeEntries( 168 blacklist->GetDecisionEntries(flag_entries, disabled);
152 content::GPU_FEATURE_TYPE_ALL, flag_entries, disabled);
153 DCHECK_GT(flag_entries.size(), 0u); 169 DCHECK_GT(flag_entries.size(), 0u);
154 for (size_t i = 0; i < flag_entries.size(); ++i) { 170 for (size_t i = 0; i < flag_entries.size(); ++i) {
155 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", 171 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry",
156 flag_entries[i], max_entry_id + 1); 172 flag_entries[i], max_entry_id + 1);
157 } 173 }
158 } 174 }
159 175
160 // This counts how many users are affected by a disabled entry - this allows 176 // This counts how many users are affected by a disabled entry - this allows
161 // us to understand the impact of an entry before enable it. 177 // us to understand the impact of an entry before enable it.
162 std::vector<uint32> flag_disabled_entries; 178 std::vector<uint32> flag_disabled_entries;
163 disabled = true; 179 disabled = true;
164 blacklist->GetGpuFeatureTypeEntries( 180 blacklist->GetDecisionEntries(flag_disabled_entries, disabled);
165 content::GPU_FEATURE_TYPE_ALL, flag_disabled_entries, disabled);
166 for (size_t i = 0; i < flag_disabled_entries.size(); ++i) { 181 for (size_t i = 0; i < flag_disabled_entries.size(); ++i) {
167 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerDisabledEntry", 182 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerDisabledEntry",
168 flag_disabled_entries[i], max_entry_id + 1); 183 flag_disabled_entries[i], max_entry_id + 1);
169 } 184 }
170 185
171 const content::GpuFeatureType kGpuFeatures[] = { 186 const content::GpuFeatureType kGpuFeatures[] = {
172 content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, 187 content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS,
173 content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING, 188 content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING,
174 content::GPU_FEATURE_TYPE_WEBGL 189 content::GPU_FEATURE_TYPE_WEBGL
175 }; 190 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 kGpuBlacklistFeatureHistogramNamesWin[i], 229 kGpuBlacklistFeatureHistogramNamesWin[i],
215 1, kNumWinSubVersions * kGpuFeatureNumStatus, 230 1, kNumWinSubVersions * kGpuFeatureNumStatus,
216 kNumWinSubVersions * kGpuFeatureNumStatus + 1, 231 kNumWinSubVersions * kGpuFeatureNumStatus + 1,
217 base::Histogram::kUmaTargetedHistogramFlag); 232 base::Histogram::kUmaTargetedHistogramFlag);
218 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); 233 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value));
219 #endif 234 #endif
220 } 235 }
221 } 236 }
222 237
223 } // namespace gpu_util; 238 } // namespace gpu_util;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698