Commit 521697f5 authored by kbr's avatar kbr Committed by Commit bot

Refine dual-GPU detection on Mac OS X.

Only consider the system to have dual GPUs if one is an Intel GPU and
the other isn't. This avoids problems where recent Mac Pros which
contain dual AMD GPUs are considered to be "dual-GPU". One symptom was
a 300 ms scroll lag on these machines once idle for 10 seconds as
described in https://codereview.chromium.org/1147653002/ .

BUG=380026

Review URL: https://codereview.chromium.org/1144843005

Cr-Commit-Position: refs/heads/master@{#330471}
parent 0ee6d7d8
......@@ -1037,8 +1037,14 @@ void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() {
void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager(
const gpu::GPUInfo& gpu_info) {
ui::GpuSwitchingManager::GetInstance()->SetGpuCount(
gpu_info.secondary_gpus.size() + 1);
// The vendor IDs might be 0 on non-PCI devices (like Android), but
// the length of the vector is all we care about in most cases.
std::vector<uint32> vendor_ids;
vendor_ids.push_back(gpu_info.gpu.vendor_id);
for (const auto& device : gpu_info.secondary_gpus) {
vendor_ids.push_back(device.vendor_id);
}
ui::GpuSwitchingManager::GetInstance()->SetGpuVendorIds(vendor_ids);
if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) {
if (gpu_driver_bugs_.count(gpu::FORCE_DISCRETE_GPU) == 1)
......
......@@ -32,7 +32,6 @@ GpuSwitchingManager::GpuSwitchingManager()
gpu_switching_option_set_(false),
supports_dual_gpus_(false),
supports_dual_gpus_set_(false),
gpu_count_(0),
platform_specific_(new PlatformSpecific) {
#if defined(OS_MACOSX)
platform_specific_->discrete_pixel_format = nullptr;
......@@ -91,7 +90,7 @@ bool GpuSwitchingManager::SupportsDualGpus() {
// Browser process.
// We only compute this flag in the browser process.
#if defined(OS_MACOSX)
flag = (gpu_count_ == 2);
flag = (vendor_ids_.size() == 2);
if (flag && command_line.HasSwitch(switches::kUseGL) &&
command_line.GetSwitchValueASCII(switches::kUseGL) !=
gfx::kGLImplementationDesktopName)
......@@ -99,6 +98,17 @@ bool GpuSwitchingManager::SupportsDualGpus() {
if (flag && !base::mac::IsOSLionOrLater())
flag = false;
if (flag) {
// Only advertise that we have two GPUs to the rest of
// Chrome's code if we find an Intel GPU and some other
// vendor's GPU. Otherwise we don't understand the
// configuration and don't deal well with it (an example being
// the dual AMD GPUs in recent Mac Pros).
const uint32 intel = 0x8086;
flag = ((vendor_ids_[0] == intel && vendor_ids_[1] != intel) ||
(vendor_ids_[0] != intel && vendor_ids_[1] == intel));
}
#endif // OS_MACOSX
}
supports_dual_gpus_ = flag;
......@@ -107,8 +117,9 @@ bool GpuSwitchingManager::SupportsDualGpus() {
return supports_dual_gpus_;
}
void GpuSwitchingManager::SetGpuCount(size_t gpu_count) {
gpu_count_ = gpu_count;
void GpuSwitchingManager::SetGpuVendorIds(
const std::vector<uint32>& vendor_ids) {
vendor_ids_ = vendor_ids;
}
void GpuSwitchingManager::AddObserver(GpuSwitchingObserver* observer) {
......
......@@ -36,7 +36,9 @@ class GL_EXPORT GpuSwitchingManager {
// --supports-dual-gpus commandline switch.
bool SupportsDualGpus();
void SetGpuCount(size_t gpu_count);
// Sets the vendor IDs of the GPUs on the system. The length of this
// vector defines the count of GPUs.
void SetGpuVendorIds(const std::vector<uint32>& vendor_ids);
void AddObserver(GpuSwitchingObserver* observer);
void RemoveObserver(GpuSwitchingObserver* observer);
......@@ -61,11 +63,11 @@ class GL_EXPORT GpuSwitchingManager {
gfx::GpuPreference gpu_switching_option_;
bool gpu_switching_option_set_;
std::vector<uint32> vendor_ids_;
bool supports_dual_gpus_;
bool supports_dual_gpus_set_;
size_t gpu_count_;
struct PlatformSpecific;
scoped_ptr<PlatformSpecific> platform_specific_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment