Using integrated graphics with ANGLE on MacOS

282 views
Skip to first unread message

Hamish Arblaster

unread,
Sep 15, 2020, 5:27:02 PM9/15/20
to angleproject
How do I use integrated graphics with ANGLE on MacOS?

I have a program that renders with ANGLE and can run on MacOS, and I was wondering how I could use the integrated graphics card instead of the discrete graphics card, I have already tried setting NSSupportsAutomaticGraphicsSwitching to true, but it makes my view go away and still uses the graphics card somehow.

Is there some way that I can force it to use the integrated GPU if available because I think that using the graphics card is overkill for my application?

Specifically I'm looking for some sort of an API / code snippet to use, and/or some values that need to be set in the info.plist file. All I'm using is a class inherited from NSView that keeps drawing itself in UpdateLayer.

My application is in C# using Xamarin.Mac, and an experimental (but functional) AngleSharp wrapper, but code snippets in any relevant language should help. Thanks!

Ken Russell

unread,
Sep 15, 2020, 6:03:09 PM9/15/20
to hama...@gmail.com, angleproject
I'm surprised that setting NSSupportsAutomaticGraphicsSwitching to true in your Info.plist doesn't keep your application on the integrated GPU. Have you tried stripping everything out, using raw CGL to create an OpenGL context with the kCGLPFAAllowOfflineRenderers context creation attribute, and verifying that your system stays on the integrated GPU?

The code which implements automatic graphics switching in ANGLE on macOS is here:

Note that most applications can't switch to the discrete GPU and then back to the integrated GPU - once they've switched to the discrete GPU, they stay there indefinitely. This was a stability decision made by Apple a long time ago and never revisited.

-Ken



--
You received this message because you are subscribed to the Google Groups "angleproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angleproject/a35a7b79-9d7d-474f-8a91-966461853a3fn%40googlegroups.com.

Hamish Arblaster

unread,
Sep 15, 2020, 7:27:14 PM9/15/20
to angleproject
I'm not exactly sure how to use the raw CGL.
I've done more extensive testing after including EGL_POWER_PREFERENCE_ANGLE, which I did not know about, here are my results (I checked whether it's being used with Graphics history in activity monitor):Screen Shot 2020-09-16 at 9.22.30 am.png
It could be (most likely is) that I've set up my code incorrectly.
I've attached some relevant code.
Archive.zip
Message has been deleted
Message has been deleted

Ken Russell

unread,
Sep 18, 2020, 2:53:56 PM9/18/20
to hama...@gmail.com, angleproject
I'm sorry but we don't have the resources to try to build and test your app. Maybe the Xamarin developers who maintain these graphics bindings could help. Scanning through the code, it seems fine.

I don't understand the result that setting NSSupportsAutomaticGraphicsSwitching=Yes in your app makes it so that neither the integrated nor discrete GPU is used. The best next step would be to track down any errors that are caused by that setting. Chromium uses it: https://source.chromium.org/search?q=NSSupportsAutomaticGraphicsSwitching .

-Ken



On Fri, Sep 18, 2020 at 4:05 AM Hamish Arblaster <hama...@gmail.com> wrote:
Can anyone help me with this?

Hamish Arblaster

unread,
Sep 19, 2020, 7:52:44 PM9/19/20
to angleproject
Hey, the ANGLE bindings are my own and work completely fine in every other way on MacOS and Windows.
I added the CGDisplayRegisterReconfigurationCallback code which calls EGL.HandleGPUSwitchANGLE, but it still doesn't work properly.
I logged the output of CGDisplayRegisterReconfigurationCallback (LOW_POWER_ANGLE)
The console output is this:

Context (0x7fead682ac00) set to GPU with ID: (4294970113).

Switch detected flag: 0x00000001, display: 69734406.

Switch detected flag: 0x00000001, display: 2077749241.

Switch detected flag: 0x0000211C, display: 69734406.

Switch detected flag: 0x00002220, display: 2077749241.


Do you think that you could make a minimum code needed for a triangle in a single file sample for an ANGLE project on MacOS that definitely uses the integrated GPU so I can try to see what I've done wrong?

Ken Russell

unread,
Sep 25, 2020, 7:20:46 PM9/25/20
to hama...@gmail.com, angleproject
I'm really sorry but don't have time to do that.


Reply all
Reply to author
Forward
0 new messages