aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/devdraw
diff options
context:
space:
mode:
authorChris Schultz <christopher.schultz@auth0.com>2019-04-05 14:08:20 -0500
committerRuss Cox <rsc@golang.org>2019-04-05 15:08:20 -0400
commit61601587295f6d0ef1c4084530fe0318e0c72b16 (patch)
tree210fc2dc9234721c33f20790dbecfda46f674490 /src/cmd/devdraw
parent26c6b2579543e928158fa7d3c00d8b0e04ac270c (diff)
downloadplan9port-61601587295f6d0ef1c4084530fe0318e0c72b16.tar.gz
plan9port-61601587295f6d0ef1c4084530fe0318e0c72b16.tar.bz2
plan9port-61601587295f6d0ef1c4084530fe0318e0c72b16.zip
devdraw: prefer low-power GPU for macOS metal rendering (#231)
Diffstat (limited to 'src/cmd/devdraw')
-rw-r--r--src/cmd/devdraw/cocoa-screen-metal.m15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m
index 78110302..21c041a5 100644
--- a/src/cmd/devdraw/cocoa-screen-metal.m
+++ b/src/cmd/devdraw/cocoa-screen-metal.m
@@ -153,6 +153,7 @@ threadmain(int argc, char **argv)
id<MTLLibrary> library;
MTLRenderPipelineDescriptor *pipelineDesc;
NSError *error;
+ NSArray *allDevices;
const NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled
| NSWindowStyleMaskClosable
@@ -197,8 +198,18 @@ threadmain(int argc, char **argv)
[win setContentView:myContent];
[myContent setWantsLayer:YES];
[myContent setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay];
-
- 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];