tdevdraw: prefer low-power GPU for macOS metal rendering (#231) - plan9port - [… | |
git clone git://src.adamsgaard.dk/plan9port | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 61601587295f6d0ef1c4084530fe0318e0c72b16 | |
parent 26c6b2579543e928158fa7d3c00d8b0e04ac270c | |
Author: Chris Schultz <[email protected]> | |
Date: Fri, 5 Apr 2019 14:08:20 -0500 | |
devdraw: prefer low-power GPU for macOS metal rendering (#231) | |
Diffstat: | |
M src/cmd/devdraw/cocoa-screen-metal… | 15 +++++++++++++-- | |
1 file changed, 13 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-scree… | |
t@@ -153,6 +153,7 @@ threadmain(int argc, char **argv) | |
id<MTLLibrary> library; | |
MTLRenderPipelineDescriptor *pipelineDesc; | |
NSError *error; | |
+ NSArray *allDevices; | |
const NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled | |
| NSWindowStyleMaskClosable | |
t@@ -197,8 +198,18 @@ threadmain(int argc, char **argv) | |
[win setContentView:myContent]; | |
[myContent setWantsLayer:YES]; | |
[myContent setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSet… | |
- | |
- device = MTLCreateSystemDefaultDevice(); | |
+ | |
+ device = nil; | |
+ allDevices = MTLCopyAllDevices(); | |
+ for(id mtlDevice in allDevices) { | |
+ if ([mtlDevice isLowPower] && ![mtlDevice isRemovable]) { | |
+ device = mtlDevice; | |
+ break; | |
+ } | |
+ } | |
+ if(!device) | |
+ device = MTLCreateSystemDefaultDevice(); | |
+ | |
commandQueue = [device newCommandQueue]; | |
layer = (DrawLayer *)[myContent layer]; |