1a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// found in the LICENSE file. 4a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 5a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/browser/gpu/gpu_data_manager_impl_private.h" 6a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 7a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/bind.h" 8a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/bind_helpers.h" 9a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/command_line.h" 10a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/debug/trace_event.h" 11a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/metrics/field_trial.h" 12a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/metrics/histogram.h" 133240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch#include "base/metrics/sparse_histogram.h" 14a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/strings/string_number_conversions.h" 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/stringprintf.h" 16a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/sys_info.h" 17a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/version.h" 1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "cc/base/switches.h" 19a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/browser/gpu/gpu_process_host.h" 20a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/common/gpu/gpu_messages.h" 21a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/public/browser/browser_thread.h" 22a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/public/browser/gpu_data_manager_observer.h" 23a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/public/common/content_client.h" 24a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/public/common/content_constants.h" 25a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/public/common/content_switches.h" 26116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "content/public/common/web_preferences.h" 27a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "gpu/command_buffer/service/gpu_switches.h" 2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "gpu/config/gpu_control_list_jsons.h" 29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "gpu/config/gpu_driver_bug_workaround_type.h" 3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "gpu/config/gpu_feature_type.h" 3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "gpu/config/gpu_info_collector.h" 3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "gpu/config/gpu_util.h" 33a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "ui/base/ui_base_switches.h" 34a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "ui/gl/gl_implementation.h" 35a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "ui/gl/gl_switches.h" 36a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "ui/gl/gpu_switching_manager.h" 37a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 3890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_MACOSX) 3990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include <ApplicationServices/ApplicationServices.h> 4090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // OS_MACOSX 41a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_WIN) 42a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/win/windows_version.h" 4390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // OS_WIN 4490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_ANDROID) 4590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ui/gfx/android/device_display_info.h" 4690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // OS_ANDROID 47a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 48a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)namespace content { 4990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 50a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)namespace { 51a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 5290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)enum GpuFeatureStatus { 5390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kGpuFeatureEnabled = 0, 5490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kGpuFeatureBlacklisted = 1, 5590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kGpuFeatureDisabled = 2, // disabled by user but not blacklisted 5690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kGpuFeatureNumStatus 5790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}; 5890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 5990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_WIN) 6090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 6190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)enum WinSubVersion { 6290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kWinOthers = 0, 6390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kWinXP, 6490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kWinVista, 6590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kWin7, 667dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch kWin8, 6790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kNumWinSubVersions 6890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}; 6990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 7090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)int GetGpuBlacklistHistogramValueWin(GpuFeatureStatus status) { 7190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) static WinSubVersion sub_version = kNumWinSubVersions; 7290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (sub_version == kNumWinSubVersions) { 7390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) sub_version = kWinOthers; 7490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::string version_str = base::SysInfo::OperatingSystemVersion(); 7590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) size_t pos = version_str.find_first_not_of("0123456789."); 7690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (pos != std::string::npos) 7790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) version_str = version_str.substr(0, pos); 7890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) Version os_version(version_str); 7990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (os_version.IsValid() && os_version.components().size() >= 2) { 8090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const std::vector<uint16>& version_numbers = os_version.components(); 8190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (version_numbers[0] == 5) 8290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) sub_version = kWinXP; 8390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) else if (version_numbers[0] == 6 && version_numbers[1] == 0) 8490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) sub_version = kWinVista; 8590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) else if (version_numbers[0] == 6 && version_numbers[1] == 1) 8690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) sub_version = kWin7; 877dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch else if (version_numbers[0] == 6 && version_numbers[1] == 2) 887dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch sub_version = kWin8; 8990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 9090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 9190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int entry_index = static_cast<int>(sub_version) * kGpuFeatureNumStatus; 9290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) switch (status) { 9390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case kGpuFeatureEnabled: 9490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) break; 9590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case kGpuFeatureBlacklisted: 9690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) entry_index++; 9790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) break; 9890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case kGpuFeatureDisabled: 9990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) entry_index += 2; 10090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) break; 10190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 10290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return entry_index; 10390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 10490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // OS_WIN 10590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1063240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch// Send UMA histograms about the enabled features and GPU properties. 1073240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdochvoid UpdateStats(const gpu::GPUInfo& gpu_info, 1083240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch const gpu::GpuBlacklist* blacklist, 10990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const std::set<int>& blacklisted_features) { 11090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) uint32 max_entry_id = blacklist->max_entry_id(); 11190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (max_entry_id == 0) { 11290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // GPU Blacklist was not loaded. No need to go further. 11390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return; 11490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 11590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const base::CommandLine& command_line = 1176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) *base::CommandLine::ForCurrentProcess(); 11890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool disabled = false; 1197dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 1207dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // Use entry 0 to capture the total number of times that data 1217dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // was recorded in this histogram in order to have a convenient 1227dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // denominator to compute blacklist percentages for the rest of the 1237dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // entries. 1247dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", 1257dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 0, max_entry_id + 1); 1267dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 1277dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch if (blacklisted_features.size() != 0) { 12890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::vector<uint32> flag_entries; 12990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) blacklist->GetDecisionEntries(&flag_entries, disabled); 13090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) DCHECK_GT(flag_entries.size(), 0u); 13190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) for (size_t i = 0; i < flag_entries.size(); ++i) { 13290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", 13390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) flag_entries[i], max_entry_id + 1); 13490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 13590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 13690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 13790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // This counts how many users are affected by a disabled entry - this allows 13890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // us to understand the impact of an entry before enable it. 13990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::vector<uint32> flag_disabled_entries; 14090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) disabled = true; 14190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) blacklist->GetDecisionEntries(&flag_disabled_entries, disabled); 1425f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) for (uint32 disabled_entry : flag_disabled_entries) { 14390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerDisabledEntry", 1445f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) disabled_entry, max_entry_id + 1); 14590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 14690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 14790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const gpu::GpuFeatureType kGpuFeatures[] = { 14890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, 1490529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING, gpu::GPU_FEATURE_TYPE_WEBGL}; 15090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const std::string kGpuBlacklistFeatureHistogramNames[] = { 15190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) "GPU.BlacklistFeatureTestResults.Accelerated2dCanvas", 1520529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch "GPU.BlacklistFeatureTestResults.GpuCompositing", 1530529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch "GPU.BlacklistFeatureTestResults.Webgl", }; 15490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const bool kGpuFeatureUserFlags[] = { 15590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) command_line.HasSwitch(switches::kDisableAccelerated2dCanvas), 1560529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch command_line.HasSwitch(switches::kDisableGpu), 1570529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch command_line.HasSwitch(switches::kDisableExperimentalWebGL), }; 15890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_WIN) 15990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const std::string kGpuBlacklistFeatureHistogramNamesWin[] = { 16090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) "GPU.BlacklistFeatureTestResultsWindows.Accelerated2dCanvas", 1610529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch "GPU.BlacklistFeatureTestResultsWindows.GpuCompositing", 1620529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch "GPU.BlacklistFeatureTestResultsWindows.Webgl", }; 16390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif 16490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const size_t kNumFeatures = 16590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) sizeof(kGpuFeatures) / sizeof(gpu::GpuFeatureType); 16690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) for (size_t i = 0; i < kNumFeatures; ++i) { 16790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // We can't use UMA_HISTOGRAM_ENUMERATION here because the same name is 16890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // expected if the macro is used within a loop. 16990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) GpuFeatureStatus value = kGpuFeatureEnabled; 17090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (blacklisted_features.count(kGpuFeatures[i])) 17190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) value = kGpuFeatureBlacklisted; 17290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) else if (kGpuFeatureUserFlags[i]) 17390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) value = kGpuFeatureDisabled; 17490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) base::HistogramBase* histogram_pointer = base::LinearHistogram::FactoryGet( 17590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kGpuBlacklistFeatureHistogramNames[i], 17690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1, kGpuFeatureNumStatus, kGpuFeatureNumStatus + 1, 17790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) base::HistogramBase::kUmaTargetedHistogramFlag); 17890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) histogram_pointer->Add(value); 17990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_WIN) 18090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) histogram_pointer = base::LinearHistogram::FactoryGet( 18190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kGpuBlacklistFeatureHistogramNamesWin[i], 18290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1, kNumWinSubVersions * kGpuFeatureNumStatus, 18390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kNumWinSubVersions * kGpuFeatureNumStatus + 1, 18490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) base::HistogramBase::kUmaTargetedHistogramFlag); 18590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); 18690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif 18790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 1883240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch 1893240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.GLResetNotificationStrategy", 1903240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch gpu_info.gl_reset_notification_strategy); 19190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 19290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 193a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Combine the integers into a string, seperated by ','. 194a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)std::string IntSetToString(const std::set<int>& list) { 195a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string rt; 196a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) for (std::set<int>::const_iterator it = list.begin(); 197a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) it != list.end(); ++it) { 198a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!rt.empty()) 199a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) rt += ","; 200a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) rt += base::IntToString(*it); 201a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 202a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return rt; 203a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 204a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 205a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_MACOSX) 206a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void DisplayReconfigCallback(CGDirectDisplayID display, 207a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CGDisplayChangeSummaryFlags flags, 208a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) void* gpu_data_manager) { 209424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) if (flags == kCGDisplayBeginConfigurationFlag) 210868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return; // This call contains no information about the display change 211868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 212868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) GpuDataManagerImpl* manager = 213868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); 214868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) DCHECK(manager); 215868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 2160529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Display change. 2170529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch bool display_changed = false; 218868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) uint32_t displayCount; 219868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) CGGetActiveDisplayList(0, NULL, &displayCount); 220868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if (displayCount != manager->GetDisplayCount()) { 221868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) manager->SetDisplayCount(displayCount); 2220529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch display_changed = true; 2230529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch } 2240529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 2250529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // Gpu change. 2260529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch bool gpu_changed = false; 2270529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch if (flags & kCGDisplayAddFlag) { 2280529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch uint32 vendor_id, device_id; 2291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (gpu::CollectGpuID(&vendor_id, &device_id) == gpu::kCollectInfoSuccess) { 2300529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gpu_changed = manager->UpdateActiveGpu(vendor_id, device_id); 2310529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch } 232a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 233868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 2340529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch if (display_changed || gpu_changed) 235868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) manager->HandleGpuSwitch(); 236a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 237a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif // OS_MACOSX 238a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 239a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Block all domains' use of 3D APIs for this many milliseconds if 240a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// approaching a threshold where system stability might be compromised. 241a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)const int64 kBlockAllDomainsMs = 10000; 242a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)const int kNumResetsWithinDuration = 1; 243a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 244a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Enums for UMA histograms. 245a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)enum BlockStatusHistogram { 246a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_NOT_BLOCKED, 247a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, 248a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_ALL_DOMAINS_BLOCKED, 249a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_MAX 250a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)}; 251a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 252a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} // namespace anonymous 253a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 254a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::InitializeForTesting( 255a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::string& gpu_blacklist_json, 25690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const gpu::GPUInfo& gpu_info) { 257a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // This function is for testing only, so disable histograms. 258a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) update_histograms_ = false; 259a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 2604e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // Prevent all further initialization. 2614e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) finalized_ = true; 2624e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 263f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) InitializeImpl(gpu_blacklist_json, std::string(), gpu_info); 264a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 265a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 266a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { 2673551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#if defined(OS_CHROMEOS) 2683551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && 2696e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::CommandLine::ForCurrentProcess()->HasSwitch( 2703551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) switches::kDisablePanelFitting)) { 2713551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) return true; 2723551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) } 2733551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#endif // OS_CHROMEOS 2741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (use_swiftshader_ || ShouldUseWarp()) { 275a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Skia's software rendering is probably more efficient than going through 276a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // software emulation of the GPU, so use that. 27790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) 278a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return true; 279a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 280a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 281a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 282a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return (blacklisted_features_.count(feature) == 1); 283a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 284a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 285424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { 286424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) return (gpu_driver_bugs_.count(feature) == 1); 287424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)} 288424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 289a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { 2901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (use_swiftshader_ || ShouldUseWarp()) 291a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return 1; 292a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return blacklisted_features_.size(); 293a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 294a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 295868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void GpuDataManagerImplPrivate::SetDisplayCount(unsigned int display_count) { 296868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) display_count_ = display_count; 297868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 298868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 299868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)unsigned int GpuDataManagerImplPrivate::GetDisplayCount() const { 300868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return display_count_; 301868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 302868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 30390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { 304a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return gpu_info_; 305a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 306a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 307a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::GetGpuProcessHandles( 308a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { 309a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::GetProcessHandles(callback); 310a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 311a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 312a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)bool GpuDataManagerImplPrivate::GpuAccessAllowed( 313a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string* reason) const { 3141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (use_swiftshader_ || ShouldUseWarp()) 315a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return true; 316a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 317eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (!gpu_process_accessible_) { 318a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (reason) { 319a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *reason = "GPU process launch failed."; 320a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 321a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 322a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 323a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 324a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (card_blacklisted_) { 325a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (reason) { 326a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *reason = "GPU access is disabled "; 3276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 328a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (command_line->HasSwitch(switches::kDisableGpu)) 329a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *reason += "through commandline switch --disable-gpu."; 330a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) else 331a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *reason += "in chrome://settings."; 332a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 333a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 334a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 335a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 336a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // We only need to block GPU process if more features are disallowed other 337a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // than those in the preliminary gpu feature flags because the latter work 338a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // through renderer commandline switches. 339a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::set<int> features = preliminary_blacklisted_features_; 34090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::MergeFeatureSets(&features, blacklisted_features_); 341a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (features.size() > preliminary_blacklisted_features_.size()) { 342a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (reason) { 343a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *reason = "Features are disabled upon full but not preliminary GPU info."; 344a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 345a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 346a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 347a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 34890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (blacklisted_features_.size() == gpu::NUMBER_OF_GPU_FEATURE_TYPES) { 349a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // On Linux, we use cached GL strings to make blacklist decsions at browser 350a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // startup time. We need to launch the GPU process to validate these 351a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // strings even if all features are blacklisted. If all GPU features are 352a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // disabled, the GPU process will only initialize GL bindings, create a GL 353a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // context, and collect full GPU info. 354a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if !defined(OS_LINUX) 355a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (reason) { 356a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *reason = "All GPU features are blacklisted."; 357a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 358a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 359a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 360a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 361a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 362a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return true; 363a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 364a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 365a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::RequestCompleteGpuInfoIfNeeded() { 3661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (complete_gpu_info_already_requested_ || IsCompleteGpuInfoAvailable()) 367a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 368a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) complete_gpu_info_already_requested_ = true; 369a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 370a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::SendOnIO( 371a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_WIN) 372a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, 373a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#else 374a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, 375a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 376a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDED, 377a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) new GpuMsg_CollectGraphicsInfo()); 378a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 379a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 3801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccibool GpuDataManagerImplPrivate::IsEssentialGpuInfoAvailable() const { 3811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (gpu_info_.basic_info_state == gpu::kCollectInfoNone || 3821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci gpu_info_.context_info_state == gpu::kCollectInfoNone) { 3831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return false; 3841320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 3851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return true; 3861320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 3871320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 388a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)bool GpuDataManagerImplPrivate::IsCompleteGpuInfoAvailable() const { 3891320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#if defined(OS_WIN) 3901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (gpu_info_.dx_diagnostics_info_state == gpu::kCollectInfoNone) 3911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return false; 3921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif 3931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return IsEssentialGpuInfoAvailable(); 394a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 395a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 396a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { 397a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::SendOnIO( 398a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, 399a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, 400a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) new GpuMsg_GetVideoMemoryUsageStats()); 401a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 402a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 403a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { 404a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return use_swiftshader_; 405a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 406a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 407a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::RegisterSwiftShaderPath( 408a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const base::FilePath& path) { 409a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) swiftshader_path_ = path; 410a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EnableSwiftShaderIfNecessary(); 411a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 412a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 4131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccibool GpuDataManagerImplPrivate::ShouldUseWarp() const { 4141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return use_warp_ || 4151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseWarp); 4161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 4171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 418a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::AddObserver(GpuDataManagerObserver* observer) { 419a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::UnlockedSession session(owner_); 420a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->AddObserver(observer); 421a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 422a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 423a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::RemoveObserver( 424a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerObserver* observer) { 425a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::UnlockedSession session(owner_); 426a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->RemoveObserver(observer); 427a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 428a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 429a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::UnblockDomainFrom3DAPIs(const GURL& url) { 430a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // This method must do two things: 431a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // 432a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // 1. If the specific domain is blocked, then unblock it. 433a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // 434a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // 2. Reset our notion of how many GPU resets have occurred recently. 435a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // This is necessary even if the specific domain was blocked. 436a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Otherwise, if we call Are3DAPIsBlocked with the same domain right 437a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // after unblocking it, it will probably still be blocked because of 438a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // the recent GPU reset caused by that domain. 439a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // 440a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // These policies could be refined, but at a certain point the behavior 441a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // will become difficult to explain. 442a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string domain = GetDomainFromURL(url); 443a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 444a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) blocked_domains_.erase(domain); 445a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) timestamps_of_gpu_resets_.clear(); 446a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 447a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 448a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::DisableGpuWatchdog() { 449a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::SendOnIO( 450a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, 451a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, 452a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) new GpuMsg_DisableWatchdog); 453a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 454a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 455a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::SetGLStrings(const std::string& gl_vendor, 456a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::string& gl_renderer, 457a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::string& gl_version) { 458a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (gl_vendor.empty() && gl_renderer.empty() && gl_version.empty()) 459a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 460a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 461a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // If GPUInfo already got GL strings, do nothing. This is for the rare 462a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // situation where GPU process collected GL strings before this call. 463a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!gpu_info_.gl_vendor.empty() || 464a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) !gpu_info_.gl_renderer.empty() || 465010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) !gpu_info_.gl_version.empty()) 466a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 467a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 46890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GPUInfo gpu_info = gpu_info_; 469a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 470a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info.gl_vendor = gl_vendor; 471a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info.gl_renderer = gl_renderer; 472010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) gpu_info.gl_version = gl_version; 473a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 47490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::CollectDriverInfoGL(&gpu_info); 475a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 476a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdateGpuInfo(gpu_info); 477a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdateGpuSwitchingManager(gpu_info); 478a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdatePreliminaryBlacklistedFeatures(); 479a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 480a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 481a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::GetGLStrings(std::string* gl_vendor, 482a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string* gl_renderer, 483a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string* gl_version) { 484a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(gl_vendor && gl_renderer && gl_version); 485a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 486a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *gl_vendor = gpu_info_.gl_vendor; 487a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *gl_renderer = gpu_info_.gl_renderer; 488010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) *gl_version = gpu_info_.gl_version; 489a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 490a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 491a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::Initialize() { 492a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize"); 4934e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) if (finalized_) { 494f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) DVLOG(0) << "GpuDataManagerImpl marked as finalized; skipping Initialize"; 4954e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) return; 4964e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) } 4974e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 4986e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const base::CommandLine* command_line = 4996e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::CommandLine::ForCurrentProcess(); 5004e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) 501a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 502a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 50390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GPUInfo gpu_info; 5044e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) if (command_line->GetSwitchValueASCII( 5054e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) switches::kUseGL) == gfx::kGLImplementationOSMesaName) { 5064e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // If using the OSMesa GL implementation, use fake vendor and device ids to 5074e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // make sure it never gets blacklisted. This is better than simply 5084e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // cancelling GPUInfo gathering as it allows us to proceed with loading the 5094e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // blacklist below which may have non-device specific entries we want to 5104e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // apply anyways (e.g., OS version blacklisting). 5114e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gpu_info.gpu.vendor_id = 0xffff; 5124e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gpu_info.gpu.device_id = 0xffff; 5134e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 5144e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // Also declare the driver_vendor to be osmesa to be able to specify 5154e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // exceptions based on driver_vendor==osmesa for some blacklist rules. 5164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gpu_info.driver_vendor = gfx::kGLImplementationOSMesaName; 5174e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) } else { 518a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) TRACE_EVENT0("startup", 519a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); 52090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::CollectBasicGraphicsInfo(&gpu_info); 521a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 522a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(ARCH_CPU_X86_FAMILY) 5231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) { 5241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci gpu_info.context_info_state = gpu::kCollectInfoNonFatalFailure; 5251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#if defined(OS_WIN) 5261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci gpu_info.dx_diagnostics_info_state = gpu::kCollectInfoNonFatalFailure; 5271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif // OS_WIN 5281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 5291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif // ARCH_CPU_X86_FAMILY 530a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 531a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string gpu_blacklist_string; 532a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string gpu_driver_bug_list_string; 5337dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist) && 5347dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch !command_line->HasSwitch(switches::kUseGpuInTests)) { 53590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_blacklist_string = gpu::kSoftwareRenderingListJson; 536a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 537a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { 53890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_driver_bug_list_string = gpu::kGpuDriverBugListJson; 539a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 540a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) InitializeImpl(gpu_blacklist_string, 541a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_driver_bug_list_string, 542a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info); 543a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 544a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 545e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochvoid GpuDataManagerImplPrivate::UpdateGpuInfoHelper() { 546a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GetContentClient()->SetGpuInfo(gpu_info_); 547a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 548a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (gpu_blacklist_) { 549a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::set<int> features = gpu_blacklist_->MakeDecision( 55090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GpuControlList::kOsAny, std::string(), gpu_info_); 551a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (update_histograms_) 5523240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch UpdateStats(gpu_info_, gpu_blacklist_.get(), features); 553a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 554a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdateBlacklistedFeatures(features); 555a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 556e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch if (gpu_driver_bug_list_) { 557a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_driver_bugs_ = gpu_driver_bug_list_->MakeDecision( 55890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GpuControlList::kOsAny, std::string(), gpu_info_); 55990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 560e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch gpu::GpuDriverBugList::AppendWorkaroundsFromCommandLine( 5616e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) &gpu_driver_bugs_, *base::CommandLine::ForCurrentProcess()); 562a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 563a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // We have to update GpuFeatureType before notify all the observers. 564a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) NotifyGpuInfoUpdate(); 565a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 566a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 567e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochvoid GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { 568e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch // No further update of gpu_info if falling back to SwiftShader. 5691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (use_swiftshader_ || ShouldUseWarp()) 570e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch return; 571e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 572e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch gpu::MergeGPUInfo(&gpu_info_, gpu_info); 5731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (IsCompleteGpuInfoAvailable()) 5741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci complete_gpu_info_already_requested_ = true; 575e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 576e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch UpdateGpuInfoHelper(); 577e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch} 578e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 579a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats( 580a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const GPUVideoMemoryUsageStats& video_memory_usage_stats) { 581a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::UnlockedSession session(owner_); 582a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, 583a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) video_memory_usage_stats); 584a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 585a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 586a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::AppendRendererCommandLine( 5876e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::CommandLine* command_line) const { 588a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(command_line); 589a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 59090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) && 591a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) 592a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); 593a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#if defined(ENABLE_WEBRTC) 594a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE) && 595a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) !command_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) 596a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) command_line->AppendSwitch(switches::kDisableWebRtcHWEncoding); 597a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#endif 598a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 599a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#if defined(USE_AURA) 6005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!CanUseGpuBrowserCompositor()) 601a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) command_line->AppendSwitch(switches::kDisableGpuCompositing); 602a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#endif 603a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 604a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 605a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::AppendGpuCommandLine( 6066e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::CommandLine* command_line) const { 607a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(command_line); 608a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 609a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string use_gl = 6106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 6116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) switches::kUseGL); 612a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::FilePath swiftshader_path = 6136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( 614a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kSwiftShaderPath); 6157dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch if (gpu_driver_bugs_.find(gpu::DISABLE_D3D11) != gpu_driver_bugs_.end()) 6167dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch command_line->AppendSwitch(switches::kDisableD3D11); 617a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (use_swiftshader_) { 618a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kUseGL, "swiftshader"); 619a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (swiftshader_path.empty()) 620a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) swiftshader_path = swiftshader_path_; 62190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } else if ((IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL) || 6220529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING) || 62390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) IsFeatureBlacklisted( 62490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) && 6250529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch (use_gl == "any")) { 626a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII( 627a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kUseGL, gfx::kGLImplementationOSMesaName); 628a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } else if (!use_gl.empty()) { 629a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kUseGL, use_gl); 630a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 631f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) 632a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "true"); 633f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) else 634a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false"); 635a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 6367d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) if (!swiftshader_path.empty()) { 637a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchPath(switches::kSwiftShaderPath, 638a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) swiftshader_path); 6397d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) } 640a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 641a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!gpu_driver_bugs_.empty()) { 642a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds, 643a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) IntSetToString(gpu_driver_bugs_)); 644a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 645a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 6463551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) && 6473551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { 6483551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); 6493551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) } 650a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#if defined(ENABLE_WEBRTC) 651a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE) && 652a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) !command_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) { 653a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) command_line->AppendSwitch(switches::kDisableWebRtcHWEncoding); 654a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 655a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#endif 6563551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 657a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Pass GPU and driver information to GPU process. We try to avoid full GPU 658a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // info collection at GPU process startup, but we need gpu vendor_id, 659a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // device_id, driver_vendor, driver_version for deciding whether we need to 660a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // collect full info (on Linux) and for crash reporting purpose. 661a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuVendorID, 662a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::StringPrintf("0x%04x", gpu_info_.gpu.vendor_id)); 663a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuDeviceID, 664a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::StringPrintf("0x%04x", gpu_info_.gpu.device_id)); 665a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuDriverVendor, 666a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info_.driver_vendor); 667a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuDriverVersion, 668a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info_.driver_version); 6691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 6701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (ShouldUseWarp()) 6711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci command_line->AppendSwitch(switches::kUseWarp); 672a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 673a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 674a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::AppendPluginCommandLine( 6756e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::CommandLine* command_line) const { 676a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(command_line); 677a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 678a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_MACOSX) 679a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // TODO(jbauman): Add proper blacklist support for core animation plugins so 680a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // special-casing this video card won't be necessary. See 681a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // http://crbug.com/134015 6820529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) { 683a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!command_line->HasSwitch( 684a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kDisableCoreAnimationPlugins)) 685a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch( 686a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kDisableCoreAnimationPlugins); 687a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 688a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 689a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 690a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 691a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::UpdateRendererWebPrefs( 692a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) WebPreferences* prefs) const { 693a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(prefs); 694a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 6955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)) { 696a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->experimental_webgl_enabled = false; 6975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs->pepper_3d_enabled = false; 6985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 69990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH3D)) 700a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->flash_3d_enabled = false; 70190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D)) { 702a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->flash_stage3d_enabled = false; 703a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->flash_stage3d_baseline_enabled = false; 704a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 70590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) 706a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->flash_stage3d_baseline_enabled = false; 70790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) 708a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->accelerated_2d_canvas_enabled = false; 7095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (IsDriverBugWorkaroundActive(gpu::DISABLE_MULTISAMPLING) || 710424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) (IsDriverBugWorkaroundActive(gpu::DISABLE_MULTIMONITOR_MULTISAMPLING) && 711424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) display_count_ > 1)) 712a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->gl_multisampling_enabled = false; 713a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 714a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#if defined(USE_AURA) 7155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!CanUseGpuBrowserCompositor()) { 716a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) prefs->accelerated_2d_canvas_enabled = false; 7175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs->pepper_3d_enabled = false; 7185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 719a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#endif 720a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 721a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) && 7226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) !base::CommandLine::ForCurrentProcess()->HasSwitch( 723a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) switches::kDisableAcceleratedVideoDecode)) { 724a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) prefs->pepper_accelerated_video_decode_enabled = true; 725a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 726a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 727a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 728a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::DisableHardwareAcceleration() { 729a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) card_blacklisted_ = true; 730a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 73190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) for (int i = 0; i < gpu::NUMBER_OF_GPU_FEATURE_TYPES; ++i) 732a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) blacklisted_features_.insert(i); 733a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 7341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci EnableWarpIfNecessary(); 735a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EnableSwiftShaderIfNecessary(); 736a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) NotifyGpuInfoUpdate(); 737a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 738a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 739a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)std::string GpuDataManagerImplPrivate::GetBlacklistVersion() const { 740a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (gpu_blacklist_) 741a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return gpu_blacklist_->version(); 742a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return "0"; 743a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 744a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 745868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)std::string GpuDataManagerImplPrivate::GetDriverBugListVersion() const { 746868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if (gpu_driver_bug_list_) 747868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return gpu_driver_bug_list_->version(); 748868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return "0"; 749868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 750868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 751868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void GpuDataManagerImplPrivate::GetBlacklistReasons( 752868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::ListValue* reasons) const { 753a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (gpu_blacklist_) 754a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) gpu_blacklist_->GetReasons(reasons, "disabledFeatures"); 755a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (gpu_driver_bug_list_) 756a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) gpu_driver_bug_list_->GetReasons(reasons, "workarounds"); 757868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 758868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 759868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void GpuDataManagerImplPrivate::GetDriverBugWorkarounds( 760868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::ListValue* workarounds) const { 761868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) for (std::set<int>::const_iterator it = gpu_driver_bugs_.begin(); 762868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) it != gpu_driver_bugs_.end(); ++it) { 763868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) workarounds->AppendString( 764868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) gpu::GpuDriverBugWorkaroundTypeToString( 765868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) static_cast<gpu::GpuDriverBugWorkaroundType>(*it))); 766868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } 767a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 768a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 769a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::AddLogMessage( 770a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int level, const std::string& header, const std::string& message) { 7715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) log_messages_.push_back(LogMessage(level, header, message)); 772a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 773a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 774a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::ProcessCrashed( 775a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::TerminationStatus exit_code) { 776a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 777a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Unretained is ok, because it's posted to UI thread, the thread 778a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // where the singleton GpuDataManagerImpl lives until the end. 779a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BrowserThread::PostTask( 780a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BrowserThread::UI, 781a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) FROM_HERE, 782a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::Bind(&GpuDataManagerImpl::ProcessCrashed, 783a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::Unretained(owner_), 784a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) exit_code)); 785a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 786a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 787a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) { 7885f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) gpu_info_.process_crash_count = GpuProcessHost::gpu_crash_count(); 789a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::UnlockedSession session(owner_); 790a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->Notify( 791a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) &GpuDataManagerObserver::OnGpuProcessCrashed, exit_code); 792a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 793a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 794a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 795a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)base::ListValue* GpuDataManagerImplPrivate::GetLogMessages() const { 7965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::ListValue* value = new base::ListValue; 7975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) for (size_t ii = 0; ii < log_messages_.size(); ++ii) { 7985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::DictionaryValue* dict = new base::DictionaryValue(); 7995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) dict->SetInteger("level", log_messages_[ii].level); 8005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) dict->SetString("header", log_messages_[ii].header); 8015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) dict->SetString("message", log_messages_[ii].message); 8025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) value->Append(dict); 8035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 804a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return value; 805a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 806a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 807a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::HandleGpuSwitch() { 8080529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch GpuDataManagerImpl::UnlockedSession session(owner_); 8090529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch observer_list_->Notify(&GpuDataManagerObserver::OnGpuSwitching); 8100529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch} 8110529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 8120529e5d033099cbfc42635f6f6183833b09dff6eBen Murdochbool GpuDataManagerImplPrivate::UpdateActiveGpu( 8130529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch uint32 vendor_id, uint32 device_id) { 8140529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch if (gpu_info_.gpu.vendor_id == vendor_id && 8150529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gpu_info_.gpu.device_id == device_id) { 8160529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // The primary GPU is active. 817e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch if (gpu_info_.gpu.active) 8180529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch return false; 8190529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gpu_info_.gpu.active = true; 8200529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch for (size_t ii = 0; ii < gpu_info_.secondary_gpus.size(); ++ii) 8210529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gpu_info_.secondary_gpus[ii].active = false; 8220529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch } else { 8230529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch // A secondary GPU is active. 824e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch for (size_t ii = 0; ii < gpu_info_.secondary_gpus.size(); ++ii) { 8250529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch if (gpu_info_.secondary_gpus[ii].vendor_id == vendor_id && 8260529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gpu_info_.secondary_gpus[ii].device_id == device_id) { 8270529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch if (gpu_info_.secondary_gpus[ii].active) 8280529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch return false; 8290529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gpu_info_.secondary_gpus[ii].active = true; 8300529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch } else { 8310529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gpu_info_.secondary_gpus[ii].active = false; 8320529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch } 833e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch } 8340529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch gpu_info_.gpu.active = false; 835e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch } 8360529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch UpdateGpuInfoHelper(); 8370529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch return true; 838a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 839a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 8407dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdochbool GpuDataManagerImplPrivate::CanUseGpuBrowserCompositor() const { 8411320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (CommandLine::ForCurrentProcess()->HasSwitch( 8421320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci switches::kDisableGpuCompositing)) 8431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return false; 8441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (ShouldUseWarp()) 8451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return true; 8460529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch if (ShouldUseSwiftShader()) 8470529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch return false; 8480529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) 8490529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch return false; 8500529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch return true; 8517dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch} 8527dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 853a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIs( 854a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const GURL& url, GpuDataManagerImpl::DomainGuilt guilt) { 855a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BlockDomainFrom3DAPIsAtTime(url, guilt, base::Time::Now()); 856a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 857a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 858a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)bool GpuDataManagerImplPrivate::Are3DAPIsBlocked(const GURL& url, 859a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int render_process_id, 860a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int render_view_id, 861a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ThreeDAPIType requester) { 862a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) bool blocked = Are3DAPIsBlockedAtTime(url, base::Time::Now()) != 863a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_NOT_BLOCKED; 864a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (blocked) { 865a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Unretained is ok, because it's posted to UI thread, the thread 866a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // where the singleton GpuDataManagerImpl lives until the end. 867a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BrowserThread::PostTask( 868a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BrowserThread::UI, FROM_HERE, 869a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::Bind(&GpuDataManagerImpl::Notify3DAPIBlocked, 870a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::Unretained(owner_), url, render_process_id, 871a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) render_view_id, requester)); 872a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 873a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 874a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return blocked; 875a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 876a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 877a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::DisableDomainBlockingFor3DAPIsForTesting() { 878a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) domain_blocking_enabled_ = false; 879a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 880a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 881a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// static 882a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)GpuDataManagerImplPrivate* GpuDataManagerImplPrivate::Create( 883a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl* owner) { 884a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return new GpuDataManagerImplPrivate(owner); 885a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 886a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 887a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)GpuDataManagerImplPrivate::GpuDataManagerImplPrivate( 888a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl* owner) 889a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) : complete_gpu_info_already_requested_(false), 890a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_(new GpuDataManagerObserverList), 891a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) use_swiftshader_(false), 8921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci use_warp_(false), 893a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) card_blacklisted_(false), 894a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) update_histograms_(true), 895a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) window_count_(0), 896a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) domain_blocking_enabled_(true), 897868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) owner_(owner), 898eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch display_count_(0), 899a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) gpu_process_accessible_(true), 9004e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) finalized_(false) { 901a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(owner_); 9026e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) const base::CommandLine* command_line = 9036e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::CommandLine::ForCurrentProcess(); 904a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (command_line->HasSwitch(switches::kDisableGpu)) 905a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DisableHardwareAcceleration(); 906a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 907a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_MACOSX) 908868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) CGGetActiveDisplayList (0, NULL, &display_count_); 909a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); 910a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif // OS_MACOSX 9118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 9128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // For testing only. 9138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) if (command_line->HasSwitch(switches::kDisableDomainBlockingFor3DAPIs)) { 9148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) domain_blocking_enabled_ = false; 9158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 916a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 917a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 918a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)GpuDataManagerImplPrivate::~GpuDataManagerImplPrivate() { 919a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_MACOSX) 920a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, owner_); 921a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 922a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 923a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 924a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::InitializeImpl( 925a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::string& gpu_blacklist_json, 926a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::string& gpu_driver_bug_list_json, 92790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const gpu::GPUInfo& gpu_info) { 9284e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) const bool log_gpu_control_list_decisions = 9296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::CommandLine::ForCurrentProcess()->HasSwitch( 9304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) switches::kLogGpuControlListDecisions); 9314e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 932a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!gpu_blacklist_json.empty()) { 93390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_blacklist_.reset(gpu::GpuBlacklist::Create()); 9344e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) if (log_gpu_control_list_decisions) 9354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gpu_blacklist_->enable_control_list_logging("gpu_blacklist"); 9364e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) bool success = gpu_blacklist_->LoadList( 937a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) gpu_blacklist_json, gpu::GpuControlList::kCurrentOsOnly); 9384e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) DCHECK(success); 939a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 940a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!gpu_driver_bug_list_json.empty()) { 94190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_driver_bug_list_.reset(gpu::GpuDriverBugList::Create()); 9424e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) if (log_gpu_control_list_decisions) 9434e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) gpu_driver_bug_list_->enable_control_list_logging("gpu_driver_bug_list"); 9444e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) bool success = gpu_driver_bug_list_->LoadList( 945a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) gpu_driver_bug_list_json, gpu::GpuControlList::kCurrentOsOnly); 9464e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) DCHECK(success); 947a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 948a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 949a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info_ = gpu_info; 950a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdateGpuInfo(gpu_info); 951a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdateGpuSwitchingManager(gpu_info); 952a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdatePreliminaryBlacklistedFeatures(); 953a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 954a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 955a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures( 956a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::set<int>& features) { 957a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) blacklisted_features_ = features; 958a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 959a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Force disable using the GPU for these features, even if they would 960a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // otherwise be allowed. 9610529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch if (card_blacklisted_) { 9620529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING); 96390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_WEBGL); 964a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 965a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 9661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci EnableWarpIfNecessary(); 967a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EnableSwiftShaderIfNecessary(); 968a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 969a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 970a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() { 971a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) preliminary_blacklisted_features_ = blacklisted_features_; 972a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 973a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 974a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager( 97590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const gpu::GPUInfo& gpu_info) { 976a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ui::GpuSwitchingManager::GetInstance()->SetGpuCount( 977a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info.secondary_gpus.size() + 1); 978a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 979a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { 980f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) if (gpu_driver_bugs_.count(gpu::FORCE_DISCRETE_GPU) == 1) 981f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); 982f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) else if (gpu_driver_bugs_.count(gpu::FORCE_INTEGRATED_GPU) == 1) 983f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); 984a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 985a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 986a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 987a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() { 988a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->Notify(&GpuDataManagerObserver::OnGpuInfoUpdate); 989a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 990a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 991a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() { 9921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (ShouldUseWarp()) 9931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return; 9941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 995a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!GpuAccessAllowed(NULL) || 99690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) { 997a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!swiftshader_path_.empty() && 9986e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) !base::CommandLine::ForCurrentProcess()->HasSwitch( 999a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kDisableSoftwareRasterizer)) 1000a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) use_swiftshader_ = true; 1001a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1002a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1003a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 10041320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid GpuDataManagerImplPrivate::EnableWarpIfNecessary() { 10051320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#if defined(OS_WIN) 10061320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (use_warp_) 10071320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return; 10081320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // We should only use WARP if we are unable to use the regular GPU for 10091320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // compositing, and if we in Metro mode. 10101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci use_warp_ = 10111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci CommandLine::ForCurrentProcess()->HasSwitch(switches::kViewerConnect) && 10121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci !CanUseGpuBrowserCompositor(); 10131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif 10141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 10151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 10161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid GpuDataManagerImplPrivate::ForceWarpModeForTesting() { 10171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci use_warp_ = true; 10181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 10191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 1020a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)std::string GpuDataManagerImplPrivate::GetDomainFromURL( 1021a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const GURL& url) const { 1022a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // For the moment, we just use the host, or its IP address, as the 1023a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // entry in the set, rather than trying to figure out the top-level 1024a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // domain. This does mean that a.foo.com and b.foo.com will be 1025a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // treated independently in the blocking of a given domain, but it 1026a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // would require a third-party library to reliably figure out the 1027a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // top-level domain from a URL. 1028a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!url.has_host()) { 1029a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return std::string(); 1030a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1031a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1032a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return url.host(); 1033a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1034a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1035a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIsAtTime( 1036a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const GURL& url, 1037a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::DomainGuilt guilt, 1038a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::Time at_time) { 1039a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!domain_blocking_enabled_) 1040a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 1041a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1042a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string domain = GetDomainFromURL(url); 1043a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1044a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DomainBlockEntry& entry = blocked_domains_[domain]; 1045a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) entry.last_guilt = guilt; 1046a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) timestamps_of_gpu_resets_.push_back(at_time); 1047a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1048a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1049a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)GpuDataManagerImpl::DomainBlockStatus 1050a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)GpuDataManagerImplPrivate::Are3DAPIsBlockedAtTime( 1051a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const GURL& url, base::Time at_time) const { 1052a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!domain_blocking_enabled_) 1053a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_NOT_BLOCKED; 1054a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1055a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Note: adjusting the policies in this code will almost certainly 1056a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // require adjusting the associated unit tests. 1057a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string domain = GetDomainFromURL(url); 1058a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1059a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DomainBlockMap::const_iterator iter = blocked_domains_.find(domain); 1060a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (iter != blocked_domains_.end()) { 1061a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Err on the side of caution, and assume that if a particular 1062a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // domain shows up in the block map, it's there for a good 1063a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // reason and don't let its presence there automatically expire. 1064a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1065a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UMA_HISTOGRAM_ENUMERATION("GPU.BlockStatusForClient3DAPIs", 1066a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, 1067a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_MAX); 1068a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1069a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_BLOCKED; 1070a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1071a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1072a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Look at the timestamps of the recent GPU resets to see if there are 1073a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // enough within the threshold which would cause us to blacklist all 1074a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // domains. This doesn't need to be overly precise -- if time goes 1075a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // backward due to a system clock adjustment, that's fine. 1076a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // 1077a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // TODO(kbr): make this pay attention to the TDR thresholds in the 1078a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Windows registry, but make sure it continues to be testable. 1079a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) { 1080a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::list<base::Time>::iterator iter = timestamps_of_gpu_resets_.begin(); 1081a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int num_resets_within_timeframe = 0; 1082a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) while (iter != timestamps_of_gpu_resets_.end()) { 1083a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::Time time = *iter; 1084a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::TimeDelta delta_t = at_time - time; 1085a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1086a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // If this entry has "expired", just remove it. 1087a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (delta_t.InMilliseconds() > kBlockAllDomainsMs) { 1088a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) iter = timestamps_of_gpu_resets_.erase(iter); 1089a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) continue; 1090a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1091a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1092a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ++num_resets_within_timeframe; 1093a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ++iter; 1094a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1095a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1096a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (num_resets_within_timeframe >= kNumResetsWithinDuration) { 1097a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UMA_HISTOGRAM_ENUMERATION("GPU.BlockStatusForClient3DAPIs", 1098a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_ALL_DOMAINS_BLOCKED, 1099a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_MAX); 1100a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1101a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_ALL_DOMAINS_BLOCKED; 1102a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1103a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1104a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1105a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UMA_HISTOGRAM_ENUMERATION("GPU.BlockStatusForClient3DAPIs", 1106a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_NOT_BLOCKED, 1107a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_MAX); 1108a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1109a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_NOT_BLOCKED; 1110a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1111a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1112a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)int64 GpuDataManagerImplPrivate::GetBlockAllDomainsDurationInMs() const { 1113a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return kBlockAllDomainsMs; 1114a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1115a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1116a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::Notify3DAPIBlocked(const GURL& url, 1117a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int render_process_id, 1118a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int render_view_id, 1119a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ThreeDAPIType requester) { 1120a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::UnlockedSession session(owner_); 1121a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, 1122a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) url, render_process_id, render_view_id, requester); 1123a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1124a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1125eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochvoid GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { 1126eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch gpu_process_accessible_ = false; 11271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; 11281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#if defined(OS_WIN) 11291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; 11301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif 1131eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch complete_gpu_info_already_requested_ = true; 1132eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Some observers might be waiting. 1133eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch NotifyGpuInfoUpdate(); 1134eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch} 1135eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 1136a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} // namespace content 1137