OLD | NEW |
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 blacklist->GetDecisionEntries(&flag_disabled_entries, disabled); | 160 blacklist->GetDecisionEntries(&flag_disabled_entries, disabled); |
161 for (uint32_t disabled_entry : flag_disabled_entries) { | 161 for (uint32_t disabled_entry : flag_disabled_entries) { |
162 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerDisabledEntry", | 162 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerDisabledEntry", |
163 disabled_entry, max_entry_id + 1); | 163 disabled_entry, max_entry_id + 1); |
164 } | 164 } |
165 | 165 |
166 const gpu::GpuFeatureType kGpuFeatures[] = { | 166 const gpu::GpuFeatureType kGpuFeatures[] = { |
167 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, | 167 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, |
168 gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING, | 168 gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING, |
169 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION, | 169 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION, |
170 gpu::GPU_FEATURE_TYPE_WEBGL, | 170 gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL, gpu::GPU_FEATURE_TYPE_WEBGL2}; |
171 gpu::GPU_FEATURE_TYPE_WEBGL2}; | |
172 const std::string kGpuBlacklistFeatureHistogramNames[] = { | 171 const std::string kGpuBlacklistFeatureHistogramNames[] = { |
173 "GPU.BlacklistFeatureTestResults.Accelerated2dCanvas", | 172 "GPU.BlacklistFeatureTestResults.Accelerated2dCanvas", |
174 "GPU.BlacklistFeatureTestResults.GpuCompositing", | 173 "GPU.BlacklistFeatureTestResults.GpuCompositing", |
175 "GPU.BlacklistFeatureTestResults.GpuRasterization", | 174 "GPU.BlacklistFeatureTestResults.GpuRasterization", |
176 "GPU.BlacklistFeatureTestResults.Webgl", | 175 "GPU.BlacklistFeatureTestResults.Webgl", |
177 "GPU.BlacklistFeatureTestResults.Webgl2"}; | 176 "GPU.BlacklistFeatureTestResults.Webgl2"}; |
178 const bool kGpuFeatureUserFlags[] = { | 177 const bool kGpuFeatureUserFlags[] = { |
179 command_line.HasSwitch(switches::kDisableAccelerated2dCanvas), | 178 command_line.HasSwitch(switches::kDisableAccelerated2dCanvas), |
180 command_line.HasSwitch(switches::kDisableGpu), | 179 command_line.HasSwitch(switches::kDisableGpu), |
181 command_line.HasSwitch(switches::kDisableGpuRasterization), | 180 command_line.HasSwitch(switches::kDisableGpuRasterization), |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 294 } |
296 | 295 |
297 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { | 296 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { |
298 #if defined(OS_CHROMEOS) | 297 #if defined(OS_CHROMEOS) |
299 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && | 298 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && |
300 base::CommandLine::ForCurrentProcess()->HasSwitch( | 299 base::CommandLine::ForCurrentProcess()->HasSwitch( |
301 switches::kDisablePanelFitting)) { | 300 switches::kDisablePanelFitting)) { |
302 return true; | 301 return true; |
303 } | 302 } |
304 #endif // OS_CHROMEOS | 303 #endif // OS_CHROMEOS |
305 if (use_swiftshader_) { | |
306 // Skia's software rendering is probably more efficient than going through | |
307 // software emulation of the GPU, so use that. | |
308 if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) | |
309 return true; | |
310 return false; | |
311 } | |
312 | 304 |
313 return (blacklisted_features_.count(feature) == 1); | 305 // SwiftShader blacklists all features |
| 306 return use_swiftshader_ || (blacklisted_features_.count(feature) == 1); |
314 } | 307 } |
315 | 308 |
316 bool GpuDataManagerImplPrivate::IsFeatureEnabled(int feature) const { | 309 bool GpuDataManagerImplPrivate::IsFeatureEnabled(int feature) const { |
317 DCHECK_EQ(feature, gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); | 310 DCHECK_EQ(feature, gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); |
318 return gpu_feature_info_ | 311 return gpu_feature_info_ |
319 .status_values[gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION] == | 312 .status_values[gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION] == |
320 gpu::kGpuFeatureStatusEnabled; | 313 gpu::kGpuFeatureStatusEnabled; |
321 } | 314 } |
322 | 315 |
| 316 bool GpuDataManagerImplPrivate::IsWebGLEnabled() const { |
| 317 return use_swiftshader_ || |
| 318 !blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL); |
| 319 } |
| 320 |
323 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { | 321 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { |
324 return (gpu_driver_bugs_.count(feature) == 1); | 322 return (gpu_driver_bugs_.count(feature) == 1); |
325 } | 323 } |
326 | 324 |
327 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { | 325 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { |
328 if (use_swiftshader_) | 326 // SwiftShader blacklists all features |
329 return 1; | 327 return use_swiftshader_ ? gpu::NUMBER_OF_GPU_FEATURE_TYPES |
330 return blacklisted_features_.size(); | 328 : blacklisted_features_.size(); |
331 } | 329 } |
332 | 330 |
333 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { | 331 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { |
334 return gpu_info_; | 332 return gpu_info_; |
335 } | 333 } |
336 | 334 |
337 void GpuDataManagerImplPrivate::GetGpuProcessHandles( | 335 void GpuDataManagerImplPrivate::GetGpuProcessHandles( |
338 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { | 336 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { |
339 GpuProcessHost::GetProcessHandles(callback); | 337 GpuProcessHost::GetProcessHandles(callback); |
340 } | 338 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 // because their context creation can always be rejected on the GPU process | 371 // because their context creation can always be rejected on the GPU process |
374 // side. | 372 // side. |
375 std::set<int> feature_diffs; | 373 std::set<int> feature_diffs; |
376 std::set_difference(blacklisted_features_.begin(), | 374 std::set_difference(blacklisted_features_.begin(), |
377 blacklisted_features_.end(), | 375 blacklisted_features_.end(), |
378 preliminary_blacklisted_features_.begin(), | 376 preliminary_blacklisted_features_.begin(), |
379 preliminary_blacklisted_features_.end(), | 377 preliminary_blacklisted_features_.end(), |
380 std::inserter(feature_diffs, feature_diffs.begin())); | 378 std::inserter(feature_diffs, feature_diffs.begin())); |
381 if (feature_diffs.size()) { | 379 if (feature_diffs.size()) { |
382 // TODO(zmo): Other features might also be OK to ignore here. | 380 // TODO(zmo): Other features might also be OK to ignore here. |
383 feature_diffs.erase(gpu::GPU_FEATURE_TYPE_WEBGL); | 381 feature_diffs.erase(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL); |
384 feature_diffs.erase(gpu::GPU_FEATURE_TYPE_WEBGL2); | 382 feature_diffs.erase(gpu::GPU_FEATURE_TYPE_WEBGL2); |
385 } | 383 } |
386 if (feature_diffs.size()) { | 384 if (feature_diffs.size()) { |
387 if (reason) { | 385 if (reason) { |
388 *reason = "Features are disabled on full but not preliminary GPU info."; | 386 *reason = "Features are disabled on full but not preliminary GPU info."; |
389 } | 387 } |
390 return false; | 388 return false; |
391 } | 389 } |
392 } | 390 } |
393 | 391 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 gpu_driver_bugs_.end()) { | 741 gpu_driver_bugs_.end()) { |
744 command_line->AppendSwitch(switches::kDisableES3GLContext); | 742 command_line->AppendSwitch(switches::kDisableES3GLContext); |
745 } | 743 } |
746 if (gpu_driver_bugs_.find(gpu::DISABLE_DIRECT_COMPOSITION) != | 744 if (gpu_driver_bugs_.find(gpu::DISABLE_DIRECT_COMPOSITION) != |
747 gpu_driver_bugs_.end()) { | 745 gpu_driver_bugs_.end()) { |
748 command_line->AppendSwitch(switches::kDisableDirectComposition); | 746 command_line->AppendSwitch(switches::kDisableDirectComposition); |
749 } | 747 } |
750 if (use_swiftshader_) { | 748 if (use_swiftshader_) { |
751 command_line->AppendSwitchASCII( | 749 command_line->AppendSwitchASCII( |
752 switches::kUseGL, gl::kGLImplementationSwiftShaderForWebGLName); | 750 switches::kUseGL, gl::kGLImplementationSwiftShaderForWebGLName); |
753 } else if ((IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL) || | 751 } else if ((IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL) || |
754 IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING) || | 752 IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING) || |
755 IsFeatureBlacklisted( | 753 IsFeatureBlacklisted( |
756 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) && | 754 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) && |
757 (use_gl == "any")) { | 755 (use_gl == "any")) { |
758 command_line->AppendSwitchASCII( | 756 command_line->AppendSwitchASCII( |
759 switches::kUseGL, | 757 switches::kUseGL, |
760 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation())); | 758 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation())); |
761 } else if (!use_gl.empty()) { | 759 } else if (!use_gl.empty()) { |
762 command_line->AppendSwitchASCII(switches::kUseGL, use_gl); | 760 command_line->AppendSwitchASCII(switches::kUseGL, use_gl); |
763 } | 761 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 command_line->AppendSwitchASCII( | 881 command_line->AppendSwitchASCII( |
884 switches::kGpuActiveDeviceID, | 882 switches::kGpuActiveDeviceID, |
885 base::StringPrintf("0x%04x", maybe_active_gpu_device.device_id)); | 883 base::StringPrintf("0x%04x", maybe_active_gpu_device.device_id)); |
886 } | 884 } |
887 } | 885 } |
888 | 886 |
889 void GpuDataManagerImplPrivate::UpdateRendererWebPrefs( | 887 void GpuDataManagerImplPrivate::UpdateRendererWebPrefs( |
890 WebPreferences* prefs) const { | 888 WebPreferences* prefs) const { |
891 DCHECK(prefs); | 889 DCHECK(prefs); |
892 | 890 |
893 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)) { | 891 if (!IsWebGLEnabled()) { |
894 prefs->experimental_webgl_enabled = false; | 892 prefs->experimental_webgl_enabled = false; |
895 prefs->pepper_3d_enabled = false; | 893 prefs->pepper_3d_enabled = false; |
896 } | 894 } |
897 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH3D)) | 895 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH3D)) |
898 prefs->flash_3d_enabled = false; | 896 prefs->flash_3d_enabled = false; |
899 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D)) { | 897 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D)) { |
900 prefs->flash_stage3d_enabled = false; | 898 prefs->flash_stage3d_enabled = false; |
901 prefs->flash_stage3d_baseline_enabled = false; | 899 prefs->flash_stage3d_baseline_enabled = false; |
902 } | 900 } |
903 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) | 901 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 } | 1219 } |
1222 | 1220 |
1223 void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures( | 1221 void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures( |
1224 const std::set<int>& features) { | 1222 const std::set<int>& features) { |
1225 blacklisted_features_ = features; | 1223 blacklisted_features_ = features; |
1226 | 1224 |
1227 // Force disable using the GPU for these features, even if they would | 1225 // Force disable using the GPU for these features, even if they would |
1228 // otherwise be allowed. | 1226 // otherwise be allowed. |
1229 if (card_blacklisted_) { | 1227 if (card_blacklisted_) { |
1230 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING); | 1228 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING); |
1231 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_WEBGL); | 1229 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL); |
| 1230 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_WEBGL2); |
1232 } | 1231 } |
1233 | 1232 |
1234 EnableSwiftShaderIfNecessary(); | 1233 EnableSwiftShaderIfNecessary(); |
1235 } | 1234 } |
1236 | 1235 |
1237 void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() { | 1236 void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() { |
1238 preliminary_blacklisted_features_ = blacklisted_features_; | 1237 preliminary_blacklisted_features_ = blacklisted_features_; |
1239 preliminary_blacklisted_features_initialized_ = true; | 1238 preliminary_blacklisted_features_initialized_ = true; |
1240 } | 1239 } |
1241 | 1240 |
1242 void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager( | 1241 void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager( |
1243 const gpu::GPUInfo& gpu_info) { | 1242 const gpu::GPUInfo& gpu_info) { |
1244 // The vendor IDs might be 0 on non-PCI devices (like Android), but | 1243 // The vendor IDs might be 0 on non-PCI devices (like Android), but |
1245 // the length of the vector is all we care about in most cases. | 1244 // the length of the vector is all we care about in most cases. |
1246 std::vector<uint32_t> vendor_ids; | 1245 std::vector<uint32_t> vendor_ids; |
1247 vendor_ids.push_back(gpu_info.gpu.vendor_id); | 1246 vendor_ids.push_back(gpu_info.gpu.vendor_id); |
1248 for (const auto& device : gpu_info.secondary_gpus) { | 1247 for (const auto& device : gpu_info.secondary_gpus) { |
1249 vendor_ids.push_back(device.vendor_id); | 1248 vendor_ids.push_back(device.vendor_id); |
1250 } | 1249 } |
1251 ui::GpuSwitchingManager::GetInstance()->SetGpuVendorIds(vendor_ids); | 1250 ui::GpuSwitchingManager::GetInstance()->SetGpuVendorIds(vendor_ids); |
1252 gpu::InitializeDualGpusIfSupported(gpu_driver_bugs_); | 1251 gpu::InitializeDualGpusIfSupported(gpu_driver_bugs_); |
1253 } | 1252 } |
1254 | 1253 |
1255 void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() { | 1254 void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() { |
1256 observer_list_->Notify(FROM_HERE, &GpuDataManagerObserver::OnGpuInfoUpdate); | 1255 observer_list_->Notify(FROM_HERE, &GpuDataManagerObserver::OnGpuInfoUpdate); |
1257 } | 1256 } |
1258 | 1257 |
1259 void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() { | 1258 void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() { |
1260 if (!GpuAccessAllowed(NULL) || | 1259 if (!GpuAccessAllowed(NULL) || |
1261 blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) { | 1260 blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)) { |
1262 if (!swiftshader_path_.empty() && | 1261 if (!swiftshader_path_.empty() && |
1263 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1262 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
1264 switches::kDisableSoftwareRasterizer)) | 1263 switches::kDisableSoftwareRasterizer)) |
1265 use_swiftshader_ = true; | 1264 use_swiftshader_ = true; |
1266 } | 1265 } |
1267 } | 1266 } |
1268 | 1267 |
1269 std::string GpuDataManagerImplPrivate::GetDomainFromURL( | 1268 std::string GpuDataManagerImplPrivate::GetDomainFromURL( |
1270 const GURL& url) const { | 1269 const GURL& url) const { |
1271 // For the moment, we just use the host, or its IP address, as the | 1270 // For the moment, we just use the host, or its IP address, as the |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; | 1371 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
1373 #if defined(OS_WIN) | 1372 #if defined(OS_WIN) |
1374 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | 1373 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; |
1375 #endif | 1374 #endif |
1376 complete_gpu_info_already_requested_ = true; | 1375 complete_gpu_info_already_requested_ = true; |
1377 // Some observers might be waiting. | 1376 // Some observers might be waiting. |
1378 NotifyGpuInfoUpdate(); | 1377 NotifyGpuInfoUpdate(); |
1379 } | 1378 } |
1380 | 1379 |
1381 } // namespace content | 1380 } // namespace content |
OLD | NEW |