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

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

Issue 2654993004: Move GPU blacklist calculation to GPU proc (Closed)
Patch Set: Feedback + add rest of logic back in Created 3 years, 10 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
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include <ApplicationServices/ApplicationServices.h> 54 #include <ApplicationServices/ApplicationServices.h>
55 #endif // OS_MACOSX 55 #endif // OS_MACOSX
56 #if defined(OS_WIN) 56 #if defined(OS_WIN)
57 #include "base/win/windows_version.h" 57 #include "base/win/windows_version.h"
58 #endif // OS_WIN 58 #endif // OS_WIN
59 59
60 namespace content { 60 namespace content {
61 61
62 namespace { 62 namespace {
63 63
64 enum GpuFeatureStatus {
65 kGpuFeatureEnabled = 0,
66 kGpuFeatureBlacklisted = 1,
67 kGpuFeatureDisabled = 2, // disabled by user but not blacklisted
68 kGpuFeatureNumStatus
69 };
70
71 #if defined(OS_WIN) 64 #if defined(OS_WIN)
72 65
73 enum WinSubVersion { 66 enum WinSubVersion {
74 kWinOthers = 0, 67 kWinOthers = 0,
75 kWinXP, 68 kWinXP,
76 kWinVista, 69 kWinVista,
77 kWin7, 70 kWin7,
78 kWin8, 71 kWin8,
79 kWin8_1, 72 kWin8_1,
80 kWin10, 73 kWin10,
81 kWin10_TH2, 74 kWin10_TH2,
82 kNumWinSubVersions 75 kNumWinSubVersions
83 }; 76 };
84 77
85 int GetGpuBlacklistHistogramValueWin(GpuFeatureStatus status) { 78 int GetGpuBlacklistHistogramValueWin(gpu::GpuFeatureStatus status) {
86 static WinSubVersion sub_version = kNumWinSubVersions; 79 static WinSubVersion sub_version = kNumWinSubVersions;
87 if (sub_version == kNumWinSubVersions) { 80 if (sub_version == kNumWinSubVersions) {
88 sub_version = kWinOthers; 81 sub_version = kWinOthers;
89 switch (base::win::GetVersion()) { 82 switch (base::win::GetVersion()) {
90 case base::win::VERSION_PRE_XP: 83 case base::win::VERSION_PRE_XP:
91 case base::win::VERSION_XP: 84 case base::win::VERSION_XP:
92 case base::win::VERSION_SERVER_2003: 85 case base::win::VERSION_SERVER_2003:
93 case base::win::VERSION_VISTA: 86 case base::win::VERSION_VISTA:
94 case base::win::VERSION_WIN_LAST: 87 case base::win::VERSION_WIN_LAST:
95 break; 88 break;
96 case base::win::VERSION_WIN7: 89 case base::win::VERSION_WIN7:
97 sub_version = kWin7; 90 sub_version = kWin7;
98 break; 91 break;
99 case base::win::VERSION_WIN8: 92 case base::win::VERSION_WIN8:
100 sub_version = kWin8; 93 sub_version = kWin8;
101 break; 94 break;
102 case base::win::VERSION_WIN8_1: 95 case base::win::VERSION_WIN8_1:
103 sub_version = kWin8_1; 96 sub_version = kWin8_1;
104 break; 97 break;
105 case base::win::VERSION_WIN10: 98 case base::win::VERSION_WIN10:
106 sub_version = kWin10; 99 sub_version = kWin10;
107 break; 100 break;
108 case base::win::VERSION_WIN10_TH2: 101 case base::win::VERSION_WIN10_TH2:
109 sub_version = kWin10_TH2; 102 sub_version = kWin10_TH2;
110 break; 103 break;
111 } 104 }
112 } 105 }
113 int entry_index = static_cast<int>(sub_version) * kGpuFeatureNumStatus; 106 int entry_index = static_cast<int>(sub_version) * gpu::kGpuFeatureStatusMax;
114 switch (status) { 107 switch (status) {
115 case kGpuFeatureEnabled: 108 case gpu::kGpuFeatureStatusEnabled:
116 break; 109 break;
117 case kGpuFeatureBlacklisted: 110 case gpu::kGpuFeatureStatusBlacklisted:
118 entry_index++; 111 entry_index++;
119 break; 112 break;
120 case kGpuFeatureDisabled: 113 case gpu::kGpuFeatureStatusDisabled:
121 entry_index += 2; 114 entry_index += 2;
122 break; 115 break;
123 case kGpuFeatureNumStatus: 116 case gpu::kGpuFeatureStatusMax:
124 NOTREACHED(); 117 NOTREACHED();
125 break; 118 break;
126 } 119 }
127 return entry_index; 120 return entry_index;
128 } 121 }
129 #endif // OS_WIN 122 #endif // OS_WIN
130 123
131 // Send UMA histograms about the enabled features and GPU properties. 124 // Send UMA histograms about the enabled features and GPU properties.
132 void UpdateStats(const gpu::GPUInfo& gpu_info, 125 void UpdateStats(const gpu::GPUInfo& gpu_info,
133 const gpu::GpuBlacklist* blacklist, 126 const gpu::GpuBlacklist* blacklist,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 "GPU.BlacklistFeatureTestResultsWindows.GpuCompositing", 187 "GPU.BlacklistFeatureTestResultsWindows.GpuCompositing",
195 "GPU.BlacklistFeatureTestResultsWindows.GpuRasterization", 188 "GPU.BlacklistFeatureTestResultsWindows.GpuRasterization",
196 "GPU.BlacklistFeatureTestResultsWindows.Webgl", 189 "GPU.BlacklistFeatureTestResultsWindows.Webgl",
197 "GPU.BlacklistFeatureTestResultsWindows.Webgl2"}; 190 "GPU.BlacklistFeatureTestResultsWindows.Webgl2"};
198 #endif 191 #endif
199 const size_t kNumFeatures = 192 const size_t kNumFeatures =
200 sizeof(kGpuFeatures) / sizeof(gpu::GpuFeatureType); 193 sizeof(kGpuFeatures) / sizeof(gpu::GpuFeatureType);
201 for (size_t i = 0; i < kNumFeatures; ++i) { 194 for (size_t i = 0; i < kNumFeatures; ++i) {
202 // We can't use UMA_HISTOGRAM_ENUMERATION here because the same name is 195 // We can't use UMA_HISTOGRAM_ENUMERATION here because the same name is
203 // expected if the macro is used within a loop. 196 // expected if the macro is used within a loop.
204 GpuFeatureStatus value = kGpuFeatureEnabled; 197 gpu::GpuFeatureStatus value = gpu::kGpuFeatureStatusEnabled;
205 if (blacklisted_features.count(kGpuFeatures[i])) 198 if (blacklisted_features.count(kGpuFeatures[i]))
206 value = kGpuFeatureBlacklisted; 199 value = gpu::kGpuFeatureStatusBlacklisted;
207 else if (kGpuFeatureUserFlags[i]) 200 else if (kGpuFeatureUserFlags[i])
208 value = kGpuFeatureDisabled; 201 value = gpu::kGpuFeatureStatusDisabled;
209 base::HistogramBase* histogram_pointer = base::LinearHistogram::FactoryGet( 202 base::HistogramBase* histogram_pointer = base::LinearHistogram::FactoryGet(
210 kGpuBlacklistFeatureHistogramNames[i], 203 kGpuBlacklistFeatureHistogramNames[i], 1, gpu::kGpuFeatureStatusMax,
211 1, kGpuFeatureNumStatus, kGpuFeatureNumStatus + 1, 204 gpu::kGpuFeatureStatusMax + 1,
212 base::HistogramBase::kUmaTargetedHistogramFlag); 205 base::HistogramBase::kUmaTargetedHistogramFlag);
213 histogram_pointer->Add(value); 206 histogram_pointer->Add(value);
214 #if defined(OS_WIN) 207 #if defined(OS_WIN)
215 histogram_pointer = base::LinearHistogram::FactoryGet( 208 histogram_pointer = base::LinearHistogram::FactoryGet(
216 kGpuBlacklistFeatureHistogramNamesWin[i], 209 kGpuBlacklistFeatureHistogramNamesWin[i], 1,
217 1, kNumWinSubVersions * kGpuFeatureNumStatus, 210 kNumWinSubVersions * gpu::kGpuFeatureStatusMax,
218 kNumWinSubVersions * kGpuFeatureNumStatus + 1, 211 kNumWinSubVersions * gpu::kGpuFeatureStatusMax + 1,
219 base::HistogramBase::kUmaTargetedHistogramFlag); 212 base::HistogramBase::kUmaTargetedHistogramFlag);
220 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); 213 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value));
221 #endif 214 #endif
222 } 215 }
223 } 216 }
224 217
225 // Combine the integers into a string, seperated by ','. 218 // Combine the integers into a string, seperated by ','.
226 std::string IntSetToString(const std::set<int>& list) { 219 std::string IntSetToString(const std::set<int>& list) {
227 std::string rt; 220 std::string rt;
228 for (std::set<int>::const_iterator it = list.begin(); 221 for (std::set<int>::const_iterator it = list.begin();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 // Skia's software rendering is probably more efficient than going through 295 // Skia's software rendering is probably more efficient than going through
303 // software emulation of the GPU, so use that. 296 // software emulation of the GPU, so use that.
304 if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) 297 if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)
305 return true; 298 return true;
306 return false; 299 return false;
307 } 300 }
308 301
309 return (blacklisted_features_.count(feature) == 1); 302 return (blacklisted_features_.count(feature) == 1);
310 } 303 }
311 304
305 bool GpuDataManagerImplPrivate::IsFeatureEnabled(int feature) const {
Zhenyao Mo 2017/02/03 23:57:32 What is the design for the situation if this is ca
ericrk 2017/02/06 19:51:38 makes sense - added disabled.
306 DCHECK_EQ(feature, gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION);
307 return gpu_feature_info_
ericrk 2017/01/30 15:41:24 We could also put an IsFeatureEnabled on GpuFeatur
Zhenyao Mo 2017/02/03 23:57:32 Sounds good.
308 .status_values[gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION] ==
309 gpu::kGpuFeatureStatusEnabled;
310 }
311
312 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { 312 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const {
313 return (gpu_driver_bugs_.count(feature) == 1); 313 return (gpu_driver_bugs_.count(feature) == 1);
314 } 314 }
315 315
316 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { 316 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const {
317 if (use_swiftshader_) 317 if (use_swiftshader_)
318 return 1; 318 return 1;
319 return blacklisted_features_.size(); 319 return blacklisted_features_.size();
320 } 320 }
321 321
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 if (IsCompleteGpuInfoAvailable()) { 675 if (IsCompleteGpuInfoAvailable()) {
676 complete_gpu_info_already_requested_ = true; 676 complete_gpu_info_already_requested_ = true;
677 } else if (was_info_available) { 677 } else if (was_info_available) {
678 // Allow future requests to go through properly. 678 // Allow future requests to go through properly.
679 complete_gpu_info_already_requested_ = false; 679 complete_gpu_info_already_requested_ = false;
680 } 680 }
681 681
682 UpdateGpuInfoHelper(); 682 UpdateGpuInfoHelper();
683 } 683 }
684 684
685 void GpuDataManagerImplPrivate::UpdateGpuFeatureInfo(
686 const gpu::GpuFeatureInfo& gpu_feature_info) {
687 gpu_feature_info_ = gpu_feature_info;
688 }
689
685 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats( 690 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats(
686 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) { 691 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) {
687 GpuDataManagerImpl::UnlockedSession session(owner_); 692 GpuDataManagerImpl::UnlockedSession session(owner_);
688 observer_list_->Notify(FROM_HERE, 693 observer_list_->Notify(FROM_HERE,
689 &GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, 694 &GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate,
690 video_memory_usage_stats); 695 video_memory_usage_stats);
691 } 696 }
692 697
693 void GpuDataManagerImplPrivate::AppendRendererCommandLine( 698 void GpuDataManagerImplPrivate::AppendRendererCommandLine(
694 base::CommandLine* command_line) const { 699 base::CommandLine* command_line) const {
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; 1352 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure;
1348 #if defined(OS_WIN) 1353 #if defined(OS_WIN)
1349 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; 1354 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure;
1350 #endif 1355 #endif
1351 complete_gpu_info_already_requested_ = true; 1356 complete_gpu_info_already_requested_ = true;
1352 // Some observers might be waiting. 1357 // Some observers might be waiting.
1353 NotifyGpuInfoUpdate(); 1358 NotifyGpuInfoUpdate();
1354 } 1359 }
1355 1360
1356 } // namespace content 1361 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698