Re: CGDisplaySetDisplayMode only working properly after calling twice in a row
Re: CGDisplaySetDisplayMode only working properly after calling twice in a row
- Subject: Re: CGDisplaySetDisplayMode only working properly after calling twice in a row
- From: Ken Thomases <email@hidden>
- Date: Thu, 22 May 2014 09:17:05 -0500
On May 21, 2014, at 6:25 PM, Matthias Dörfelt wrote:
> Capturing the display does not make a difference.
Did you capture it before or after creating the pixel format object?
> Anyways, your guess about the GPU switching was spot on! If I disable it, the issue disappears. Is there any way to fix this in my code? I.e. an NSOpenGLPixelFormat flag that would take that into account?
Technical Q&A QA1734: Allowing OpenGL applications to utilize the integrated GPU
https://developer.apple.com/library/mac/qa/qa1734/_index.html
That will avoid switching the GPU, but then you have to make your app cope with something else changing the GPU on the fly:
Technical Note TN2229: Supporting Multiple GPUs on Mac OS X
https://developer.apple.com/library/mac/technotes/tn2229/_index.html
On May 21, 2014, at 8:45 PM, Matthias Dörfelt wrote:
> The more I think about this, the more I think this deserves a bug report.
Sure. The behavior is clearly not something that a developer could or should anticipate.
> If the automatic GPU switching gets triggered by switching the display mode in the first place, and the newly active GPU supports the same display format, shouldn’t it make sure it keeps the same format? I don’t see how that should be the job of client code. Any thoughts?
It's not changing the display mode which switches the GPU. It's the use of OpenGL.
The two GPUs use different display modes. Since you're calling CGDisplayCopyAllDisplayModes() after triggering the switch, you should be OK, because you should get the modes appropriate for the discrete GPU. Obviously, that's not happening.
I suspect that Quartz needs an opportunity to detect the change of GPU before it starts returning the new set of display modes. I suspect that returning to the run loop between creating the pixel format and changing the display mode would let it notice. Apparently, the attempt to change the display mode also gives it an opportunity to update itself. At that point, it's too late for that particular attempt but fixes the next one. I guess.
I also suspect that capturing the display between creating the pixel format object and querying the display modes would give Quartz the opportunity to notice the GPU change.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden