diff options
author | kbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-13 22:55:50 +0000 |
---|---|---|
committer | kbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-13 22:55:50 +0000 |
commit | 276f89060fa4b38582dcd76ebdf9454bb7d42c8e (patch) | |
tree | 0ff1c47fed812c196ae491a6c7295164d557e813 /ui/gfx/gl/gl_context.h | |
parent | 91701aec11f289e96ce92b588b858b26179cb89c (diff) | |
download | chromium_src-276f89060fa4b38582dcd76ebdf9454bb7d42c8e.zip chromium_src-276f89060fa4b38582dcd76ebdf9454bb7d42c8e.tar.gz chromium_src-276f89060fa4b38582dcd76ebdf9454bb7d42c8e.tar.bz2 |
Support dynamic switching between integrated and discrete GPUs on Mac OS X.
Change Chrome to allocate most OpenGL contexts with the
kCGLPFAAllowOfflineRenderers flag, and specify
NSSupportsAutomaticGraphicsSwitching in the Info.plist for the main
executable and helper apps. This keeps Chrome on the integrated GPU
except when using WebGL, accelerated 2D Canvas, Pepper 3D, and Core
Animation-based plugins (except Flash).
Chrome shares resources between OpenGL contexts in order to display WebGL
and other content in the compositor, and resource sharing doesn't work
between contexts allocated on different GPUs. Therefore, when the first
context for a given renderer requests the discrete GPU, the channel is
dropped and all contexts are reallocated on the discrete GPU. Similarly,
when the last context requesting the discrete GPU for a given renderer is
shut down, all contexts are dropped and reallocated on the integrated GPU.
Currently dynamic GPU switching is only supported on the latest Mac OS X
10.7 update and MacBook Pros with dual AMD / Intel GPUs, though this will
improve in future OS updates.
Tested with WebGL, CSS 3D, Flash and Unity3D content and observed desired
GPU switching behavior. Also added a layout test to WebKit under
https://bugs.webkit.org/show_bug.cgi?id=69776 which when run in Chrome
catches an assertion failure related to the destruction of contexts. The
intent is to add it as a UI layout test on the GPU bots.
BUG=88788
TEST=none
Review URL: http://codereview.chromium.org/8233027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105399 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/gl/gl_context.h')
-rw-r--r-- | ui/gfx/gl/gl_context.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ui/gfx/gl/gl_context.h b/ui/gfx/gl/gl_context.h index 0a617f4..3046485 100644 --- a/ui/gfx/gl/gl_context.h +++ b/ui/gfx/gl/gl_context.h @@ -11,6 +11,7 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "ui/gfx/gl/gl_share_group.h" +#include "ui/gfx/gl/gpu_preference.h" namespace gfx { @@ -25,7 +26,8 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> { // context can be made with other surface's of the same type. The compatible // surface is only needed for certain platforms like WGL, OSMesa and GLX. It // should be specific for all platforms though. - virtual bool Initialize(GLSurface* compatible_surface) = 0; + virtual bool Initialize( + GLSurface* compatible_surface, GpuPreference gpu_preference) = 0; // Destroys the GL context. virtual void Destroy() = 0; @@ -60,10 +62,13 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> { // internally created OpenGL context shares textures and other resources. static scoped_refptr<GLContext> CreateGLContext( GLShareGroup* share_group, - GLSurface* compatible_surface); + GLSurface* compatible_surface, + GpuPreference gpu_preference); static bool LosesAllContextsOnContextLost(); + static bool SupportsDualGpus(); + static GLContext* GetCurrent(); virtual bool WasAllocatedUsingARBRobustness(); |