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

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: fix win clang build 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::kGpuFeatureStatusUndefined:
117 case gpu::kGpuFeatureStatusMax:
124 NOTREACHED(); 118 NOTREACHED();
125 break; 119 break;
126 } 120 }
127 return entry_index; 121 return entry_index;
128 } 122 }
129 #endif // OS_WIN 123 #endif // OS_WIN
130 124
131 // Send UMA histograms about the enabled features and GPU properties. 125 // Send UMA histograms about the enabled features and GPU properties.
132 void UpdateStats(const gpu::GPUInfo& gpu_info, 126 void UpdateStats(const gpu::GPUInfo& gpu_info,
133 const gpu::GpuBlacklist* blacklist, 127 const gpu::GpuBlacklist* blacklist,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 "GPU.BlacklistFeatureTestResultsWindows.GpuCompositing", 188 "GPU.BlacklistFeatureTestResultsWindows.GpuCompositing",
195 "GPU.BlacklistFeatureTestResultsWindows.GpuRasterization", 189 "GPU.BlacklistFeatureTestResultsWindows.GpuRasterization",
196 "GPU.BlacklistFeatureTestResultsWindows.Webgl", 190 "GPU.BlacklistFeatureTestResultsWindows.Webgl",
197 "GPU.BlacklistFeatureTestResultsWindows.Webgl2"}; 191 "GPU.BlacklistFeatureTestResultsWindows.Webgl2"};
198 #endif 192 #endif
199 const size_t kNumFeatures = 193 const size_t kNumFeatures =
200 sizeof(kGpuFeatures) / sizeof(gpu::GpuFeatureType); 194 sizeof(kGpuFeatures) / sizeof(gpu::GpuFeatureType);
201 for (size_t i = 0; i < kNumFeatures; ++i) { 195 for (size_t i = 0; i < kNumFeatures; ++i) {
202 // We can't use UMA_HISTOGRAM_ENUMERATION here because the same name is 196 // We can't use UMA_HISTOGRAM_ENUMERATION here because the same name is
203 // expected if the macro is used within a loop. 197 // expected if the macro is used within a loop.
204 GpuFeatureStatus value = kGpuFeatureEnabled; 198 gpu::GpuFeatureStatus value = gpu::kGpuFeatureStatusEnabled;
205 if (blacklisted_features.count(kGpuFeatures[i])) 199 if (blacklisted_features.count(kGpuFeatures[i]))
206 value = kGpuFeatureBlacklisted; 200 value = gpu::kGpuFeatureStatusBlacklisted;
207 else if (kGpuFeatureUserFlags[i]) 201 else if (kGpuFeatureUserFlags[i])
208 value = kGpuFeatureDisabled; 202 value = gpu::kGpuFeatureStatusDisabled;
209 base::HistogramBase* histogram_pointer = base::LinearHistogram::FactoryGet( 203 base::HistogramBase* histogram_pointer = base::LinearHistogram::FactoryGet(
210 kGpuBlacklistFeatureHistogramNames[i], 204 kGpuBlacklistFeatureHistogramNames[i], 1, gpu::kGpuFeatureStatusMax,
211 1, kGpuFeatureNumStatus, kGpuFeatureNumStatus + 1, 205 gpu::kGpuFeatureStatusMax + 1,
212 base::HistogramBase::kUmaTargetedHistogramFlag); 206 base::HistogramBase::kUmaTargetedHistogramFlag);
213 histogram_pointer->Add(value); 207 histogram_pointer->Add(value);
214 #if defined(OS_WIN) 208 #if defined(OS_WIN)
215 histogram_pointer = base::LinearHistogram::FactoryGet( 209 histogram_pointer = base::LinearHistogram::FactoryGet(
216 kGpuBlacklistFeatureHistogramNamesWin[i], 210 kGpuBlacklistFeatureHistogramNamesWin[i], 1,
217 1, kNumWinSubVersions * kGpuFeatureNumStatus, 211 kNumWinSubVersions * gpu::kGpuFeatureStatusMax,
218 kNumWinSubVersions * kGpuFeatureNumStatus + 1, 212 kNumWinSubVersions * gpu::kGpuFeatureStatusMax + 1,
219 base::HistogramBase::kUmaTargetedHistogramFlag); 213 base::HistogramBase::kUmaTargetedHistogramFlag);
220 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); 214 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value));
221 #endif 215 #endif
222 } 216 }
223 } 217 }
224 218
225 // Combine the integers into a string, seperated by ','. 219 // Combine the integers into a string, seperated by ','.
226 std::string IntSetToString(const std::set<int>& list) { 220 std::string IntSetToString(const std::set<int>& list) {
227 std::string rt; 221 std::string rt;
228 for (std::set<int>::const_iterator it = list.begin(); 222 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 296 // Skia's software rendering is probably more efficient than going through
303 // software emulation of the GPU, so use that. 297 // software emulation of the GPU, so use that.
304 if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) 298 if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)
305 return true; 299 return true;
306 return false; 300 return false;
307 } 301 }
308 302
309 return (blacklisted_features_.count(feature) == 1); 303 return (blacklisted_features_.count(feature) == 1);
310 } 304 }
311 305
306 bool GpuDataManagerImplPrivate::IsFeatureEnabled(int feature) const {
307 DCHECK_EQ(feature, gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION);
308 return gpu_feature_info_
309 .status_values[gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION] ==
310 gpu::kGpuFeatureStatusEnabled;
311 }
312
312 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { 313 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const {
313 return (gpu_driver_bugs_.count(feature) == 1); 314 return (gpu_driver_bugs_.count(feature) == 1);
314 } 315 }
315 316
316 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { 317 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const {
317 if (use_swiftshader_) 318 if (use_swiftshader_)
318 return 1; 319 return 1;
319 return blacklisted_features_.size(); 320 return blacklisted_features_.size();
320 } 321 }
321 322
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 if (IsCompleteGpuInfoAvailable()) { 676 if (IsCompleteGpuInfoAvailable()) {
676 complete_gpu_info_already_requested_ = true; 677 complete_gpu_info_already_requested_ = true;
677 } else if (was_info_available) { 678 } else if (was_info_available) {
678 // Allow future requests to go through properly. 679 // Allow future requests to go through properly.
679 complete_gpu_info_already_requested_ = false; 680 complete_gpu_info_already_requested_ = false;
680 } 681 }
681 682
682 UpdateGpuInfoHelper(); 683 UpdateGpuInfoHelper();
683 } 684 }
684 685
686 void GpuDataManagerImplPrivate::UpdateGpuFeatureInfo(
687 const gpu::GpuFeatureInfo& gpu_feature_info) {
688 gpu_feature_info_ = gpu_feature_info;
689 }
690
685 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats( 691 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats(
686 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) { 692 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) {
687 GpuDataManagerImpl::UnlockedSession session(owner_); 693 GpuDataManagerImpl::UnlockedSession session(owner_);
688 observer_list_->Notify(FROM_HERE, 694 observer_list_->Notify(FROM_HERE,
689 &GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, 695 &GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate,
690 video_memory_usage_stats); 696 video_memory_usage_stats);
691 } 697 }
692 698
693 void GpuDataManagerImplPrivate::AppendRendererCommandLine( 699 void GpuDataManagerImplPrivate::AppendRendererCommandLine(
694 base::CommandLine* command_line) const { 700 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; 1353 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure;
1348 #if defined(OS_WIN) 1354 #if defined(OS_WIN)
1349 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; 1355 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure;
1350 #endif 1356 #endif
1351 complete_gpu_info_already_requested_ = true; 1357 complete_gpu_info_already_requested_ = true;
1352 // Some observers might be waiting. 1358 // Some observers might be waiting.
1353 NotifyGpuInfoUpdate(); 1359 NotifyGpuInfoUpdate();
1354 } 1360 }
1355 1361
1356 } // namespace content 1362 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_data_manager_impl_private.h ('k') | content/browser/gpu/gpu_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698