PICO-8 uses the discrete GPU on mac laptops; this uses a lot of power on battery.
@zep, could PICO-8 use the integrated graphics instead of the discrete GPU?
I really hope this change is compatible with PICO-8, I would really like to use it on battery and still have decent battery life. PICO-8 seems lightweight otherwise.
Resources I found on this topic:
This is a link to how GLFW sets up an OpenGL context on the integrated GPU on macOS
In SDL2, I added those two attributes used in the GLFW source to the NSOpenGLPixelFormat init call found in
This caused all of the example apps in the Xcode "SDLTest" project in the SDL2 source code to use the integrated graphics, the attributes being: "NSOpenGLPFAAllowOfflineRenderers" and "kCGLPFASupportsAutomaticGraphicsSwitching"
Here is the partial change from the SDL source tree (missing adding attribute "kCGLPFASupportsAutomaticGraphicsSwitching"):
(edited to a single post for easy reading, thanks @PixelBytes)
Interesting -- yes, this looks like something PICO-8 probably should do as it only uses the gpu for blitting. I plan to do one more round of optimization during beta, but until then you could also try running in software blitting mode:
Open Terminal and navigate to PICO-8.app/Contents/MacOS
- Run PICO-8 with: ./pico8 -software_blit 1 -windowed 1
(this is still experimental for OSX and probably won't work in full-screen mode)
I ran PICO-8 with those command line arguments, but the discrete GPU was still used. :(
I've found that even trivial SDL apps that use just blitting will still trigger the discrete GPU on mac, unless those both "NSOpenGLPixelFormatAttribute" are provided.
In SDL2, these need to be added at about line 175 of src/video/cocoa/SDL_cocoaopengl.m
attr[i++] = NSOpenGLPFAAllowOfflineRenderers; attr[i++] = kCGLPFASupportsAutomaticGraphicsSwitching;
Log in to post a comment