Staying on integrated GPU while using NSOpenGLView

  • Hello,
    I'm having issues getting an app to not trigger switching to the dedicated GPU when using NSOpenGLView.

    I've added NSSupportsAutomaticGraphicsSwitching: YES to the Info.plist, but the dedicated GPU keeps getting triggered no matter what, just as soon as I call [self openGLContext] from inside the initWithFrame method (my view is a subclass of NSOpenGLView).

    I've seen both and <A href="http://developer.apple.com/library/mac/#technotes/tn2229/_index.html">http://developer.apple.com/library/mac/#technotes/tn2229/_index.html, but I haven't been able to glean anything else that could help me from there.

    Is there anything I'm doing wrong? I've read on this mailing list before (http://lists.apple.com/archives/cocoa-dev/2011/Mar/msg00795.html) that specifying certain pixel formats could cause the discrete GPU to be triggered, but I'n not even defining any pixel format when I'm initting the NSOpenGLView, just a simple [super initWithFrame:frameRect].

    Building against the 10.7 SDK, for i386 arch only, in case that matters. Currently testing on 10.8 with a 15" Retina MBP (MacBookPro10,1, early 2013).

    Thanks,
    Miguel Pontes
  • On Jun 10, 2013, at 10:03 PM, Miguel Pontes <miguelpontes...> wrote:

    > Hello,
    > I'm having issues getting an app to not trigger switching to the dedicated GPU when using NSOpenGLView.
    […]
    > Is there anything I'm doing wrong? I've read on this mailing list before (http://lists.apple.com/archives/cocoa-dev/2011/Mar/msg00795.html) that specifying certain pixel formats could cause the discrete GPU to be triggered, but I'n not even defining any pixel format when I'm initting the NSOpenGLView, just a simple [super initWithFrame:frameRect].

    No, you're not doing anything wrong. I was curious about this as well, and I noticed that, starting in 10.8.4, instantiating an IKImageBrowserView will not toggle the discrete GPU. So I tried to figure out what it was doing, and found it uses four pixel formats: NSOpenGLPFAAllowOfflineRenderers, NSOpenGLPFANoRecovery, NSOpenGLPFAAccelerated, and a mysterious pixel format identified as 1262.

    The first three of the above are standard pixel formats, but the 1262 format doesn't appear to be documented anywhere. I found out that adding the undocumented pixel format in addition to the three above apparently prevents the discrete switch-over from happening. Since it's undocumented, the usual disclaimers apply: use it at your own risk, it may break in the future, and all that.

    Nick Zitzmann
    <http://www.chronosnet.com/>
  • On Jun 11, 2013, at 21:39 , Nick Zitzmann <nick...> wrote:

    > On Jun 10, 2013, at 10:03 PM, Miguel Pontes <miguelpontes...> wrote:
    >
    >> Hello,
    >> I'm having issues getting an app to not trigger switching to the dedicated GPU when using NSOpenGLView.
    > […]
    >> Is there anything I'm doing wrong? I've read on this mailing list before (http://lists.apple.com/archives/cocoa-dev/2011/Mar/msg00795.html) that specifying certain pixel formats could cause the discrete GPU to be triggered, but I'n not even defining any pixel format when I'm initting the NSOpenGLView, just a simple [super initWithFrame:frameRect].
    >
    > No, you're not doing anything wrong. I was curious about this as well, and I noticed that, starting in 10.8.4, instantiating an IKImageBrowserView will not toggle the discrete GPU. So I tried to figure out what it was doing, and found it uses four pixel formats: NSOpenGLPFAAllowOfflineRenderers, NSOpenGLPFANoRecovery, NSOpenGLPFAAccelerated, and a mysterious pixel format identified as 1262.
    >
    > The first three of the above are standard pixel formats, but the 1262 format doesn't appear to be documented anywhere. I found out that adding the undocumented pixel format in addition to the three above apparently prevents the discrete switch-over from happening. Since it's undocumented, the usual disclaimers apply: use it at your own risk, it may break in the future, and all that.
    >
    > Nick Zitzmann
    > <http://www.chronosnet.com/>

    Actually, I was being dumb. I was failing to set the "NSOpenGLPFAAllowOfflineRenderers" pixel format. You must explicitly set that one for NSOpenGLView to not trigger a GPU change. Just letting it use the defaults won't work.

    With NSOpenGLPFAAllowOfflineRenderers as a pixel format + NSSupportsAutomaticGraphicsSwitching in the Info.plist, the GPU change isn't triggered.

    That 1262 format is a nice find, though. It appears that using it as a pixel format makes it ALWAYS use the integrated graphics, even without needing to set NSSupportsAutomaticGraphicsSwitching to YES in the Info.plist. I'm assuming they added that as a private, internal mode in order to make it so programs that use framework classes such as that ImageKit one you mentioned don't indadvertedly switch to discrete graphics when they use them, without the developers needing to go and explicitly modify the plist.

    Thanks!
    Miguel Pontes
  • On 6/11/13, Nick Zitzmann <nick...> wrote:
    >

    > No, you're not doing anything wrong. I was curious about this as well, and I
    > noticed that, starting in 10.8.4, instantiating an IKImageBrowserView will
    > not toggle the discrete GPU. So I tried to figure out what it was doing, and
    > found it uses four pixel formats: NSOpenGLPFAAllowOfflineRenderers,
    > NSOpenGLPFANoRecovery, NSOpenGLPFAAccelerated, and a mysterious pixel format
    > identified as 1262.
    >
    > The first three of the above are standard pixel formats, but the 1262 format
    > doesn't appear to be documented anywhere. I found out that adding the
    > undocumented pixel format in addition to the three above apparently prevents
    > the discrete switch-over from happening. Since it's undocumented, the usual
    > disclaimers apply: use it at your own risk, it may break in the future, and
    > all that.
    >
    > Nick Zitzmann
    > <http://www.chronosnet.com/>
    >
    >

    I'm curious, how did you examine which specific parameter values
    IKImageBrowserView used?

    Thanks,
    Eric
    --
    Beginning iPhone Games Development
    http://playcontrol.net/iphonegamebook/
  • On Jun 12, 2013, at 11:15 AM, Eric Wing <ewmailing...> wrote:

    > I'm curious, how did you examine which specific parameter values
    > IKImageBrowserView used?

    I just broke on -[NSOpenGLPixelFormat initWithAttributes:] and had a look at those attributes. IKImageBrowserView uses OpenGL internally, and uses NSOpenGLPixelFormat to set up its pixel format.

    Nick Zitzmann
    <http://www.chronosnet.com/>
previous month june 2013 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today