Support running Qt apps on the integrated GPU

By default starting an app that uses OpenGL will
switch machines with dual graphics hardware over
to the discrete GPU. This causes a delay at startup
and possibly increased power usage.

It is possible to prevent the switch:

1) Add the NSOpenGLPFAAllowOfflineRenderers attribute
to the OpenGL pixel format. This is done in this commit.

2) Add <key>NSSupportsAutomaticGraphicsSwitching</key><true/>
to the apps Info.plist. This final opt-in is left to
the app author.

Change-Id: Ibff56fd7770a6b7f8041c8bb60bf290eed24330a
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
Morten Johan Sørvig 2013-12-12 14:17:03 +01:00 committed by The Qt Project
parent db73862302
commit 8166a34fc5
1 changed files with 1 additions and 0 deletions

View File

@ -121,6 +121,7 @@ void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format)
<< NSOpenGLPFASamples << (NSOpenGLPixelFormatAttribute) format.samples(); << NSOpenGLPFASamples << (NSOpenGLPixelFormatAttribute) format.samples();
} }
attrs << NSOpenGLPFAAllowOfflineRenderers;
attrs << 0; attrs << 0;
NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs.constData()]; NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs.constData()];