summaryrefslogtreecommitdiffstats
path: root/ui/gfx/gl
diff options
context:
space:
mode:
authorkbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 02:57:02 +0000
committerkbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 02:57:02 +0000
commitaebadfeb3084d62b0b0b55111f12b0585f7f1fc9 (patch)
tree3f58b4f9277d84fec808f68b19ddb1b7206e5c8d /ui/gfx/gl
parent26d2456d9f8981b05ad661fa91db9a99e749833c (diff)
downloadchromium_src-aebadfeb3084d62b0b0b55111f12b0585f7f1fc9.zip
chromium_src-aebadfeb3084d62b0b0b55111f12b0585f7f1fc9.tar.gz
chromium_src-aebadfeb3084d62b0b0b55111f12b0585f7f1fc9.tar.bz2
Worked around IOSurface related system lockups on dual NVIDIA/Intel GPU
MacBook Pros by forcing Chrome to use and stay on the discrete GPU on such systems. BUG=113703 TEST=ran Gmail and WebGL demos on dual NVIDIA/Intel and AMD/Intel GPU MBPs Review URL: http://codereview.chromium.org/9365066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122013 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/gl')
-rw-r--r--ui/gfx/gl/gl_context_cgl.cc13
-rw-r--r--ui/gfx/gl/gl_context_cgl.h9
-rw-r--r--ui/gfx/gl/gl_context_mac.mm21
3 files changed, 40 insertions, 3 deletions
diff --git a/ui/gfx/gl/gl_context_cgl.cc b/ui/gfx/gl/gl_context_cgl.cc
index f530f3a..79fe282 100644
--- a/ui/gfx/gl/gl_context_cgl.cc
+++ b/ui/gfx/gl/gl_context_cgl.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -146,4 +146,15 @@ GpuPreference GLContextCGL::GetGpuPreference() {
return gpu_preference_;
}
+void GLContextCGL::ForceUseOfDiscreteGPU() {
+ static CGLPixelFormatObj format = NULL;
+ if (format)
+ return;
+ CGLPixelFormatAttribute attribs[1];
+ attribs[0] = static_cast<CGLPixelFormatAttribute>(0);
+ GLint num_pixel_formats = 0;
+ CGLChoosePixelFormat(attribs, &format, &num_pixel_formats);
+ // format is deliberately leaked.
+}
+
} // namespace gfx
diff --git a/ui/gfx/gl/gl_context_cgl.h b/ui/gfx/gl/gl_context_cgl.h
index fdceeda..021882b 100644
--- a/ui/gfx/gl/gl_context_cgl.h
+++ b/ui/gfx/gl/gl_context_cgl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -24,12 +24,19 @@ class GLContextCGL : public GLContext {
virtual void* GetHandle() OVERRIDE;
virtual void SetSwapInterval(int interval) OVERRIDE;
+ // Expose ForceUseOfDiscreteGPU only to GLContext implementation.
+ friend class GLContext;
+
private:
void* context_;
GpuPreference gpu_preference_;
GpuPreference GetGpuPreference();
+ // Helper for dual-GPU support on systems where this is necessary
+ // for stability reasons.
+ static void ForceUseOfDiscreteGPU();
+
DISALLOW_COPY_AND_ASSIGN(GLContextCGL);
};
diff --git a/ui/gfx/gl/gl_context_mac.mm b/ui/gfx/gl/gl_context_mac.mm
index 6e68ccf..c863512 100644
--- a/ui/gfx/gl/gl_context_mac.mm
+++ b/ui/gfx/gl/gl_context_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -146,6 +146,25 @@ bool GLContext::SupportsDualGpus() {
}
if (found_online && found_offline) {
+ // Only switch GPUs dynamically on recent MacBook Pro models.
+ // Otherwise, keep the system on the discrete GPU for the lifetime
+ // of the browser process, since switching back and forth causes
+ // system stability issues. http://crbug.com/113703
+ std::string model;
+ int32 model_major, model_minor;
+ if (!base::mac::ParseModelIdentifier(base::mac::GetModelIdentifier(),
+ &model, &model_major, &model_minor)) {
+ return false;
+ }
+ if (model == "MacBookPro") {
+ const int kMacBookProFirstDualAMDIntelGPUModel = 8;
+ if (model_major < kMacBookProFirstDualAMDIntelGPUModel) {
+ // We're on an older MacBook Pro.
+ GLContextCGL::ForceUseOfDiscreteGPU();
+ return false;
+ }
+ }
+
supports_dual_gpus = true;
}