Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphics (GPU) switching on macOS #2423

Closed
samuel opened this issue Sep 1, 2021 · 3 comments
Closed

Graphics (GPU) switching on macOS #2423

samuel opened this issue Sep 1, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@samuel
Copy link

samuel commented Sep 1, 2021

On a MacBook Pro Fyne uses the discrete rather than integrated GPU. This can lead to higher battery usage. Ideally, Fine would by default utilize the automatic switching by adding a hint to the GLFW window.

As is, when running a simple Fyne application I see usage of the discrete GPU, AMD Radeon Pro (as observed in gfxCardStatus and Activity Monitor GPU utilization). Adding glfw.WindowHint(glfw.CocoaGraphicsSwitching, 1) to glfw_core.go and running the same Fyne application shows usage of the integrated GPU, Intel HD Graphics.

Documentation for the hint is at https://www.glfw.org/docs/latest/window_guide.html

GLFW_COCOA_GRAPHICS_SWITCHING specifies whether to in Automatic Graphics Switching, i.e. to allow the system to choose the integrated GPU for the OpenGL context and move it between GPUs if necessary or whether to force it to always run on the discrete GPU. This only affects systems with both integrated and discrete GPUs. Possible values are GLFW_TRUE and GLFW_FALSE. This is ignored on other platforms.

Simpler programs and tools may want to enable this to save power, while games and other applications performing advanced rendering will want to leave it disabled.

A bundled application that wishes to participate in Automatic Graphics Switching should also declare this in its Info.plist by setting the NSSupportsAutomaticGraphicsSwitching key to true.

I believe that providing the hint is a better default as most applications will likely not need the performance of the discrete GPU and be better off saving power. It should also be possible to optionally (though I haven't considered the API) choose to use the discrete GPU (not providing the hint).

andydotxyz added a commit to andydotxyz/fyne that referenced this issue Sep 1, 2021
@andydotxyz
Copy link
Member

Can you please test #2425 for me @samuel?
You will need to build and install the fyne command from this patch as well, because it needs an updated Info.plist template.

@samuel
Copy link
Author

samuel commented Sep 1, 2021

The change works great. Using the new Fyne command and fyne package and running the .app, and also just go build and running it outside of the .app. For both the integrated GPU is used instead of the discrete.

Thanks for the the very quick response to this!

@andydotxyz
Copy link
Member

Thanks for confirming, this is now on develop and will be in v2.1

@andydotxyz andydotxyz added this to the Aberlour (2.1) milestone Sep 6, 2021
@andydotxyz andydotxyz added the bug Something isn't working label Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants